Completed
Push — master ( 600d7a...2856fd )
by Jamie
03:59
created
classes/views/styles/_buttons.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <p class="frm_no_top_margin">
2 2
 	<label for="frm_submit_style">
3
-		<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('submit_style') ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" />
3
+		<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_style' ) ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" />
4 4
 		<?php esc_html_e( 'Disable submit button styling', 'formidable' ); ?>
5 5
 		<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Note: If disabled, you may not see the change take effect until you make 2 more styling changes or click "Update Options".', 'formidable' ) ?>"></span>
6 6
 	</label>
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 <div class="posttypediv">
10 10
 	<ul class="posttype-tabs add-menu-item-tabs">
11 11
 		<li <?php echo ( 'default' == $current_tab ? ' class="tabs"' : '' ); ?>>
12
-    		<a href="<?php echo esc_url('?page=formidable-styles&page-tab=default#tabs-panel-button-default') ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a>
12
+    		<a href="<?php echo esc_url( '?page=formidable-styles&page-tab=default#tabs-panel-button-default' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a>
13 13
     	</li>
14 14
 		<li <?php echo ( 'button-hover' == $current_tab ? ' class="tabs"' : '' ); ?>>
15
-			<a href="<?php echo esc_url('?page=formidable-styles&page-tab=button-hover#page-button-hover') ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a>
15
+			<a href="<?php echo esc_url( '?page=formidable-styles&page-tab=button-hover#page-button-hover' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a>
16 16
 		</li>
17 17
 		<li <?php echo ( 'button-click' == $current_tab ? ' class="tabs"' : '' ); ?>>
18 18
 			<a href="?page=formidable-styles&page-tab=button-click#tabs-panel-button-click" class="nav-tab-link" data-type="tabs-panel-button-click"><?php _e( 'Click', 'formidable' ) ?></a>
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
 	?>">
25 25
 	    <div class="field-group field-group-border clearfix">
26 26
         	<label><?php _e( 'Size', 'formidable' ) ?></label>
27
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_font_size') ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>"  size="3" />
27
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_font_size' ) ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>"  size="3" />
28 28
         </div>
29 29
 
30 30
         <div class="field-group clearfix">
31 31
         	<label><?php _e( 'Width', 'formidable' ) ?></label>
32
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_width') ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>"  size="5" />
32
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_width' ) ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>"  size="5" />
33 33
         </div>
34 34
 
35 35
         <div class="field-group clearfix">
36 36
         	<label><?php _e( 'Height', 'formidable' ) ?></label>
37
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_height') ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>"  size="5" />
37
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_height' ) ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>"  size="5" />
38 38
         </div>
39 39
 
40 40
         <div class="field-group clearfix">
41 41
         	<label><?php _e( 'Weight', 'formidable' ) ?></label>
42
-        	<select name="<?php echo esc_attr( $frm_style->get_field_name('submit_weight') ) ?>" id="frm_submit_weight">
42
+        	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_weight' ) ) ?>" id="frm_submit_weight">
43 43
 				<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
44 44
 				<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['submit_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
45 45
 				<?php } ?>
@@ -48,48 +48,48 @@  discard block
 block discarded – undo
48 48
 
49 49
         <div class="field-group clearfix">
50 50
         	<label><?php _e( 'Corners', 'formidable' ) ?></label>
51
-        	<input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_radius') ) ?>" id="frm_submit_border_radius" size="4"/>
51
+        	<input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_radius' ) ) ?>" id="frm_submit_border_radius" size="4"/>
52 52
         </div>
53 53
 
54 54
         <div class="field-group field-group-border clearfix">
55 55
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
56
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_color') ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" />
56
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_color' ) ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" />
57 57
         </div>
58 58
 
59 59
         <div class="field-group clearfix">
60 60
         	<label><?php _e( 'Text', 'formidable' ) ?></label>
61
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_text_color') ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" />
61
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_text_color' ) ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" />
62 62
         </div>
63 63
 
64 64
         <div class="field-group field-group-border clearfix">
65 65
         	<label><?php _e( 'Border', 'formidable' ) ?></label>
66
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_color') ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" />
66
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_color' ) ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" />
67 67
         </div>
68 68
 
69 69
         <div class="field-group clearfix">
70 70
         	<label><?php _e( 'Thickness', 'formidable' ) ?></label>
71
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_width') ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" />
71
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_width' ) ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" />
72 72
         </div>
73 73
 
74 74
         <div class="field-group clearfix">
75 75
         	<label><?php _e( 'Shadow', 'formidable' ) ?></label>
76
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_shadow_color') ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" />
76
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_shadow_color' ) ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" />
77 77
         </div>
78 78
 
79 79
         <div class="clear"></div>
80 80
         <div class="field-group field-group-border frm-full">
81 81
         	<label><?php _e( 'BG Image', 'formidable' ) ?></label>
82
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_img') ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>"  />
82
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_img' ) ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>"  />
83 83
         </div>
84 84
 
85 85
         <div class="field-group field-group-border clearfix">
86 86
         	<label><?php _e( 'Margin', 'formidable' ) ?></label>
87
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_margin') ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" />
87
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_margin' ) ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" />
88 88
         </div>
89 89
 
90 90
         <div class="field-group clearfix">
91 91
         	<label><?php _e( 'Padding', 'formidable' ) ?></label>
92
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_padding') ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" />
92
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_padding' ) ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" />
93 93
         </div>
94 94
         <div class="clear"></div>
95 95
 	</div><!-- /.tabs-panel -->
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
 	?>">
100 100
 	    <div class="field-group clearfix">
101 101
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
102
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_bg_color') ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" />
102
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_bg_color' ) ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" />
103 103
         </div>
104 104
 
105 105
         <div class="field-group clearfix">
106 106
     	    <label><?php _e( 'Text', 'formidable' ) ?></label>
107
-    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_color') ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" />
107
+    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_color' ) ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" />
108 108
         </div>
109 109
 
110 110
         <div class="field-group clearfix">
111 111
             <label><?php _e( 'Border', 'formidable' ) ?></label>
112
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_border_color') ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" />
112
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_border_color' ) ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" />
113 113
         </div>
114 114
 
115 115
 	    <div class="clear"></div>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
 	?>">
121 121
 	    <div class="field-group clearfix">
122 122
         	<label><?php _e( 'BG Color', 'formidable' ) ?></label>
123
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_bg_color') ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" />
123
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_bg_color' ) ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" />
124 124
         </div>
125 125
 
126 126
         <div class="field-group clearfix">
127 127
     	    <label><?php _e( 'Text', 'formidable' ) ?></label>
128
-    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_color') ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" />
128
+    	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_color' ) ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" />
129 129
         </div>
130 130
 
131 131
         <div class="field-group clearfix">
132 132
             <label><?php _e( 'Border', 'formidable' ) ?></label>
133
-        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_border_color') ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" />
133
+        	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_border_color' ) ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" />
134 134
         </div>
135 135
 
136 136
 	    <div class="clear"></div>
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = array();
27 27
 		if ( apply_filters( 'frm_include_addon_page', false ) ) {
@@ -30,53 +30,53 @@  discard block
 block discarded – undo
30 30
 				'name' => __( 'Plugin Licenses', 'formidable' ),
31 31
 			);
32 32
 		}
33
-        $sections = apply_filters( 'frm_add_settings_section', $sections );
33
+		$sections = apply_filters( 'frm_add_settings_section', $sections );
34 34
 
35
-        $captcha_lang = FrmAppHelper::locales( 'captcha' );
35
+		$captcha_lang = FrmAppHelper::locales( 'captcha' );
36 36
 
37
-        require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
38
-    }
37
+		require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
38
+	}
39 39
 
40
-    public static function process_form( $stop_load = false ) {
41
-        global $frm_vars;
40
+	public static function process_form( $stop_load = false ) {
41
+		global $frm_vars;
42 42
 
43
-        $frm_settings = FrmAppHelper::get_settings();
43
+		$frm_settings = FrmAppHelper::get_settings();
44 44
 
45 45
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
46 46
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
47
-            wp_die( $frm_settings->admin_permission );
48
-        }
47
+			wp_die( $frm_settings->admin_permission );
48
+		}
49 49
 
50
-        $errors = array();
51
-        $message = '';
50
+		$errors = array();
51
+		$message = '';
52 52
 
53
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
-            //$errors = $frm_settings->validate($_POST,array());
55
-            $frm_settings->update( stripslashes_deep( $_POST ) );
53
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
54
+			//$errors = $frm_settings->validate($_POST,array());
55
+			$frm_settings->update( stripslashes_deep( $_POST ) );
56 56
 
57
-            if ( empty( $errors ) ) {
58
-                $frm_settings->store();
59
-                $message = __( 'Settings Saved', 'formidable' );
60
-            }
61
-        } else {
62
-            $message = __( 'Settings Saved', 'formidable' );
63
-        }
57
+			if ( empty( $errors ) ) {
58
+				$frm_settings->store();
59
+				$message = __( 'Settings Saved', 'formidable' );
60
+			}
61
+		} else {
62
+			$message = __( 'Settings Saved', 'formidable' );
63
+		}
64 64
 
65 65
 		if ( $stop_load == 'stop_load' ) {
66
-            $frm_vars['settings_routed'] = true;
67
-            return;
68
-        }
66
+			$frm_vars['settings_routed'] = true;
67
+			return;
68
+		}
69 69
 
70
-        self::display_form( $errors, $message );
71
-    }
70
+		self::display_form( $errors, $message );
71
+	}
72 72
 
73
-    public static function route( $stop_load = false ) {
74
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
73
+	public static function route( $stop_load = false ) {
74
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
75 75
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
76
-        if ( $action == 'process-form' ) {
76
+		if ( $action == 'process-form' ) {
77 77
 			self::process_form( $stop_load );
78
-        } else if ( $stop_load != 'stop_load' ) {
78
+		} else if ( $stop_load != 'stop_load' ) {
79 79
 			self::display_form();
80
-        }
81
-    }
80
+		}
81
+	}
82 82
 }
Please login to merge, or discard this patch.
classes/views/styles/_field-description.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <div class="field-group field-group-background clearfix frm-first-row">
2 2
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
4 4
 </div>
5 5
 <div class="field-group clearfix frm-first-row">
6 6
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
7
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_weight') ) ?>" id="frm_description_weight">
7
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_weight">
8 8
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9 9
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10 10
 		<?php } ?>
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 </div>
13 13
 <div class="field-group clearfix frm-first-row">
14 14
 	<label><?php _e( 'Style', 'formidable' ) ?></label>
15
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style">
16
-		<option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
-		<option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option>
15
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style">
16
+		<option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
+		<option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option>
18 18
 	</select>
19 19
 </div>
20 20
 
21 21
 <div class="field-group clearfix">
22 22
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
23
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
23
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
24 24
 </div>
25 25
 <div class="field-group clearfix">
26 26
 	<label><?php _e( 'Align', 'formidable' ) ?></label>
27
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align">
28
-		<option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
29
-		<option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
27
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align">
28
+		<option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
29
+		<option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
30 30
 	</select>
31 31
 </div>
32 32
 <div class="field-group clearfix">
33 33
 	<label><?php _e( 'Margin', 'formidable' ) ?></label>
34
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
34
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
35 35
 </div>
36 36
 <div class="clear"></div>
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 3 patches
Indentation   +596 added lines, -596 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,128 +24,128 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+			return self::create($values);
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
63
-            $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
62
+			$values = FrmFormsHelper::setup_new_vars($values);
63
+			$id = FrmForm::create( $values );
64
+			$form = FrmForm::getOne($id);
65 65
 
66
-            // add default email notification
67
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
66
+			// add default email notification
67
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
68
+			$action_control->create($form->id);
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72
-            $values['id'] = $id;
72
+			$values['id'] = $id;
73 73
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
74
-        }
75
-    }
74
+		}
75
+	}
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+		FrmAppHelper::permission_check('frm_edit_forms');
79 79
 
80
-        global $frm_vars;
81
-        if ( empty( $values ) ) {
82
-            $values = $_POST;
83
-        }
80
+		global $frm_vars;
81
+		if ( empty( $values ) ) {
82
+			$values = $_POST;
83
+		}
84 84
 
85
-        //Set radio button and checkbox meta equal to "other" value
86
-        if ( FrmAppHelper::pro_is_installed() ) {
87
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
88
-        }
85
+		//Set radio button and checkbox meta equal to "other" value
86
+		if ( FrmAppHelper::pro_is_installed() ) {
87
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
88
+		}
89 89
 
90 90
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
-            $frm_settings = FrmAppHelper::get_settings();
94
-            $errors = array( 'form' => $frm_settings->admin_permission );
95
-        } else {
96
-            $errors = FrmForm::validate($values);
97
-        }
92
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
+			$frm_settings = FrmAppHelper::get_settings();
94
+			$errors = array( 'form' => $frm_settings->admin_permission );
95
+		} else {
96
+			$errors = FrmForm::validate($values);
97
+		}
98 98
 
99
-        if ( count($errors) > 0 ) {
100
-            $hide_preview = true;
99
+		if ( count($errors) > 0 ) {
100
+			$hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102
-            $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
102
+			$form = FrmForm::getOne( $id );
103
+			$fields = FrmField::get_all_for_form($id);
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108 108
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
109
-        } else {
110
-            FrmForm::update( $id, $values, true );
109
+		} else {
110
+			FrmForm::update( $id, $values, true );
111 111
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
112 112
 			die( FrmAppHelper::js_redirect( $url ) );
113
-        }
114
-    }
113
+		}
114
+	}
115 115
 
116
-    public static function edit( $values = false ) {
117
-        FrmAppHelper::permission_check('frm_edit_forms');
116
+	public static function edit( $values = false ) {
117
+		FrmAppHelper::permission_check('frm_edit_forms');
118 118
 
119 119
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
120
-        return self::get_edit_vars($id);
121
-    }
120
+		return self::get_edit_vars($id);
121
+	}
122 122
 
123
-    public static function settings( $id = false, $message = '' ) {
124
-        FrmAppHelper::permission_check('frm_edit_forms');
123
+	public static function settings( $id = false, $message = '' ) {
124
+		FrmAppHelper::permission_check('frm_edit_forms');
125 125
 
126
-        if ( ! $id || ! is_numeric($id) ) {
126
+		if ( ! $id || ! is_numeric($id) ) {
127 127
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
128
-        }
128
+		}
129 129
 		return self::get_settings_vars( $id, array(), $message );
130
-    }
130
+	}
131 131
 
132
-    public static function update_settings() {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+	public static function update_settings() {
133
+		FrmAppHelper::permission_check('frm_edit_forms');
134 134
 
135 135
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136 136
 
137
-        $errors = FrmForm::validate($_POST);
138
-        if ( count($errors) > 0 ) {
139
-            return self::get_settings_vars($id, $errors);
140
-        }
137
+		$errors = FrmForm::validate($_POST);
138
+		if ( count($errors) > 0 ) {
139
+			return self::get_settings_vars($id, $errors);
140
+		}
141 141
 
142
-        do_action('frm_before_update_form_settings', $id);
142
+		do_action('frm_before_update_form_settings', $id);
143 143
 
144 144
 		FrmForm::update( $id, $_POST );
145 145
 
146
-        $message = __( 'Settings Successfully Updated', 'formidable' );
146
+		$message = __( 'Settings Successfully Updated', 'formidable' );
147 147
 		return self::get_settings_vars( $id, array(), $message );
148
-    }
148
+	}
149 149
 
150 150
 	public static function edit_key() {
151 151
 		$values = self::edit_in_place_value( 'form_key' );
@@ -175,43 +175,43 @@  discard block
 block discarded – undo
175 175
 
176 176
 	public static function update( $values = array() ) {
177 177
 		if ( empty( $values ) ) {
178
-            $values = $_POST;
179
-        }
178
+			$values = $_POST;
179
+		}
180 180
 
181
-        //Set radio button and checkbox meta equal to "other" value
182
-        if ( FrmAppHelper::pro_is_installed() ) {
183
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
184
-        }
181
+		//Set radio button and checkbox meta equal to "other" value
182
+		if ( FrmAppHelper::pro_is_installed() ) {
183
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
184
+		}
185 185
 
186
-        $errors = FrmForm::validate( $values );
187
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
188
-        if ( $permission_error !== false ) {
189
-            $errors['form'] = $permission_error;
190
-        }
186
+		$errors = FrmForm::validate( $values );
187
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
188
+		if ( $permission_error !== false ) {
189
+			$errors['form'] = $permission_error;
190
+		}
191 191
 
192 192
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
193 193
 
194 194
 		if ( count( $errors ) > 0 ) {
195
-            return self::get_edit_vars( $id, $errors );
195
+			return self::get_edit_vars( $id, $errors );
196 196
 		} else {
197
-            FrmForm::update( $id, $values );
198
-            $message = __( 'Form was Successfully Updated', 'formidable' );
199
-            if ( defined( 'DOING_AJAX' ) ) {
197
+			FrmForm::update( $id, $values );
198
+			$message = __( 'Form was Successfully Updated', 'formidable' );
199
+			if ( defined( 'DOING_AJAX' ) ) {
200 200
 				wp_die( $message );
201
-            }
201
+			}
202 202
 			return self::get_edit_vars( $id, array(), $message );
203
-        }
204
-    }
203
+		}
204
+	}
205 205
 
206
-    public static function bulk_create_template( $ids ) {
207
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
206
+	public static function bulk_create_template( $ids ) {
207
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
208 208
 
209
-        foreach ( $ids as $id ) {
210
-            FrmForm::duplicate( $id, true, true );
211
-        }
209
+		foreach ( $ids as $id ) {
210
+			FrmForm::duplicate( $id, true, true );
211
+		}
212 212
 
213
-        return __( 'Form template was Successfully Created', 'formidable' );
214
-    }
213
+		return __( 'Form template was Successfully Created', 'formidable' );
214
+	}
215 215
 
216 216
 	/**
217 217
 	 * Redirect to the url for creating from a template
@@ -233,45 +233,45 @@  discard block
 block discarded – undo
233 233
 		wp_die();
234 234
 	}
235 235
 
236
-    public static function duplicate() {
237
-        FrmAppHelper::permission_check('frm_edit_forms');
236
+	public static function duplicate() {
237
+		FrmAppHelper::permission_check('frm_edit_forms');
238 238
 
239 239
 		$params = FrmForm::list_page_params();
240
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242
-        if ( $form ) {
240
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242
+		if ( $form ) {
243 243
 			return self::get_edit_vars( $form, array(), $message, true );
244
-        } else {
245
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
246
-        }
247
-    }
244
+		} else {
245
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
246
+		}
247
+	}
248 248
 
249
-    public static function page_preview() {
249
+	public static function page_preview() {
250 250
 		$params = FrmForm::list_page_params();
251
-        if ( ! $params['form'] ) {
252
-            return;
253
-        }
254
-
255
-        $form = FrmForm::getOne( $params['form'] );
256
-        if ( ! $form ) {
257
-            return;
258
-        }
259
-        return self::show_form( $form->id, '', true, true );
260
-    }
261
-
262
-    public static function preview() {
263
-        do_action( 'frm_wp' );
264
-
265
-        global $frm_vars;
266
-        $frm_vars['preview'] = true;
267
-
268
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
269
-            global $wp;
270
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
251
+		if ( ! $params['form'] ) {
252
+			return;
253
+		}
254
+
255
+		$form = FrmForm::getOne( $params['form'] );
256
+		if ( ! $form ) {
257
+			return;
258
+		}
259
+		return self::show_form( $form->id, '', true, true );
260
+	}
261
+
262
+	public static function preview() {
263
+		do_action( 'frm_wp' );
264
+
265
+		global $frm_vars;
266
+		$frm_vars['preview'] = true;
267
+
268
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
269
+			global $wp;
270
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
271 271
 			include_once( $root . '/wp-config.php' );
272
-            $wp->init();
273
-            $wp->register_globals();
274
-        }
272
+			$wp->init();
273
+			$wp->register_globals();
274
+		}
275 275
 
276 276
 		self::register_pro_scripts();
277 277
 
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
286 286
 		if ( empty( $form ) ) {
287 287
 			$form = FrmForm::getAll( array(), '', 1 );
288
-        }
288
+		}
289 289
 
290 290
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
291
-        wp_die();
292
-    }
291
+		wp_die();
292
+	}
293 293
 
294 294
 	public static function register_pro_scripts() {
295 295
 		if ( FrmAppHelper::pro_is_installed() ) {
@@ -300,22 +300,22 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 	}
302 302
 
303
-    public static function untrash() {
303
+	public static function untrash() {
304 304
 		self::change_form_status( 'untrash' );
305
-    }
305
+	}
306 306
 
307 307
 	public static function bulk_untrash( $ids ) {
308
-        FrmAppHelper::permission_check('frm_edit_forms');
308
+		FrmAppHelper::permission_check('frm_edit_forms');
309 309
 
310
-        $count = FrmForm::set_status( $ids, 'published' );
310
+		$count = FrmForm::set_status( $ids, 'published' );
311 311
 
312
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
313
-        return $message;
314
-    }
312
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
313
+		return $message;
314
+	}
315 315
 
316
-    public static function trash() {
316
+	public static function trash() {
317 317
 		self::change_form_status( 'trash' );
318
-    }
318
+	}
319 319
 
320 320
 	/**
321 321
 	 * @param string $status
@@ -353,68 +353,68 @@  discard block
 block discarded – undo
353 353
 	}
354 354
 
355 355
 	public static function bulk_trash( $ids ) {
356
-        FrmAppHelper::permission_check('frm_delete_forms');
356
+		FrmAppHelper::permission_check('frm_delete_forms');
357 357
 
358
-        $count = 0;
359
-        foreach ( $ids as $id ) {
360
-            if ( FrmForm::trash( $id ) ) {
361
-                $count++;
362
-            }
363
-        }
358
+		$count = 0;
359
+		foreach ( $ids as $id ) {
360
+			if ( FrmForm::trash( $id ) ) {
361
+				$count++;
362
+			}
363
+		}
364 364
 
365
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
365
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
366 366
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
367 367
 
368
-        return $message;
369
-    }
368
+		return $message;
369
+	}
370 370
 
371
-    public static function destroy() {
372
-        FrmAppHelper::permission_check('frm_delete_forms');
371
+	public static function destroy() {
372
+		FrmAppHelper::permission_check('frm_delete_forms');
373 373
 
374 374
 		$params = FrmForm::list_page_params();
375 375
 
376
-        //check nonce url
377
-        check_admin_referer('destroy_form_' . $params['id']);
376
+		//check nonce url
377
+		check_admin_referer('destroy_form_' . $params['id']);
378 378
 
379
-        $count = 0;
380
-        if ( FrmForm::destroy( $params['id'] ) ) {
381
-            $count++;
382
-        }
379
+		$count = 0;
380
+		if ( FrmForm::destroy( $params['id'] ) ) {
381
+			$count++;
382
+		}
383 383
 
384
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
384
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
385 385
 
386 386
 		self::display_forms_list( $params, $message );
387
-    }
387
+	}
388 388
 
389 389
 	public static function bulk_destroy( $ids ) {
390
-        FrmAppHelper::permission_check('frm_delete_forms');
390
+		FrmAppHelper::permission_check('frm_delete_forms');
391 391
 
392
-        $count = 0;
393
-        foreach ( $ids as $id ) {
394
-            $d = FrmForm::destroy( $id );
395
-            if ( $d ) {
396
-                $count++;
397
-            }
398
-        }
392
+		$count = 0;
393
+		foreach ( $ids as $id ) {
394
+			$d = FrmForm::destroy( $id );
395
+			if ( $d ) {
396
+				$count++;
397
+			}
398
+		}
399 399
 
400
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
400
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
401 401
 
402
-        return $message;
403
-    }
402
+		return $message;
403
+	}
404 404
 
405
-    private static function delete_all() {
406
-        //check nonce url
407
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
408
-        if ( $permission_error !== false ) {
405
+	private static function delete_all() {
406
+		//check nonce url
407
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
408
+		if ( $permission_error !== false ) {
409 409
 			self::display_forms_list( array(), '', array( $permission_error ) );
410
-            return;
411
-        }
410
+			return;
411
+		}
412 412
 
413 413
 		$count = FrmForm::scheduled_delete( time() );
414
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
414
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
415 415
 
416 416
 		self::display_forms_list( array(), $message );
417
-    }
417
+	}
418 418
 
419 419
 	public static function scheduled_delete( $delete_timestamp = '' ) {
420 420
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	}
423 423
 
424 424
 	/**
425
-	* Inserts Formidable button
426
-	* Hook exists since 2.5.0
427
-	*
428
-	* @since 2.0.15
429
-	*/
425
+	 * Inserts Formidable button
426
+	 * Hook exists since 2.5.0
427
+	 *
428
+	 * @since 2.0.15
429
+	 */
430 430
 	public static function insert_form_button() {
431 431
 		if ( current_user_can('frm_view_forms') ) {
432 432
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -437,49 +437,49 @@  discard block
 block discarded – undo
437 437
 		}
438 438
 	}
439 439
 
440
-    public static function insert_form_popup() {
440
+	public static function insert_form_popup() {
441 441
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
442 442
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
443
-            return;
444
-        }
443
+			return;
444
+		}
445 445
 
446
-        FrmAppHelper::load_admin_wide_js();
446
+		FrmAppHelper::load_admin_wide_js();
447 447
 
448
-        $shortcodes = array(
448
+		$shortcodes = array(
449 449
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
450
-        );
450
+		);
451 451
 
452
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
452
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
453 453
 
454 454
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
455
-    }
455
+	}
456 456
 
457
-    public static function get_shortcode_opts() {
457
+	public static function get_shortcode_opts() {
458 458
 		FrmAppHelper::permission_check('frm_view_forms');
459
-        check_ajax_referer( 'frm_ajax', 'nonce' );
459
+		check_ajax_referer( 'frm_ajax', 'nonce' );
460 460
 
461 461
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
462
-        if ( empty($shortcode) ) {
463
-            wp_die();
464
-        }
462
+		if ( empty($shortcode) ) {
463
+			wp_die();
464
+		}
465 465
 
466 466
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
467 467
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
468 468
 
469
-        $form_id = '';
470
-        $opts = array();
469
+		$form_id = '';
470
+		$opts = array();
471 471
 		switch ( $shortcode ) {
472
-            case 'formidable':
473
-                $opts = array(
472
+			case 'formidable':
473
+				$opts = array(
474 474
 					'form_id'       => 'id',
475
-                    //'key' => ',
475
+					//'key' => ',
476 476
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
477 477
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
478 478
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
479
-                );
480
-            break;
481
-        }
482
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
479
+				);
480
+			break;
481
+		}
482
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
483 483
 
484 484
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
485 485
 			// allow other shortcodes to use the required form id option
@@ -489,61 +489,61 @@  discard block
 block discarded – undo
489 489
 
490 490
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
491 491
 
492
-        echo '</div>';
492
+		echo '</div>';
493 493
 
494
-        wp_die();
495
-    }
494
+		wp_die();
495
+	}
496 496
 
497 497
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
498
-        FrmAppHelper::permission_check( 'frm_view_forms' );
498
+		FrmAppHelper::permission_check( 'frm_view_forms' );
499 499
 		if ( ! empty( $deprecated_errors ) ) {
500 500
 			$errors = $deprecated_errors;
501 501
 			_deprecated_argument( 'errors', '2.0.8' );
502 502
 		}
503 503
 
504
-        global $wpdb, $frm_vars;
504
+		global $wpdb, $frm_vars;
505 505
 
506 506
 		if ( empty( $params ) ) {
507 507
 			$params = FrmForm::list_page_params();
508
-        }
508
+		}
509 509
 
510
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
510
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
511 511
 
512
-        $pagenum = $wp_list_table->get_pagenum();
512
+		$pagenum = $wp_list_table->get_pagenum();
513 513
 
514
-        $wp_list_table->prepare_items();
514
+		$wp_list_table->prepare_items();
515 515
 
516
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
517
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
516
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
517
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
518 518
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
519
-            die();
520
-        }
519
+			die();
520
+		}
521 521
 
522 522
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
523
-    }
523
+	}
524 524
 
525 525
 	public static function get_columns( $columns ) {
526
-	    $columns['cb'] = '<input type="checkbox" />';
527
-	    $columns['id'] = 'ID';
526
+		$columns['cb'] = '<input type="checkbox" />';
527
+		$columns['id'] = 'ID';
528 528
 
529
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
529
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
530 530
 
531
-        if ( 'template' == $type ) {
532
-            $columns['name']        = __( 'Template Name', 'formidable' );
533
-            $columns['type']        = __( 'Type', 'formidable' );
534
-            $columns['form_key']    = __( 'Key', 'formidable' );
535
-        } else {
536
-            $columns['name']        = __( 'Form Title', 'formidable' );
537
-            $columns['entries']     = __( 'Entries', 'formidable' );
538
-            $columns['form_key']    = __( 'Key', 'formidable' );
539
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
540
-        }
531
+		if ( 'template' == $type ) {
532
+			$columns['name']        = __( 'Template Name', 'formidable' );
533
+			$columns['type']        = __( 'Type', 'formidable' );
534
+			$columns['form_key']    = __( 'Key', 'formidable' );
535
+		} else {
536
+			$columns['name']        = __( 'Form Title', 'formidable' );
537
+			$columns['entries']     = __( 'Entries', 'formidable' );
538
+			$columns['form_key']    = __( 'Key', 'formidable' );
539
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
540
+		}
541 541
 
542
-        $columns['created_at'] = __( 'Date', 'formidable' );
542
+		$columns['created_at'] = __( 'Date', 'formidable' );
543 543
 
544 544
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
545 545
 
546
-        return $columns;
546
+		return $columns;
547 547
 	}
548 548
 
549 549
 	public static function get_sortable_columns() {
@@ -557,111 +557,111 @@  discard block
 block discarded – undo
557 557
 	}
558 558
 
559 559
 	public static function hidden_columns( $result ) {
560
-        $return = false;
561
-        foreach ( (array) $result as $r ) {
562
-            if ( ! empty( $r ) ) {
563
-                $return = true;
564
-                break;
565
-            }
566
-        }
560
+		$return = false;
561
+		foreach ( (array) $result as $r ) {
562
+			if ( ! empty( $r ) ) {
563
+				$return = true;
564
+				break;
565
+			}
566
+		}
567 567
 
568
-        if ( $return ) {
569
-            return $result;
568
+		if ( $return ) {
569
+			return $result;
570 570
 		}
571 571
 
572
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
572
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
573 573
 
574
-        $result[] = 'created_at';
575
-        if ( $type == 'template' ) {
576
-            $result[] = 'id';
577
-            $result[] = 'form_key';
578
-        }
574
+		$result[] = 'created_at';
575
+		if ( $type == 'template' ) {
576
+			$result[] = 'id';
577
+			$result[] = 'form_key';
578
+		}
579 579
 
580
-        return $result;
581
-    }
580
+		return $result;
581
+	}
582 582
 
583 583
 	public static function save_per_page( $save, $option, $value ) {
584
-        if ( $option == 'formidable_page_formidable_per_page' ) {
585
-            $save = (int) $value;
586
-        }
587
-        return $save;
588
-    }
584
+		if ( $option == 'formidable_page_formidable_per_page' ) {
585
+			$save = (int) $value;
586
+		}
587
+		return $save;
588
+	}
589 589
 
590 590
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
591
-        global $frm_vars;
591
+		global $frm_vars;
592 592
 
593
-        $form = FrmForm::getOne( $id );
594
-        if ( ! $form ) {
595
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
596
-        }
593
+		$form = FrmForm::getOne( $id );
594
+		if ( ! $form ) {
595
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
596
+		}
597 597
 
598
-        if ( $form->parent_form_id ) {
598
+		if ( $form->parent_form_id ) {
599 599
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
600
-        }
600
+		}
601 601
 
602 602
 		$frm_field_selection = FrmField::field_selection();
603
-        $fields = FrmField::get_all_for_form($form->id);
603
+		$fields = FrmField::get_all_for_form($form->id);
604 604
 
605
-        // Automatically add end section fields if they don't exist (2.0 migration)
606
-        $reset_fields = false;
607
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
605
+		// Automatically add end section fields if they don't exist (2.0 migration)
606
+		$reset_fields = false;
607
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
608 608
 
609
-        if ( $reset_fields ) {
610
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
611
-        }
609
+		if ( $reset_fields ) {
610
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
611
+		}
612 612
 
613
-        unset($end_section_values, $last_order, $open, $reset_fields);
613
+		unset($end_section_values, $last_order, $open, $reset_fields);
614 614
 
615 615
 		$args = array( 'parent_form_id' => $form->id );
616
-        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
616
+		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
617 617
 
618
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
619
-        if ( $form->is_template && $message == $edit_message ) {
620
-            $message = __( 'Template was Successfully Updated', 'formidable' );
621
-        }
618
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
619
+		if ( $form->is_template && $message == $edit_message ) {
620
+			$message = __( 'Template was Successfully Updated', 'formidable' );
621
+		}
622 622
 
623 623
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
624 624
 
625
-        if ( $form->default_template ) {
626
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
627
-        } else if ( defined('DOING_AJAX') ) {
628
-            wp_die();
629
-        } else if ( $create_link ) {
625
+		if ( $form->default_template ) {
626
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
627
+		} else if ( defined('DOING_AJAX') ) {
628
+			wp_die();
629
+		} else if ( $create_link ) {
630 630
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
631
-        } else {
631
+		} else {
632 632
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
633
-        }
634
-    }
633
+		}
634
+	}
635 635
 
636 636
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
637 637
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
638 638
 
639
-        global $frm_vars;
639
+		global $frm_vars;
640 640
 
641
-        $form = FrmForm::getOne( $id );
641
+		$form = FrmForm::getOne( $id );
642 642
 
643
-        $fields = FrmField::get_all_for_form($id);
644
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
643
+		$fields = FrmField::get_all_for_form($id);
644
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
645 645
 
646
-        if ( isset($values['default_template']) && $values['default_template'] ) {
647
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
648
-        }
646
+		if ( isset($values['default_template']) && $values['default_template'] ) {
647
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
648
+		}
649 649
 
650
-        $action_controls = FrmFormActionsController::get_form_actions();
650
+		$action_controls = FrmFormActionsController::get_form_actions();
651 651
 
652
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
652
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
654 654
 
655
-        $styles = apply_filters('frm_get_style_opts', array());
655
+		$styles = apply_filters('frm_get_style_opts', array());
656 656
 
657 657
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
658
-    }
658
+	}
659 659
 
660
-    public static function mb_tags_box( $form_id, $class = '' ) {
661
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
662
-        $linked_forms = array();
663
-        $col = 'one';
664
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
660
+	public static function mb_tags_box( $form_id, $class = '' ) {
661
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
662
+		$linked_forms = array();
663
+		$col = 'one';
664
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
665 665
 
666 666
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
667 667
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
670 670
 
671 671
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
672
-    }
672
+	}
673 673
 
674 674
 	/**
675 675
 	 * Get an array of the options to display in the advanced tab
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 			''          => '',
711 711
 			'siteurl'   => __( 'Site URL', 'formidable' ),
712 712
 			'sitename'  => __( 'Site Name', 'formidable' ),
713
-        );
713
+		);
714 714
 
715 715
 		if ( ! FrmAppHelper::pro_is_installed() ) {
716 716
 			unset( $entry_shortcodes['post_id'] );
@@ -737,39 +737,39 @@  discard block
 block discarded – undo
737 737
 		return $entry_shortcodes;
738 738
 	}
739 739
 
740
-    // Insert the form class setting into the form
740
+	// Insert the form class setting into the form
741 741
 	public static function form_classes( $form ) {
742
-        if ( isset($form->options['form_class']) ) {
742
+		if ( isset($form->options['form_class']) ) {
743 743
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
744
-        }
745
-    }
744
+		}
745
+	}
746 746
 
747
-    public static function get_email_html() {
747
+	public static function get_email_html() {
748 748
 		FrmAppHelper::permission_check('frm_view_forms');
749
-        check_ajax_referer( 'frm_ajax', 'nonce' );
749
+		check_ajax_referer( 'frm_ajax', 'nonce' );
750 750
 		echo FrmEntryFormat::show_entry( array(
751 751
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
752
-	        'default_email' => true,
752
+			'default_email' => true,
753 753
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
754
-	    ) );
755
-	    wp_die();
754
+		) );
755
+		wp_die();
756 756
 	}
757 757
 
758
-    public static function filter_content( $content, $form, $entry = false ) {
758
+	public static function filter_content( $content, $form, $entry = false ) {
759 759
 		self::get_entry_by_param( $entry );
760
-        if ( ! $entry ) {
761
-            return $content;
762
-        }
760
+		if ( ! $entry ) {
761
+			return $content;
762
+		}
763 763
 
764
-        if ( is_object( $form ) ) {
765
-            $form = $form->id;
766
-        }
764
+		if ( is_object( $form ) ) {
765
+			$form = $form->id;
766
+		}
767 767
 
768
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
769
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
768
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
769
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
770 770
 
771
-        return $content;
772
-    }
771
+		return $content;
772
+	}
773 773
 
774 774
 	private static function get_entry_by_param( &$entry ) {
775 775
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -781,287 +781,287 @@  discard block
 block discarded – undo
781 781
 		}
782 782
 	}
783 783
 
784
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
785
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
786
-    }
784
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
785
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
786
+	}
787 787
 
788
-    public static function process_bulk_form_actions( $errors ) {
789
-        if ( ! $_REQUEST ) {
790
-            return $errors;
791
-        }
788
+	public static function process_bulk_form_actions( $errors ) {
789
+		if ( ! $_REQUEST ) {
790
+			return $errors;
791
+		}
792 792
 
793 793
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
794
-        if ( $bulkaction == -1 ) {
794
+		if ( $bulkaction == -1 ) {
795 795
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
796
-        }
797
-
798
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
799
-            FrmAppHelper::remove_get_action();
800
-
801
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
802
-        }
803
-
804
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
805
-        if ( empty( $ids ) ) {
806
-            $errors[] = __( 'No forms were specified', 'formidable' );
807
-            return $errors;
808
-        }
809
-
810
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
811
-        if ( $permission_error !== false ) {
812
-            $errors[] = $permission_error;
813
-            return $errors;
814
-        }
815
-
816
-        if ( ! is_array( $ids ) ) {
817
-            $ids = explode( ',', $ids );
818
-        }
819
-
820
-        switch ( $bulkaction ) {
821
-            case 'delete':
822
-                $message = self::bulk_destroy( $ids );
823
-            break;
824
-            case 'trash':
825
-                $message = self::bulk_trash( $ids );
826
-            break;
827
-            case 'untrash':
828
-                $message = self::bulk_untrash( $ids );
829
-            break;
830
-            case 'create_template':
831
-                $message = self::bulk_create_template( $ids );
832
-            break;
833
-        }
834
-
835
-        if ( isset( $message ) && ! empty( $message ) ) {
796
+		}
797
+
798
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
799
+			FrmAppHelper::remove_get_action();
800
+
801
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
802
+		}
803
+
804
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
805
+		if ( empty( $ids ) ) {
806
+			$errors[] = __( 'No forms were specified', 'formidable' );
807
+			return $errors;
808
+		}
809
+
810
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
811
+		if ( $permission_error !== false ) {
812
+			$errors[] = $permission_error;
813
+			return $errors;
814
+		}
815
+
816
+		if ( ! is_array( $ids ) ) {
817
+			$ids = explode( ',', $ids );
818
+		}
819
+
820
+		switch ( $bulkaction ) {
821
+			case 'delete':
822
+				$message = self::bulk_destroy( $ids );
823
+			break;
824
+			case 'trash':
825
+				$message = self::bulk_trash( $ids );
826
+			break;
827
+			case 'untrash':
828
+				$message = self::bulk_untrash( $ids );
829
+			break;
830
+			case 'create_template':
831
+				$message = self::bulk_create_template( $ids );
832
+			break;
833
+		}
834
+
835
+		if ( isset( $message ) && ! empty( $message ) ) {
836 836
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>';
837
-        }
837
+		}
838 838
 
839
-        return $errors;
840
-    }
839
+		return $errors;
840
+	}
841 841
 
842
-    public static function add_default_templates( $path, $default = true, $template = true ) {
843
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
842
+	public static function add_default_templates( $path, $default = true, $template = true ) {
843
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
844 844
 
845
-        $path = untrailingslashit(trim($path));
845
+		$path = untrailingslashit(trim($path));
846 846
 		$templates = glob( $path . '/*.php' );
847 847
 
848 848
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
849 849
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
850 850
 			$template_query = array( 'form_key' => $filename );
851
-            if ( $template ) {
852
-                $template_query['is_template'] = 1;
853
-            }
854
-            if ( $default ) {
855
-                $template_query['default_template'] = 1;
856
-            }
851
+			if ( $template ) {
852
+				$template_query['is_template'] = 1;
853
+			}
854
+			if ( $default ) {
855
+				$template_query['default_template'] = 1;
856
+			}
857 857
 			$form = FrmForm::getAll( $template_query, '', 1 );
858 858
 
859
-            $values = FrmFormsHelper::setup_new_vars();
860
-            $values['form_key'] = $filename;
861
-            $values['is_template'] = $template;
862
-            $values['status'] = 'published';
863
-            if ( $default ) {
864
-                $values['default_template'] = 1;
865
-            }
866
-
867
-            include( $templates[ $i ] );
868
-
869
-            //get updated form
870
-            if ( isset($form) && ! empty($form) ) {
871
-                $old_id = $form->id;
872
-                $form = FrmForm::getOne($form->id);
873
-            } else {
874
-                $old_id = false;
859
+			$values = FrmFormsHelper::setup_new_vars();
860
+			$values['form_key'] = $filename;
861
+			$values['is_template'] = $template;
862
+			$values['status'] = 'published';
863
+			if ( $default ) {
864
+				$values['default_template'] = 1;
865
+			}
866
+
867
+			include( $templates[ $i ] );
868
+
869
+			//get updated form
870
+			if ( isset($form) && ! empty($form) ) {
871
+				$old_id = $form->id;
872
+				$form = FrmForm::getOne($form->id);
873
+			} else {
874
+				$old_id = false;
875 875
 				$form = FrmForm::getAll( $template_query, '', 1 );
876
-            }
876
+			}
877 877
 
878
-            if ( $form ) {
878
+			if ( $form ) {
879 879
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
880
-            }
881
-        }
882
-    }
880
+			}
881
+		}
882
+	}
883 883
 
884
-    public static function route() {
885
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
886
-        $vars = array();
884
+	public static function route() {
885
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
886
+		$vars = array();
887 887
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
888 888
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
889 889
 
890
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
891
-            $json_vars = json_decode($json_vars, true);
892
-            if ( empty($json_vars) ) {
893
-                // json decoding failed so we should return an error message
890
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
891
+			$json_vars = json_decode($json_vars, true);
892
+			if ( empty($json_vars) ) {
893
+				// json decoding failed so we should return an error message
894 894
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
895
-                if ( 'edit' == $action ) {
896
-                    $action = 'update';
897
-                }
898
-
899
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
900
-            } else {
901
-                $vars = FrmAppHelper::json_to_array($json_vars);
902
-                $action = $vars[ $action ];
895
+				if ( 'edit' == $action ) {
896
+					$action = 'update';
897
+				}
898
+
899
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
900
+			} else {
901
+				$vars = FrmAppHelper::json_to_array($json_vars);
902
+				$action = $vars[ $action ];
903 903
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
904 904
 				$_REQUEST = array_merge( $_REQUEST, $vars );
905 905
 				$_POST = array_merge( $_POST, $_REQUEST );
906
-            }
907
-        } else {
906
+			}
907
+		} else {
908 908
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
909
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
910
-                // override the action for this page
911
-    			$action = 'delete_all';
912
-            }
913
-        }
909
+			if ( isset( $_REQUEST['delete_all'] ) ) {
910
+				// override the action for this page
911
+				$action = 'delete_all';
912
+			}
913
+		}
914 914
 
915 915
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
916
-        FrmAppHelper::trigger_hook_load( 'form' );
917
-
918
-        switch ( $action ) {
919
-            case 'new':
920
-                return self::new_form($vars);
921
-            case 'create':
922
-            case 'edit':
923
-            case 'update':
924
-            case 'duplicate':
925
-            case 'trash':
926
-            case 'untrash':
927
-            case 'destroy':
928
-            case 'delete_all':
929
-            case 'settings':
930
-            case 'update_settings':
916
+		FrmAppHelper::trigger_hook_load( 'form' );
917
+
918
+		switch ( $action ) {
919
+			case 'new':
920
+				return self::new_form($vars);
921
+			case 'create':
922
+			case 'edit':
923
+			case 'update':
924
+			case 'duplicate':
925
+			case 'trash':
926
+			case 'untrash':
927
+			case 'destroy':
928
+			case 'delete_all':
929
+			case 'settings':
930
+			case 'update_settings':
931 931
 				return self::$action( $vars );
932
-            default:
932
+			default:
933 933
 				do_action( 'frm_form_action_' . $action );
934 934
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
935
-                    return;
936
-                }
935
+					return;
936
+				}
937 937
 
938 938
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
939
-                if ( $action == -1 ) {
939
+				if ( $action == -1 ) {
940 940
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
941
-                }
941
+				}
942 942
 
943
-                if ( strpos($action, 'bulk_') === 0 ) {
944
-                    FrmAppHelper::remove_get_action();
945
-                    return self::list_form();
946
-                }
943
+				if ( strpos($action, 'bulk_') === 0 ) {
944
+					FrmAppHelper::remove_get_action();
945
+					return self::list_form();
946
+				}
947 947
 
948
-                return self::display_forms_list();
949
-        }
950
-    }
948
+				return self::display_forms_list();
949
+		}
950
+	}
951 951
 
952
-    public static function json_error( $errors ) {
953
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
954
-        return $errors;
955
-    }
952
+	public static function json_error( $errors ) {
953
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
954
+		return $errors;
955
+	}
956 956
 
957 957
 
958
-    /* FRONT-END FORMS */
959
-    public static function admin_bar_css() {
958
+	/* FRONT-END FORMS */
959
+	public static function admin_bar_css() {
960 960
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
961
-            return;
962
-        }
961
+			return;
962
+		}
963 963
 
964 964
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
965 965
 		FrmAppHelper::load_font_style();
966 966
 	}
967 967
 
968 968
 	public static function admin_bar_configure() {
969
-        global $frm_vars;
970
-        if ( empty($frm_vars['forms_loaded']) ) {
971
-            return;
972
-        }
973
-
974
-        $actions = array();
975
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
976
-            if ( is_object($form) ) {
977
-                $actions[ $form->id ] = $form->name;
978
-            }
979
-            unset($form);
980
-        }
981
-
982
-        if ( empty($actions) ) {
983
-            return;
984
-        }
985
-
986
-        asort($actions);
987
-
988
-        global $wp_admin_bar;
989
-
990
-        if ( count($actions) == 1 ) {
991
-            $wp_admin_bar->add_menu( array(
992
-                'title' => 'Edit Form',
969
+		global $frm_vars;
970
+		if ( empty($frm_vars['forms_loaded']) ) {
971
+			return;
972
+		}
973
+
974
+		$actions = array();
975
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
976
+			if ( is_object($form) ) {
977
+				$actions[ $form->id ] = $form->name;
978
+			}
979
+			unset($form);
980
+		}
981
+
982
+		if ( empty($actions) ) {
983
+			return;
984
+		}
985
+
986
+		asort($actions);
987
+
988
+		global $wp_admin_bar;
989
+
990
+		if ( count($actions) == 1 ) {
991
+			$wp_admin_bar->add_menu( array(
992
+				'title' => 'Edit Form',
993 993
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
994
-                'id'    => 'frm-forms',
995
-            ) );
996
-        } else {
997
-            $wp_admin_bar->add_menu( array(
998
-        		'id'    => 'frm-forms',
999
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
994
+				'id'    => 'frm-forms',
995
+			) );
996
+		} else {
997
+			$wp_admin_bar->add_menu( array(
998
+				'id'    => 'frm-forms',
999
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
1000 1000
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
1001
-        		'meta'  => array(
1001
+				'meta'  => array(
1002 1002
 					'title' => __( 'Edit Forms', 'formidable' ),
1003
-        		),
1004
-        	) );
1003
+				),
1004
+			) );
1005 1005
 
1006
-        	foreach ( $actions as $form_id => $name ) {
1006
+			foreach ( $actions as $form_id => $name ) {
1007 1007
 
1008
-        		$wp_admin_bar->add_menu( array(
1009
-        			'parent'    => 'frm-forms',
1008
+				$wp_admin_bar->add_menu( array(
1009
+					'parent'    => 'frm-forms',
1010 1010
 					'id'        => 'edit_form_' . $form_id,
1011
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1011
+					'title'     => empty($name) ? __( '(no title)') : $name,
1012 1012
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1013
-        		) );
1014
-        	}
1015
-        }
1016
-    }
1013
+				) );
1014
+			}
1015
+		}
1016
+	}
1017 1017
 
1018
-    //formidable shortcode
1018
+	//formidable shortcode
1019 1019
 	public static function get_form_shortcode( $atts ) {
1020
-        global $frm_vars;
1021
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1022
-            $sc = '[formidable';
1020
+		global $frm_vars;
1021
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1022
+			$sc = '[formidable';
1023 1023
 			if ( ! empty( $atts ) ) {
1024 1024
 				foreach ( $atts as $k => $v ) {
1025 1025
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1026 1026
 				}
1027 1027
 			}
1028 1028
 			return $sc . ']';
1029
-        }
1030
-
1031
-        $shortcode_atts = shortcode_atts( array(
1032
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1033
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1034
-            'exclude_fields' => array(), 'minimize' => false,
1035
-        ), $atts);
1036
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1037
-
1038
-        return self::show_form(
1039
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1040
-            $shortcode_atts['description'], $atts
1041
-        );
1042
-    }
1043
-
1044
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1045
-        if ( empty( $id ) ) {
1046
-            $id = $key;
1047
-        }
1048
-
1049
-        // no form id or key set
1050
-        if ( empty( $id ) ) {
1051
-            return __( 'Please select a valid form', 'formidable' );
1052
-        }
1053
-
1054
-        $form = FrmForm::getOne( $id );
1055
-        if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) {
1056
-            return __( 'Please select a valid form', 'formidable' );
1057
-        }
1029
+		}
1030
+
1031
+		$shortcode_atts = shortcode_atts( array(
1032
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1033
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1034
+			'exclude_fields' => array(), 'minimize' => false,
1035
+		), $atts);
1036
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1037
+
1038
+		return self::show_form(
1039
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1040
+			$shortcode_atts['description'], $atts
1041
+		);
1042
+	}
1043
+
1044
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1045
+		if ( empty( $id ) ) {
1046
+			$id = $key;
1047
+		}
1048
+
1049
+		// no form id or key set
1050
+		if ( empty( $id ) ) {
1051
+			return __( 'Please select a valid form', 'formidable' );
1052
+		}
1053
+
1054
+		$form = FrmForm::getOne( $id );
1055
+		if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) {
1056
+			return __( 'Please select a valid form', 'formidable' );
1057
+		}
1058 1058
 
1059 1059
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1060
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1060
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1061 1061
 
1062
-        $form = apply_filters( 'frm_pre_display_form', $form );
1062
+		$form = apply_filters( 'frm_pre_display_form', $form );
1063 1063
 
1064
-        $frm_settings = FrmAppHelper::get_settings();
1064
+		$frm_settings = FrmAppHelper::get_settings();
1065 1065
 
1066 1066
 		if ( self::is_viewable_draft_form( $form ) ) {
1067 1067
 			// don't show a draft form on a page
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 		}
1083 1083
 
1084 1084
 		return $form;
1085
-    }
1085
+	}
1086 1086
 
1087 1087
 	private static function is_viewable_draft_form( $form ) {
1088 1088
 		global $post;
@@ -1098,98 +1098,98 @@  discard block
 block discarded – undo
1098 1098
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1099 1099
 	}
1100 1100
 
1101
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1102
-        ob_start();
1101
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1102
+		ob_start();
1103 1103
 
1104
-        self::get_form_contents( $form, $title, $description, $atts );
1104
+		self::get_form_contents( $form, $title, $description, $atts );
1105 1105
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1106 1106
 
1107
-        $contents = ob_get_contents();
1108
-        ob_end_clean();
1107
+		$contents = ob_get_contents();
1108
+		ob_end_clean();
1109 1109
 
1110 1110
 		self::maybe_minimize_form( $atts, $contents );
1111 1111
 
1112
-        return $contents;
1113
-    }
1112
+		return $contents;
1113
+	}
1114 1114
 
1115 1115
 	public static function enqueue_scripts( $params ) {
1116 1116
 		do_action( 'frm_enqueue_form_scripts', $params );
1117 1117
 	}
1118 1118
 
1119 1119
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1120
-        global $frm_vars;
1120
+		global $frm_vars;
1121 1121
 
1122
-        $frm_settings = FrmAppHelper::get_settings();
1122
+		$frm_settings = FrmAppHelper::get_settings();
1123 1123
 
1124
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1124
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1125 1125
 
1126
-        $user_ID = get_current_user_id();
1126
+		$user_ID = get_current_user_id();
1127 1127
 		$params = FrmForm::get_params( $form );
1128
-        $message = $errors = '';
1128
+		$message = $errors = '';
1129 1129
 
1130
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1131
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1132
-        }
1130
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1131
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1132
+		}
1133 1133
 
1134 1134
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1135
-        $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1135
+		$fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1136 1136
 
1137
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1138
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1139
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1140
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1137
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1138
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1139
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1140
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1141 1141
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1142
-            }
1143
-            return;
1144
-        }
1142
+			}
1143
+			return;
1144
+		}
1145 1145
 
1146
-        if ( ! empty($errors) ) {
1147
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1146
+		if ( ! empty($errors) ) {
1147
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1148 1148
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1149
-            return;
1150
-        }
1149
+			return;
1150
+		}
1151 1151
 
1152
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1153
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1154
-            return;
1155
-        }
1152
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1153
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1154
+			return;
1155
+		}
1156 1156
 
1157
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1158
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1159
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1158
+		$created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1159
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1160 1160
 
1161
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1162
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1161
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1162
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1163 1163
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1164
-            return;
1165
-        }
1164
+			return;
1165
+		}
1166 1166
 
1167
-        if ( $created && is_numeric($created) ) {
1168
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1169
-            $class = 'frm_message';
1170
-        } else {
1171
-            $message = $frm_settings->failed_msg;
1172
-            $class = 'frm_error_style';
1173
-        }
1167
+		if ( $created && is_numeric($created) ) {
1168
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1169
+			$class = 'frm_message';
1170
+		} else {
1171
+			$message = $frm_settings->failed_msg;
1172
+			$class = 'frm_error_style';
1173
+		}
1174 1174
 
1175 1175
 		$message = FrmFormsHelper::get_success_message( array(
1176 1176
 			'message' => $message, 'form' => $form,
1177 1177
 			'entry_id' => $created, 'class' => $class,
1178 1178
 		) );
1179
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1179
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1180 1180
 
1181
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1181
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1182 1182
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1183
-        } else {
1184
-            global $frm_vars;
1183
+		} else {
1184
+			global $frm_vars;
1185 1185
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1186 1186
 
1187 1187
 			$include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1188 1188
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1189
-        }
1189
+		}
1190 1190
 
1191 1191
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1192
-    }
1192
+	}
1193 1193
 
1194 1194
 	public static function front_head() {
1195 1195
 		$version = FrmAppHelper::plugin_version();
@@ -1218,10 +1218,10 @@  discard block
 block discarded – undo
1218 1218
 	}
1219 1219
 
1220 1220
 	public static function defer_script_loading( $tag, $handle ) {
1221
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1222
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1221
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1222
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1223 1223
 		}
1224
-	    return $tag;
1224
+		return $tag;
1225 1225
 	}
1226 1226
 
1227 1227
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,39 +33,39 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+            return self::create( $values );
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
62
+            $values = FrmFormsHelper::setup_new_vars( $values );
63 63
             $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
64
+            $form = FrmForm::getOne( $id );
65 65
 
66 66
             // add default email notification
67 67
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
68
+            $action_control->create( $form->id );
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     }
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
79 79
 
80 80
         global $frm_vars;
81 81
         if ( empty( $values ) ) {
@@ -87,22 +87,22 @@  discard block
 block discarded – undo
87 87
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
88 88
         }
89 89
 
90
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
90
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92 92
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93 93
             $frm_settings = FrmAppHelper::get_settings();
94 94
             $errors = array( 'form' => $frm_settings->admin_permission );
95 95
         } else {
96
-            $errors = FrmForm::validate($values);
96
+            $errors = FrmForm::validate( $values );
97 97
         }
98 98
 
99
-        if ( count($errors) > 0 ) {
99
+        if ( count( $errors ) > 0 ) {
100 100
             $hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102 102
             $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
103
+            $fields = FrmField::get_all_for_form( $id );
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108 108
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -114,32 +114,32 @@  discard block
 block discarded – undo
114 114
     }
115 115
 
116 116
     public static function edit( $values = false ) {
117
-        FrmAppHelper::permission_check('frm_edit_forms');
117
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
118 118
 
119 119
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
120
-        return self::get_edit_vars($id);
120
+        return self::get_edit_vars( $id );
121 121
     }
122 122
 
123 123
     public static function settings( $id = false, $message = '' ) {
124
-        FrmAppHelper::permission_check('frm_edit_forms');
124
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
125 125
 
126
-        if ( ! $id || ! is_numeric($id) ) {
126
+        if ( ! $id || ! is_numeric( $id ) ) {
127 127
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
128 128
         }
129 129
 		return self::get_settings_vars( $id, array(), $message );
130 130
     }
131 131
 
132 132
     public static function update_settings() {
133
-        FrmAppHelper::permission_check('frm_edit_forms');
133
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
134 134
 
135 135
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
136 136
 
137
-        $errors = FrmForm::validate($_POST);
138
-        if ( count($errors) > 0 ) {
139
-            return self::get_settings_vars($id, $errors);
137
+        $errors = FrmForm::validate( $_POST );
138
+        if ( count( $errors ) > 0 ) {
139
+            return self::get_settings_vars( $id, $errors );
140 140
         }
141 141
 
142
-        do_action('frm_before_update_form_settings', $id);
142
+        do_action( 'frm_before_update_form_settings', $id );
143 143
 
144 144
 		FrmForm::update( $id, $_POST );
145 145
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 	private static function edit_in_place_value( $field ) {
163 163
 		check_ajax_referer( 'frm_ajax', 'nonce' );
164
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
164
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
165 165
 
166 166
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
167 167
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @since 2.0
220 220
 	 */
221 221
 	public static function _create_from_template() {
222
-		FrmAppHelper::permission_check('frm_edit_forms');
222
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 		check_ajax_referer( 'frm_ajax', 'nonce' );
224 224
 
225 225
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
     public static function duplicate() {
237
-        FrmAppHelper::permission_check('frm_edit_forms');
237
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
238 238
 
239 239
 		$params = FrmForm::list_page_params();
240 240
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
241
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
242 242
         if ( $form ) {
243 243
 			return self::get_edit_vars( $form, array(), $message, true );
244 244
         } else {
245
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
246 246
         }
247 247
     }
248 248
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
 	public static function bulk_untrash( $ids ) {
308
-        FrmAppHelper::permission_check('frm_edit_forms');
308
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
309 309
 
310 310
         $count = FrmForm::set_status( $ids, 'published' );
311 311
 
312
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
312
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
313 313
         return $message;
314 314
     }
315 315
 
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
329 329
 		);
330 330
 
331
-		if ( ! isset( $available_status[ $status ] ) ) {
331
+		if ( ! isset( $available_status[$status] ) ) {
332 332
 			return;
333 333
 		}
334 334
 
335
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
335
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
336 336
 
337 337
 		$params = FrmForm::list_page_params();
338 338
 
@@ -340,25 +340,25 @@  discard block
 block discarded – undo
340 340
 		check_admin_referer( $status . '_form_' . $params['id'] );
341 341
 
342 342
 		$count = 0;
343
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
344
-			$count++;
343
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
344
+			$count ++;
345 345
 		}
346 346
 
347
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
347
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
348 348
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
349 349
 
350
-		$message = $available_status[ $status ]['message'];
350
+		$message = $available_status[$status]['message'];
351 351
 
352 352
 		self::display_forms_list( $params, $message );
353 353
 	}
354 354
 
355 355
 	public static function bulk_trash( $ids ) {
356
-        FrmAppHelper::permission_check('frm_delete_forms');
356
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
357 357
 
358 358
         $count = 0;
359 359
         foreach ( $ids as $id ) {
360 360
             if ( FrmForm::trash( $id ) ) {
361
-                $count++;
361
+                $count ++;
362 362
             }
363 363
         }
364 364
 
@@ -369,49 +369,49 @@  discard block
 block discarded – undo
369 369
     }
370 370
 
371 371
     public static function destroy() {
372
-        FrmAppHelper::permission_check('frm_delete_forms');
372
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
373 373
 
374 374
 		$params = FrmForm::list_page_params();
375 375
 
376 376
         //check nonce url
377
-        check_admin_referer('destroy_form_' . $params['id']);
377
+        check_admin_referer( 'destroy_form_' . $params['id'] );
378 378
 
379 379
         $count = 0;
380 380
         if ( FrmForm::destroy( $params['id'] ) ) {
381
-            $count++;
381
+            $count ++;
382 382
         }
383 383
 
384
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
384
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
385 385
 
386 386
 		self::display_forms_list( $params, $message );
387 387
     }
388 388
 
389 389
 	public static function bulk_destroy( $ids ) {
390
-        FrmAppHelper::permission_check('frm_delete_forms');
390
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
391 391
 
392 392
         $count = 0;
393 393
         foreach ( $ids as $id ) {
394 394
             $d = FrmForm::destroy( $id );
395 395
             if ( $d ) {
396
-                $count++;
396
+                $count ++;
397 397
             }
398 398
         }
399 399
 
400
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
400
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
401 401
 
402 402
         return $message;
403 403
     }
404 404
 
405 405
     private static function delete_all() {
406 406
         //check nonce url
407
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
407
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
408 408
         if ( $permission_error !== false ) {
409 409
 			self::display_forms_list( array(), '', array( $permission_error ) );
410 410
             return;
411 411
         }
412 412
 
413 413
 		$count = FrmForm::scheduled_delete( time() );
414
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
414
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
415 415
 
416 416
 		self::display_forms_list( array(), $message );
417 417
     }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	* @since 2.0.15
429 429
 	*/
430 430
 	public static function insert_form_button() {
431
-		if ( current_user_can('frm_view_forms') ) {
431
+		if ( current_user_can( 'frm_view_forms' ) ) {
432 432
 			$menu_name = FrmAppHelper::get_menu_name();
433 433
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
434 434
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
450 450
         );
451 451
 
452
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
452
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
453 453
 
454 454
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
455 455
     }
456 456
 
457 457
     public static function get_shortcode_opts() {
458
-		FrmAppHelper::permission_check('frm_view_forms');
458
+		FrmAppHelper::permission_check( 'frm_view_forms' );
459 459
         check_ajax_referer( 'frm_ajax', 'nonce' );
460 460
 
461 461
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
462
-        if ( empty($shortcode) ) {
462
+        if ( empty( $shortcode ) ) {
463 463
             wp_die();
464 464
         }
465 465
 
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
                 );
480 480
             break;
481 481
         }
482
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
482
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
483 483
 
484 484
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
485 485
 			// allow other shortcodes to use the required form id option
@@ -596,11 +596,11 @@  discard block
 block discarded – undo
596 596
         }
597 597
 
598 598
         if ( $form->parent_form_id ) {
599
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
599
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
600 600
         }
601 601
 
602 602
 		$frm_field_selection = FrmField::field_selection();
603
-        $fields = FrmField::get_all_for_form($form->id);
603
+        $fields = FrmField::get_all_for_form( $form->id );
604 604
 
605 605
         // Automatically add end section fields if they don't exist (2.0 migration)
606 606
         $reset_fields = false;
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
611 611
         }
612 612
 
613
-        unset($end_section_values, $last_order, $open, $reset_fields);
613
+        unset( $end_section_values, $last_order, $open, $reset_fields );
614 614
 
615 615
 		$args = array( 'parent_form_id' => $form->id );
616 616
         $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
624 624
 
625 625
         if ( $form->default_template ) {
626
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
627
-        } else if ( defined('DOING_AJAX') ) {
626
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
627
+        } else if ( defined( 'DOING_AJAX' ) ) {
628 628
             wp_die();
629 629
         } else if ( $create_link ) {
630 630
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -640,28 +640,28 @@  discard block
 block discarded – undo
640 640
 
641 641
         $form = FrmForm::getOne( $id );
642 642
 
643
-        $fields = FrmField::get_all_for_form($id);
644
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
643
+        $fields = FrmField::get_all_for_form( $id );
644
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
645 645
 
646
-        if ( isset($values['default_template']) && $values['default_template'] ) {
647
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
646
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
647
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
648 648
         }
649 649
 
650 650
         $action_controls = FrmFormActionsController::get_form_actions();
651 651
 
652
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
652
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
653 653
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
654 654
 
655
-        $styles = apply_filters('frm_get_style_opts', array());
655
+        $styles = apply_filters( 'frm_get_style_opts', array() );
656 656
 
657 657
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
658 658
     }
659 659
 
660 660
     public static function mb_tags_box( $form_id, $class = '' ) {
661
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
661
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
662 662
         $linked_forms = array();
663 663
         $col = 'one';
664
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
664
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
665 665
 
666 666
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
667 667
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 
740 740
     // Insert the form class setting into the form
741 741
 	public static function form_classes( $form ) {
742
-        if ( isset($form->options['form_class']) ) {
742
+        if ( isset( $form->options['form_class'] ) ) {
743 743
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
744 744
         }
745 745
     }
746 746
 
747 747
     public static function get_email_html() {
748
-		FrmAppHelper::permission_check('frm_view_forms');
748
+		FrmAppHelper::permission_check( 'frm_view_forms' );
749 749
         check_ajax_referer( 'frm_ajax', 'nonce' );
750 750
 		echo FrmEntryFormat::show_entry( array(
751 751
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -842,11 +842,11 @@  discard block
 block discarded – undo
842 842
     public static function add_default_templates( $path, $default = true, $template = true ) {
843 843
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
844 844
 
845
-        $path = untrailingslashit(trim($path));
845
+        $path = untrailingslashit( trim( $path ) );
846 846
 		$templates = glob( $path . '/*.php' );
847 847
 
848
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
849
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
848
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
849
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
850 850
 			$template_query = array( 'form_key' => $filename );
851 851
             if ( $template ) {
852 852
                 $template_query['is_template'] = 1;
@@ -864,12 +864,12 @@  discard block
 block discarded – undo
864 864
                 $values['default_template'] = 1;
865 865
             }
866 866
 
867
-            include( $templates[ $i ] );
867
+            include( $templates[$i] );
868 868
 
869 869
             //get updated form
870
-            if ( isset($form) && ! empty($form) ) {
870
+            if ( isset( $form ) && ! empty( $form ) ) {
871 871
                 $old_id = $form->id;
872
-                $form = FrmForm::getOne($form->id);
872
+                $form = FrmForm::getOne( $form->id );
873 873
             } else {
874 874
                 $old_id = false;
875 875
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -882,24 +882,24 @@  discard block
 block discarded – undo
882 882
     }
883 883
 
884 884
     public static function route() {
885
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
885
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
886 886
         $vars = array();
887 887
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
888 888
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
889 889
 
890
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
891
-            $json_vars = json_decode($json_vars, true);
892
-            if ( empty($json_vars) ) {
890
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
891
+            $json_vars = json_decode( $json_vars, true );
892
+            if ( empty( $json_vars ) ) {
893 893
                 // json decoding failed so we should return an error message
894 894
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
895 895
                 if ( 'edit' == $action ) {
896 896
                     $action = 'update';
897 897
                 }
898 898
 
899
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
899
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
900 900
             } else {
901
-                $vars = FrmAppHelper::json_to_array($json_vars);
902
-                $action = $vars[ $action ];
901
+                $vars = FrmAppHelper::json_to_array( $json_vars );
902
+                $action = $vars[$action];
903 903
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
904 904
 				$_REQUEST = array_merge( $_REQUEST, $vars );
905 905
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 
918 918
         switch ( $action ) {
919 919
             case 'new':
920
-                return self::new_form($vars);
920
+                return self::new_form( $vars );
921 921
             case 'create':
922 922
             case 'edit':
923 923
             case 'update':
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
941 941
                 }
942 942
 
943
-                if ( strpos($action, 'bulk_') === 0 ) {
943
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
944 944
                     FrmAppHelper::remove_get_action();
945 945
                     return self::list_form();
946 946
                 }
@@ -967,27 +967,27 @@  discard block
 block discarded – undo
967 967
 
968 968
 	public static function admin_bar_configure() {
969 969
         global $frm_vars;
970
-        if ( empty($frm_vars['forms_loaded']) ) {
970
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
971 971
             return;
972 972
         }
973 973
 
974 974
         $actions = array();
975 975
         foreach ( $frm_vars['forms_loaded'] as $form ) {
976
-            if ( is_object($form) ) {
977
-                $actions[ $form->id ] = $form->name;
976
+            if ( is_object( $form ) ) {
977
+                $actions[$form->id] = $form->name;
978 978
             }
979
-            unset($form);
979
+            unset( $form );
980 980
         }
981 981
 
982
-        if ( empty($actions) ) {
982
+        if ( empty( $actions ) ) {
983 983
             return;
984 984
         }
985 985
 
986
-        asort($actions);
986
+        asort( $actions );
987 987
 
988 988
         global $wp_admin_bar;
989 989
 
990
-        if ( count($actions) == 1 ) {
990
+        if ( count( $actions ) == 1 ) {
991 991
             $wp_admin_bar->add_menu( array(
992 992
                 'title' => 'Edit Form',
993 993
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
         		$wp_admin_bar->add_menu( array(
1009 1009
         			'parent'    => 'frm-forms',
1010 1010
 					'id'        => 'edit_form_' . $form_id,
1011
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1011
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1012 1012
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1013 1013
         		) );
1014 1014
         	}
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
     //formidable shortcode
1019 1019
 	public static function get_form_shortcode( $atts ) {
1020 1020
         global $frm_vars;
1021
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1021
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1022 1022
             $sc = '[formidable';
1023 1023
 			if ( ! empty( $atts ) ) {
1024 1024
 				foreach ( $atts as $k => $v ) {
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1033 1033
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1034 1034
             'exclude_fields' => array(), 'minimize' => false,
1035
-        ), $atts);
1036
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1035
+        ), $atts );
1036
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1037 1037
 
1038 1038
         return self::show_form(
1039 1039
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1121,51 +1121,51 @@  discard block
 block discarded – undo
1121 1121
 
1122 1122
         $frm_settings = FrmAppHelper::get_settings();
1123 1123
 
1124
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1124
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1125 1125
 
1126 1126
         $user_ID = get_current_user_id();
1127 1127
 		$params = FrmForm::get_params( $form );
1128 1128
         $message = $errors = '';
1129 1129
 
1130 1130
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1131
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1131
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1132 1132
         }
1133 1133
 
1134 1134
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1135 1135
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1136 1136
 
1137 1137
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1138
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1139
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1140
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1139
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1140
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1141 1141
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1142 1142
             }
1143 1143
             return;
1144 1144
         }
1145 1145
 
1146
-        if ( ! empty($errors) ) {
1147
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1146
+        if ( ! empty( $errors ) ) {
1147
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1148 1148
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1149 1149
             return;
1150 1150
         }
1151 1151
 
1152
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1153
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1152
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1153
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1154 1154
             return;
1155 1155
         }
1156 1156
 
1157
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1158
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1159
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1158
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1159
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1160 1160
 
1161
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1162
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1161
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1162
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1163 1163
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1164 1164
             return;
1165 1165
         }
1166 1166
 
1167
-        if ( $created && is_numeric($created) ) {
1168
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1167
+        if ( $created && is_numeric( $created ) ) {
1168
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1169 1169
             $class = 'frm_message';
1170 1170
         } else {
1171 1171
             $message = $frm_settings->failed_msg;
@@ -1176,9 +1176,9 @@  discard block
 block discarded – undo
1176 1176
 			'message' => $message, 'form' => $form,
1177 1177
 			'entry_id' => $created, 'class' => $class,
1178 1178
 		) );
1179
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1179
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1180 1180
 
1181
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1181
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1182 1182
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1183 1183
         } else {
1184 1184
             global $frm_vars;
Please login to merge, or discard this patch.
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -159,6 +159,9 @@  discard block
 block discarded – undo
159 159
 		wp_die();
160 160
 	}
161 161
 
162
+	/**
163
+	 * @param string $field
164
+	 */
162 165
 	private static function edit_in_place_value( $field ) {
163 166
 		check_ajax_referer( 'frm_ajax', 'nonce' );
164 167
 		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
@@ -203,6 +206,9 @@  discard block
 block discarded – undo
203 206
         }
204 207
     }
205 208
 
209
+    /**
210
+     * @return string
211
+     */
206 212
     public static function bulk_create_template( $ids ) {
207 213
         FrmAppHelper::permission_check( 'frm_edit_forms' );
208 214
 
@@ -698,6 +704,7 @@  discard block
 block discarded – undo
698 704
 	/**
699 705
 	 * Get an array of the helper shortcodes to display in the customization panel
700 706
 	 * @since 2.0.6
707
+	 * @param boolean $settings_tab
701 708
 	 */
702 709
 	private static function get_shortcode_helpers( $settings_tab ) {
703 710
 		$entry_shortcodes = array(
@@ -771,6 +778,9 @@  discard block
 block discarded – undo
771 778
         return $content;
772 779
     }
773 780
 
781
+	/**
782
+	 * @param boolean $entry
783
+	 */
774 784
 	private static function get_entry_by_param( &$entry ) {
775 785
 		if ( ! $entry || ! is_object( $entry ) ) {
776 786
 			if ( ! $entry || ! is_numeric( $entry ) ) {
@@ -1237,6 +1247,7 @@  discard block
 block discarded – undo
1237 1247
 
1238 1248
 	/**
1239 1249
 	 * @since 2.0.8
1250
+	 * @param string $content
1240 1251
 	 */
1241 1252
 	private static function maybe_minimize_form( $atts, &$content ) {
1242 1253
 		// check if minimizing is turned on
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 3 patches
Spacing   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public static function get_affiliate() {
69
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
69
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
70 70
 		$affiliate_id = strtolower( $affiliate_id );
71 71
 		$allowed_affiliates = array( 'mojo' );
72 72
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function get_settings() {
87 87
         global $frm_settings;
88
-        if ( empty($frm_settings) ) {
88
+        if ( empty( $frm_settings ) ) {
89 89
             $frm_settings = new FrmSettings();
90 90
         }
91 91
         return $frm_settings;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     }
107 107
 
108 108
     public static function pro_is_installed() {
109
-        return apply_filters('frm_pro_installed', false);
109
+        return apply_filters( 'frm_pro_installed', false );
110 110
     }
111 111
 
112 112
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return boolean
151 151
      */
152 152
     public static function doing_ajax() {
153
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
153
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
154 154
     }
155 155
 
156 156
 	/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @return boolean
171 171
      */
172 172
     public static function is_admin() {
173
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
173
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
174 174
     }
175 175
 
176 176
     /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @return string
197 197
      */
198 198
 	public static function get_server_value( $value ) {
199
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
199
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
200 200
     }
201 201
 
202 202
     /**
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
212 212
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
213 213
         ) as $key ) {
214
-            if ( ! isset( $_SERVER[ $key ] ) ) {
214
+            if ( ! isset( $_SERVER[$key] ) ) {
215 215
                 continue;
216 216
             }
217 217
 
218
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
219
-                $ip = trim($ip); // just to be safe
218
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
219
+                $ip = trim( $ip ); // just to be safe
220 220
 
221
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
221
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
222 222
                     return $ip;
223 223
                 }
224 224
             }
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
     }
229 229
 
230 230
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
231
-        if ( strpos($param, '[') ) {
232
-            $params = explode('[', $param);
231
+        if ( strpos( $param, '[' ) ) {
232
+            $params = explode( '[', $param );
233 233
             $param = $params[0];
234 234
         }
235 235
 
236 236
 		if ( $src == 'get' ) {
237
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
238
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
239
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
237
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
238
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
239
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
240 240
             }
241 241
 			self::sanitize_value( $sanitize, $value );
242 242
 		} else {
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 
246 246
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
247 247
             foreach ( $params as $k => $p ) {
248
-                if ( ! $k || ! is_array($value) ) {
248
+                if ( ! $k || ! is_array( $value ) ) {
249 249
                     continue;
250 250
                 }
251 251
 
252
-                $p = trim($p, ']');
253
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
252
+                $p = trim( $p, ']' );
253
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
254 254
             }
255 255
         }
256 256
 
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$value = $args['default'];
294 294
 		if ( $args['type'] == 'get' ) {
295
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
296
-				$value = $_GET[ $args['param'] ];
295
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
296
+				$value = $_GET[$args['param']];
297 297
 			}
298 298
 		} else if ( $args['type'] == 'post' ) {
299
-			if ( isset( $_POST[ $args['param'] ] ) ) {
300
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
299
+			if ( isset( $_POST[$args['param']] ) ) {
300
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
301 301
 			}
302 302
 		} else {
303
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
304
-				$value = $_REQUEST[ $args['param'] ];
303
+			if ( isset( $_REQUEST[$args['param']] ) ) {
304
+				$value = $_REQUEST[$args['param']];
305 305
 			}
306 306
 		}
307 307
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			if ( is_array( $value ) ) {
330 330
 				$temp_values = $value;
331 331
 				foreach ( $temp_values as $k => $v ) {
332
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
332
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
333 333
 				}
334 334
 			} else {
335 335
 				$value = call_user_func( $sanitize, $value );
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
     public static function sanitize_request( $sanitize_method, &$values ) {
341 341
         $temp_values = $values;
342 342
         foreach ( $temp_values as $k => $val ) {
343
-            if ( isset( $sanitize_method[ $k ] ) ) {
344
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
343
+            if ( isset( $sanitize_method[$k] ) ) {
344
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
345 345
             }
346 346
         }
347 347
     }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	public static function sanitize_array( &$values ) {
350 350
 		$temp_values = $values;
351 351
 		foreach ( $temp_values as $k => $val ) {
352
-			$values[ $k ] = wp_kses_post( $val );
352
+			$values[$k] = wp_kses_post( $val );
353 353
 		}
354 354
 	}
355 355
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		$allowed_html = array();
371 371
 		foreach ( $allowed as $a ) {
372
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
372
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
373 373
 		}
374 374
 
375 375
 		return wp_kses( $value, $allowed_html );
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      * @since 2.0
381 381
      */
382 382
     public static function remove_get_action() {
383
-        if ( ! isset($_GET) ) {
383
+        if ( ! isset( $_GET ) ) {
384 384
             return;
385 385
         }
386 386
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
         }
403 403
 
404 404
         global $wp_query;
405
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
406
-            $value = $wp_query->query_vars[ $param ];
405
+        if ( isset( $wp_query->query_vars[$param] ) ) {
406
+            $value = $wp_query->query_vars[$param];
407 407
         }
408 408
 
409 409
         return $value;
@@ -432,16 +432,16 @@  discard block
 block discarded – undo
432 432
      * @return mixed $results The cache or query results
433 433
      */
434 434
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
435
-        $results = wp_cache_get($cache_key, $group);
436
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
435
+        $results = wp_cache_get( $cache_key, $group );
436
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
437 437
             return $results;
438 438
         }
439 439
 
440 440
         if ( 'get_posts' == $type ) {
441
-            $results = get_posts($query);
441
+            $results = get_posts( $query );
442 442
         } else {
443 443
             global $wpdb;
444
-            $results = $wpdb->{$type}($query);
444
+            $results = $wpdb->{$type}( $query );
445 445
         }
446 446
 
447 447
 		if ( ! self::prevent_caching() ) {
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
         }
466 466
 
467 467
         // then check the transient
468
-        $results = get_transient($cache_key);
468
+        $results = get_transient( $cache_key );
469 469
         if ( $results ) {
470
-            wp_cache_set($cache_key, $results);
470
+            wp_cache_set( $cache_key, $results );
471 471
         }
472 472
 
473 473
         return $results;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      * @param string $cache_key
479 479
      */
480 480
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
481
-		delete_transient($cache_key);
481
+		delete_transient( $cache_key );
482 482
 		wp_cache_delete( $cache_key, $group );
483 483
 	}
484 484
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     	global $wp_object_cache;
495 495
 
496 496
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
497
-			$group_cache = $wp_object_cache->__get('cache');
497
+			$group_cache = $wp_object_cache->__get( 'cache' );
498 498
 		} elseif ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() ) {
499 499
 			// check if the object cache is overridden by Redis
500 500
 			$wp_object_cache->flush();
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 			$group_cache = $wp_object_cache->cache;
505 505
 		}
506 506
 
507
-		if ( isset( $group_cache[ $group ] ) ) {
508
-			foreach ( $group_cache[ $group ] as $k => $v ) {
507
+		if ( isset( $group_cache[$group] ) ) {
508
+			foreach ( $group_cache[$group] as $k => $v ) {
509 509
 				wp_cache_delete( $k, $group );
510 510
 			}
511 511
 			return true;
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
     }
536 536
 
537 537
     public static function get_pages() {
538
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
538
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
539 539
     }
540 540
 
541 541
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
542 542
         $pages = self::get_pages();
543 543
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
544 544
     ?>
545
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
545
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
546 546
             <option value=""> </option>
547 547
             <?php foreach ( $pages as $page ) { ?>
548
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
548
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
549 549
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
550 550
 				</option>
551 551
             <?php } ?>
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
     }
555 555
 
556 556
 	public static function post_edit_link( $post_id ) {
557
-        $post = get_post($post_id);
557
+        $post = get_post( $post_id );
558 558
         if ( $post ) {
559 559
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
560 560
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -564,17 +564,17 @@  discard block
 block discarded – undo
564 564
 
565 565
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
566 566
     ?>
567
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
567
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
568 568
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
569 569
             ?> class="frm_multiselect">
570
-            <?php self::roles_options($capability); ?>
570
+            <?php self::roles_options( $capability ); ?>
571 571
         </select>
572 572
     <?php
573 573
     }
574 574
 
575 575
 	public static function roles_options( $capability ) {
576 576
         global $frm_vars;
577
-        if ( isset($frm_vars['editable_roles']) ) {
577
+        if ( isset( $frm_vars['editable_roles'] ) ) {
578 578
             $editable_roles = $frm_vars['editable_roles'];
579 579
         } else {
580 580
             $editable_roles = get_editable_roles();
@@ -582,10 +582,10 @@  discard block
 block discarded – undo
582 582
         }
583 583
 
584 584
         foreach ( $editable_roles as $role => $details ) {
585
-            $name = translate_user_role($details['name'] ); ?>
586
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
585
+            $name = translate_user_role( $details['name'] ); ?>
586
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
587 587
 <?php
588
-            unset($role, $details);
588
+            unset( $role, $details );
589 589
         }
590 590
     }
591 591
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
     public static function maybe_add_permissions() {
642 642
 		self::force_capability( 'frm_view_entries' );
643 643
 
644
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
644
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
645 645
             return;
646 646
         }
647 647
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         $frm_roles = self::frm_capabilities();
651 651
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
652 652
 			$user->add_cap( $frm_role );
653
-            unset($frm_role, $frm_role_description);
653
+            unset( $frm_role, $frm_role_description );
654 654
         }
655 655
     }
656 656
 
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
      * @param string $permission
676 676
      */
677 677
 	public static function permission_check( $permission, $show_message = 'show' ) {
678
-        $permission_error = self::permission_nonce_error($permission);
678
+        $permission_error = self::permission_nonce_error( $permission );
679 679
         if ( $permission_error !== false ) {
680 680
             if ( 'hide' == $show_message ) {
681 681
                 $permission_error = '';
682 682
             }
683
-            wp_die($permission_error);
683
+            wp_die( $permission_error );
684 684
         }
685 685
     }
686 686
 
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 		}
698 698
 
699 699
 		$error = false;
700
-        if ( empty($nonce_name) ) {
700
+        if ( empty( $nonce_name ) ) {
701 701
             return $error;
702 702
         }
703 703
 
704
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
704
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
705 705
             $frm_settings = self::get_settings();
706 706
             $error = $frm_settings->admin_permission;
707 707
         }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 			} else {
782 782
 				foreach ( $value as $k => $v ) {
783 783
 					if ( ! is_array( $v ) ) {
784
-						$value[ $k ] = call_user_func( $original_function, $v );
784
+						$value[$k] = call_user_func( $original_function, $v );
785 785
 					}
786 786
 				}
787 787
 			}
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	public static function array_flatten( $array, $keys = 'keep' ) {
803 803
         $return = array();
804 804
         foreach ( $array as $key => $value ) {
805
-            if ( is_array($value) ) {
805
+            if ( is_array( $value ) ) {
806 806
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
807 807
             } else {
808 808
 				if ( $keys == 'keep' ) {
809
-					$return[ $key ] = $value;
809
+					$return[$key] = $value;
810 810
 				} else {
811 811
 					$return[] = $value;
812 812
 				}
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * @since 2.0
830 830
      */
831 831
 	public static function use_wpautop( $content ) {
832
-        if ( apply_filters('frm_use_wpautop', true) ) {
833
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
832
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
833
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
834 834
         }
835 835
         return $content;
836 836
     }
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
      * @return string The base Google APIS url for the current version of jQuery UI
849 849
      */
850 850
     public static function jquery_ui_base_url() {
851
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
852
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
851
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
852
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
853 853
         return $url;
854 854
     }
855 855
 
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
         $ver = 0;
866 866
 
867
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
867
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
868 868
             return $ver;
869 869
         }
870 870
 
871
-        $query = $wp_scripts->registered[ $handle ];
871
+        $query = $wp_scripts->registered[$handle];
872 872
     	if ( is_object( $query ) ) {
873 873
     	    $ver = $query->ver;
874 874
     	}
@@ -881,36 +881,36 @@  discard block
 block discarded – undo
881 881
     }
882 882
 
883 883
 	public static function get_user_id_param( $user_id ) {
884
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
884
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
885 885
             return $user_id;
886 886
         }
887 887
 
888 888
 		if ( $user_id == 'current' ) {
889 889
 			$user_id = get_current_user_id();
890 890
 		} else {
891
-            if ( is_email($user_id) ) {
892
-                $user = get_user_by('email', $user_id);
891
+            if ( is_email( $user_id ) ) {
892
+                $user = get_user_by( 'email', $user_id );
893 893
             } else {
894
-                $user = get_user_by('login', $user_id);
894
+                $user = get_user_by( 'login', $user_id );
895 895
             }
896 896
 
897 897
             if ( $user ) {
898 898
                 $user_id = $user->ID;
899 899
             }
900
-            unset($user);
900
+            unset( $user );
901 901
         }
902 902
 
903 903
         return $user_id;
904 904
     }
905 905
 
906 906
 	public static function get_file_contents( $filename, $atts = array() ) {
907
-        if ( ! is_file($filename) ) {
907
+        if ( ! is_file( $filename ) ) {
908 908
             return false;
909 909
         }
910 910
 
911
-        extract($atts);
911
+        extract( $atts );
912 912
         ob_start();
913
-        include($filename);
913
+        include( $filename );
914 914
         $contents = ob_get_contents();
915 915
         ob_end_clean();
916 916
         return $contents;
@@ -926,28 +926,28 @@  discard block
 block discarded – undo
926 926
         $key = '';
927 927
 
928 928
         if ( ! empty( $name ) ) {
929
-            $key = sanitize_key($name);
929
+            $key = sanitize_key( $name );
930 930
         }
931 931
 
932 932
 		if ( empty( $key ) ) {
933
-            $max_slug_value = pow(36, $num_chars);
933
+            $max_slug_value = pow( 36, $num_chars );
934 934
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
935
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
935
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
936 936
         }
937 937
 
938
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
938
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
939 939
 			$key = $key . 'a';
940 940
         }
941 941
 
942 942
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
943 943
 
944
-        if ( $key_check || is_numeric($key_check) ) {
944
+        if ( $key_check || is_numeric( $key_check ) ) {
945 945
             $suffix = 2;
946 946
 			do {
947 947
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
948 948
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
949
-				$suffix++;
950
-			} while ($key_check || is_numeric($key_check));
949
+				$suffix ++;
950
+			} while ( $key_check || is_numeric( $key_check ) );
951 951
 			$key = $alt_post_name;
952 952
         }
953 953
         return $key;
@@ -963,32 +963,32 @@  discard block
 block discarded – undo
963 963
             return false;
964 964
         }
965 965
 
966
-        if ( empty($post_values) ) {
967
-            $post_values = stripslashes_deep($_POST);
966
+        if ( empty( $post_values ) ) {
967
+            $post_values = stripslashes_deep( $_POST );
968 968
         }
969 969
 
970 970
 		$values = array( 'id' => $record->id, 'fields' => array() );
971 971
 
972 972
 		foreach ( array( 'name', 'description' ) as $var ) {
973
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
974
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
-            unset($var, $default_val);
973
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
974
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
975
+            unset( $var, $default_val );
976 976
         }
977 977
 
978
-        $values['description'] = self::use_wpautop($values['description']);
978
+        $values['description'] = self::use_wpautop( $values['description'] );
979 979
         $frm_settings = self::get_settings();
980
-        $is_form_builder = self::is_admin_page('formidable' );
980
+        $is_form_builder = self::is_admin_page( 'formidable' );
981 981
 
982 982
         foreach ( (array) $fields as $field ) {
983 983
             // Make sure to filter default values (for placeholder text), but not on the form builder page
984 984
             if ( ! $is_form_builder ) {
985
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
985
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
986 986
             }
987 987
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
988
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
988
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
989 989
         }
990 990
 
991
-        self::fill_form_opts($record, $table, $post_values, $values);
991
+        self::fill_form_opts( $record, $table, $post_values, $values );
992 992
 
993 993
         if ( $table == 'entries' ) {
994 994
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
         if ( $args['default'] ) {
1006 1006
             $meta_value = $field->default_value;
1007 1007
         } else {
1008
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1009
-                if ( ! isset($field->field_options['custom_field']) ) {
1008
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1009
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1010 1010
                     $field->field_options['custom_field'] = '';
1011 1011
                 }
1012 1012
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
             }
1016 1016
         }
1017 1017
 
1018
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1019
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1018
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1019
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1020 1020
 
1021 1021
         $field_array = array(
1022 1022
             'id'            => $field->id,
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
             'default_value' => $field->default_value,
1025 1025
             'name'          => $field->name,
1026 1026
             'description'   => $field->description,
1027
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1027
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1028 1028
             'options'       => $field->options,
1029 1029
             'required'      => $field->required,
1030 1030
             'field_key'     => $field->field_key,
@@ -1034,40 +1034,40 @@  discard block
 block discarded – undo
1034 1034
         );
1035 1035
 
1036 1036
         $args['field_type'] = $field_type;
1037
-        self::fill_field_opts($field, $field_array, $args);
1037
+        self::fill_field_opts( $field, $field_array, $args );
1038 1038
 		// Track the original field's type
1039 1039
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1040 1040
 
1041 1041
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1042 1042
 
1043
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1043
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1044 1044
             $field_array['unique_msg'] = '';
1045 1045
         }
1046 1046
 
1047 1047
         $field_array = array_merge( $field->field_options, $field_array );
1048 1048
 
1049
-        $values['fields'][ $field->id ] = $field_array;
1049
+        $values['fields'][$field->id] = $field_array;
1050 1050
     }
1051 1051
 
1052 1052
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1053 1053
         $post_values = $args['post_values'];
1054
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1054
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1055 1055
 
1056 1056
         foreach ( $opt_defaults as $opt => $default_opt ) {
1057
-			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1058
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1059
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1060
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1057
+			$field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt );
1058
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1059
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1060
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1061 1061
                 if ( $args['field_type'] == 'captcha' ) {
1062
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1062
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1063 1063
                 } else {
1064
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1064
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1065 1065
                 }
1066 1066
             }
1067 1067
         }
1068 1068
 
1069 1069
         if ( $field_array['custom_html'] == '' ) {
1070
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1070
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1071 1071
         }
1072 1072
     }
1073 1073
 
@@ -1086,18 +1086,18 @@  discard block
 block discarded – undo
1086 1086
             return;
1087 1087
         }
1088 1088
 
1089
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1089
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1090 1090
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1091 1091
 
1092
-        if ( ! is_array($form->options) ) {
1092
+        if ( ! is_array( $form->options ) ) {
1093 1093
             return;
1094 1094
         }
1095 1095
 
1096 1096
         foreach ( $form->options as $opt => $value ) {
1097
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1097
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1098 1098
         }
1099 1099
 
1100
-        self::fill_form_defaults($post_values, $values);
1100
+        self::fill_form_defaults( $post_values, $values );
1101 1101
     }
1102 1102
 
1103 1103
     /**
@@ -1107,23 +1107,23 @@  discard block
 block discarded – undo
1107 1107
         $form_defaults = FrmFormsHelper::get_default_opts();
1108 1108
 
1109 1109
         foreach ( $form_defaults as $opt => $default ) {
1110
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1111
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1110
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1111
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1112 1112
             }
1113 1113
 
1114
-            unset($opt, $defaut);
1114
+            unset( $opt, $defaut );
1115 1115
         }
1116 1116
 
1117
-        if ( ! isset($values['custom_style']) ) {
1117
+        if ( ! isset( $values['custom_style'] ) ) {
1118 1118
             $frm_settings = self::get_settings();
1119 1119
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1120 1120
         }
1121 1121
 
1122 1122
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1123
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1124
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1123
+			if ( ! isset( $values[$h . '_html'] ) ) {
1124
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1125 1125
             }
1126
-            unset($h);
1126
+            unset( $h );
1127 1127
         }
1128 1128
     }
1129 1129
 
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
         }
1140 1140
     ?>
1141 1141
 <li>
1142
-    <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>
1143
-    <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>
1144
-    <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>
1142
+    <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>
1143
+    <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>
1144
+    <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>
1145 1145
 </li>
1146 1146
     <?php
1147 1147
     }
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
             return '';
1160 1160
         } else if ( $length <= 10 ) {
1161 1161
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1162
-            return $sub . (($length < $original_len) ? $continue : '');
1162
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1163 1163
         }
1164 1164
 
1165 1165
         $sub = '';
@@ -1168,23 +1168,23 @@  discard block
 block discarded – undo
1168 1168
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1169 1169
 
1170 1170
 		foreach ( $words as $word ) {
1171
-            $part = (($sub != '') ? ' ' : '') . $word;
1171
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1172 1172
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1173
-            if ( $total_len > $length && str_word_count($sub) ) {
1173
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1174 1174
                 break;
1175 1175
             }
1176 1176
 
1177 1177
             $sub .= $part;
1178 1178
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1179 1179
 
1180
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1180
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1181 1181
                 break;
1182 1182
             }
1183 1183
 
1184
-            unset($total_len, $word);
1184
+            unset( $total_len, $word );
1185 1185
         }
1186 1186
 
1187
-        return $sub . (($len < $original_len) ? $continue : '');
1187
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1188 1188
     }
1189 1189
 
1190 1190
 	public static function mb_function( $function_names, $args ) {
@@ -1197,17 +1197,17 @@  discard block
 block discarded – undo
1197 1197
 	}
1198 1198
 
1199 1199
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1200
-        if ( empty($date) ) {
1200
+        if ( empty( $date ) ) {
1201 1201
             return $date;
1202 1202
         }
1203 1203
 
1204
-        if ( empty($date_format) ) {
1205
-            $date_format = get_option('date_format');
1204
+        if ( empty( $date_format ) ) {
1205
+            $date_format = get_option( 'date_format' );
1206 1206
         }
1207 1207
 
1208
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1208
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1209 1209
             $frmpro_settings = new FrmProSettings();
1210
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1210
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1211 1211
         }
1212 1212
 
1213 1213
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 
1223 1223
 	private static function add_time_to_date( $time_format, $date ) {
1224 1224
 		if ( empty( $time_format ) ) {
1225
-			$time_format = get_option('time_format');
1225
+			$time_format = get_option( 'time_format' );
1226 1226
 		}
1227 1227
 
1228 1228
 		$trimmed_format = trim( $time_format );
@@ -1268,10 +1268,10 @@  discard block
 block discarded – undo
1268 1268
 		$time_strings = self::get_time_strings();
1269 1269
 
1270 1270
 		foreach ( $time_strings as $k => $v ) {
1271
-			if ( $diff[ $k ] ) {
1272
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1271
+			if ( $diff[$k] ) {
1272
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1273 1273
 			} else {
1274
-				unset( $time_strings[ $k ] );
1274
+				unset( $time_strings[$k] );
1275 1275
 			}
1276 1276
 		}
1277 1277
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
      */
1310 1310
 	public static function esc_like( $term ) {
1311 1311
         global $wpdb;
1312
-        if ( method_exists($wpdb, 'esc_like') ) {
1312
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1313 1313
 			// WP 4.0
1314 1314
             $term = $wpdb->esc_like( $term );
1315 1315
         } else {
@@ -1323,17 +1323,17 @@  discard block
 block discarded – undo
1323 1323
      * @param string $order_query
1324 1324
      */
1325 1325
 	public static function esc_order( $order_query ) {
1326
-        if ( empty($order_query) ) {
1326
+        if ( empty( $order_query ) ) {
1327 1327
             return '';
1328 1328
         }
1329 1329
 
1330 1330
         // remove ORDER BY before santizing
1331
-        $order_query = strtolower($order_query);
1332
-        if ( strpos($order_query, 'order by') !== false ) {
1333
-            $order_query = str_replace('order by', '', $order_query);
1331
+        $order_query = strtolower( $order_query );
1332
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1333
+            $order_query = str_replace( 'order by', '', $order_query );
1334 1334
         }
1335 1335
 
1336
-        $order_query = explode(' ', trim($order_query));
1336
+        $order_query = explode( ' ', trim( $order_query ) );
1337 1337
 
1338 1338
         $order_fields = array(
1339 1339
             'id', 'form_key', 'name', 'description',
@@ -1341,13 +1341,13 @@  discard block
 block discarded – undo
1341 1341
             'default_template', 'status', 'created_at',
1342 1342
         );
1343 1343
 
1344
-        $order = trim(trim(reset($order_query), ','));
1345
-        if ( ! in_array($order, $order_fields) ) {
1344
+        $order = trim( trim( reset( $order_query ), ',' ) );
1345
+        if ( ! in_array( $order, $order_fields ) ) {
1346 1346
             return '';
1347 1347
         }
1348 1348
 
1349 1349
         $order_by = '';
1350
-        if ( count($order_query) > 1 ) {
1350
+        if ( count( $order_query ) > 1 ) {
1351 1351
 			$order_by = end( $order_query );
1352 1352
 			self::esc_order_by( $order_by );
1353 1353
         }
@@ -1369,23 +1369,23 @@  discard block
 block discarded – undo
1369 1369
      * @param string $limit
1370 1370
      */
1371 1371
 	public static function esc_limit( $limit ) {
1372
-        if ( empty($limit) ) {
1372
+        if ( empty( $limit ) ) {
1373 1373
             return '';
1374 1374
         }
1375 1375
 
1376
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1377
-        if ( is_numeric($limit) ) {
1376
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1377
+        if ( is_numeric( $limit ) ) {
1378 1378
 			return ' LIMIT ' . $limit;
1379 1379
         }
1380 1380
 
1381
-        $limit = explode(',', trim($limit));
1381
+        $limit = explode( ',', trim( $limit ) );
1382 1382
         foreach ( $limit as $k => $l ) {
1383 1383
             if ( is_numeric( $l ) ) {
1384
-                $limit[ $k ] = $l;
1384
+                $limit[$k] = $l;
1385 1385
             }
1386 1386
         }
1387 1387
 
1388
-        $limit = implode(',', $limit);
1388
+        $limit = implode( ',', $limit );
1389 1389
 		return ' LIMIT ' . $limit;
1390 1390
     }
1391 1391
 
@@ -1394,12 +1394,12 @@  discard block
 block discarded – undo
1394 1394
      * @since 2.0
1395 1395
      */
1396 1396
     public static function prepare_array_values( $array, $type = '%s' ) {
1397
-        $placeholders = array_fill(0, count($array), $type);
1398
-        return implode(', ', $placeholders);
1397
+        $placeholders = array_fill( 0, count( $array ), $type );
1398
+        return implode( ', ', $placeholders );
1399 1399
     }
1400 1400
 
1401 1401
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1402
-        if ( empty($where) ) {
1402
+        if ( empty( $where ) ) {
1403 1403
             return '';
1404 1404
         }
1405 1405
 
@@ -1440,19 +1440,19 @@  discard block
 block discarded – undo
1440 1440
 	public static function json_to_array( $json_vars ) {
1441 1441
         $vars = array();
1442 1442
         foreach ( $json_vars as $jv ) {
1443
-            $jv_name = explode('[', $jv['name']);
1444
-            $last = count($jv_name) - 1;
1443
+            $jv_name = explode( '[', $jv['name'] );
1444
+            $last = count( $jv_name ) - 1;
1445 1445
             foreach ( $jv_name as $p => $n ) {
1446
-                $name = trim($n, ']');
1447
-                if ( ! isset($l1) ) {
1446
+                $name = trim( $n, ']' );
1447
+                if ( ! isset( $l1 ) ) {
1448 1448
                     $l1 = $name;
1449 1449
                 }
1450 1450
 
1451
-                if ( ! isset($l2) ) {
1451
+                if ( ! isset( $l2 ) ) {
1452 1452
                     $l2 = $name;
1453 1453
                 }
1454 1454
 
1455
-                if ( ! isset($l3) ) {
1455
+                if ( ! isset( $l3 ) ) {
1456 1456
                     $l3 = $name;
1457 1457
                 }
1458 1458
 
@@ -1466,24 +1466,24 @@  discard block
 block discarded – undo
1466 1466
 
1467 1467
                     case 1:
1468 1468
                         $l2 = $name;
1469
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1469
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1470 1470
                     break;
1471 1471
 
1472 1472
                     case 2:
1473 1473
                         $l3 = $name;
1474
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1474
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1475 1475
                     break;
1476 1476
 
1477 1477
                     case 3:
1478 1478
                         $l4 = $name;
1479
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1479
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1480 1480
                     break;
1481 1481
                 }
1482 1482
 
1483
-                unset($this_val, $n);
1483
+                unset( $this_val, $n );
1484 1484
             }
1485 1485
 
1486
-            unset($last, $jv);
1486
+            unset( $last, $jv );
1487 1487
         }
1488 1488
 
1489 1489
         return $vars;
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1497 1497
         if ( $name == '' ) {
1498 1498
             $vars[] = $val;
1499
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1500
-            $vars[ $l1 ] = $val;
1499
+        } else if ( ! isset( $vars[$l1] ) ) {
1500
+            $vars[$l1] = $val;
1501 1501
         }
1502 1502
     }
1503 1503
 
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
             '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() ) ),
1513 1513
         );
1514 1514
 
1515
-        if ( ! isset( $tooltips[ $name ] ) ) {
1515
+        if ( ! isset( $tooltips[$name] ) ) {
1516 1516
             return;
1517 1517
         }
1518 1518
 
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
             echo ' class="frm_help"';
1523 1523
         }
1524 1524
 
1525
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1525
+		echo ' title="' . esc_attr( $tooltips[$name] );
1526 1526
 
1527 1527
         if ( 'open' != $class ) {
1528 1528
             echo '"';
@@ -1574,13 +1574,13 @@  discard block
 block discarded – undo
1574 1574
     }
1575 1575
 
1576 1576
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1577
-		if ( ! isset( $post_content[ $key ] ) ) {
1577
+		if ( ! isset( $post_content[$key] ) ) {
1578 1578
 			return;
1579 1579
 		}
1580 1580
 
1581 1581
 		if ( is_array( $val ) ) {
1582 1582
 			foreach ( $val as $k1 => $v1 ) {
1583
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1583
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1584 1584
 				unset( $k1, $v1 );
1585 1585
 			}
1586 1586
 		} else {
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 			$val = stripslashes( $val );
1589 1589
 
1590 1590
 			// Add backslashes before double quotes and forward slashes only
1591
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1591
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1592 1592
 		}
1593 1593
 	}
1594 1594
 
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1606 1606
 
1607 1607
 		if ( empty( $settings['ID'] ) ) {
1608
-			unset( $settings['ID']);
1608
+			unset( $settings['ID'] );
1609 1609
 		}
1610 1610
 
1611 1611
 		// delete all caches for this group
@@ -1639,17 +1639,17 @@  discard block
 block discarded – undo
1639 1639
 	}
1640 1640
 
1641 1641
 	public static function maybe_json_decode( $string ) {
1642
-        if ( is_array($string) ) {
1642
+        if ( is_array( $string ) ) {
1643 1643
             return $string;
1644 1644
         }
1645 1645
 
1646
-        $new_string = json_decode($string, true);
1647
-        if ( function_exists('json_last_error') ) {
1646
+        $new_string = json_decode( $string, true );
1647
+        if ( function_exists( 'json_last_error' ) ) {
1648 1648
 			// php 5.3+
1649 1649
             if ( json_last_error() == JSON_ERROR_NONE ) {
1650 1650
                 $string = $new_string;
1651 1651
             }
1652
-        } else if ( isset($new_string) ) {
1652
+        } else if ( isset( $new_string ) ) {
1653 1653
 			// php < 5.3 fallback
1654 1654
             $string = $new_string;
1655 1655
         }
@@ -1665,11 +1665,11 @@  discard block
 block discarded – undo
1665 1665
 	public static function maybe_highlight_menu( $post_type ) {
1666 1666
         global $post;
1667 1667
 
1668
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1668
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1669 1669
             return;
1670 1670
         }
1671 1671
 
1672
-        if ( is_object($post) && $post->post_type != $post_type ) {
1672
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1673 1673
             return;
1674 1674
         }
1675 1675
 
@@ -1768,11 +1768,11 @@  discard block
 block discarded – undo
1768 1768
         $frm_version = self::plugin_version();
1769 1769
 
1770 1770
         // check if Formidable meets minimum requirements
1771
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1771
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1772 1772
             return;
1773 1773
         }
1774 1774
 
1775
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1775
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1776 1776
 		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">' .
1777 1777
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1778 1778
         '</div></td></tr>';
@@ -1780,38 +1780,38 @@  discard block
 block discarded – undo
1780 1780
 
1781 1781
     public static function locales( $type = 'date' ) {
1782 1782
         $locales = array(
1783
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1784
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1785
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1783
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1784
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1785
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1786 1786
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1787
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1788
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1787
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1788
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1789 1789
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1790
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1791
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1790
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1791
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1792 1792
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1793
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1793
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1794 1794
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1795
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1795
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1796 1796
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1797
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1797
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1798 1798
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1799
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1800
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1801
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1802
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1803
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1799
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1800
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1801
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1802
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1803
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1804 1804
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1805
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1805
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1806 1806
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1807 1807
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1808
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1808
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1809 1809
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1810
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1810
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1811 1811
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1812
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1813
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1814
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1812
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1813
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1814
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1815 1815
         );
1816 1816
 
1817 1817
         if ( $type == 'captcha' ) {
@@ -1830,8 +1830,8 @@  discard block
 block discarded – undo
1830 1830
             );
1831 1831
         }
1832 1832
 
1833
-        $locales = array_diff_key($locales, array_flip($unset));
1834
-        $locales = apply_filters('frm_locales', $locales);
1833
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1834
+        $locales = apply_filters( 'frm_locales', $locales );
1835 1835
 
1836 1836
         return $locales;
1837 1837
     }
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * Sanitize the value, and allow some HTML
363 363
 	 * @since 2.0
364 364
 	 * @param string $value
365
-	 * @param array $allowed
365
+	 * @param string[] $allowed
366 366
 	 * @return string
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
@@ -779,6 +779,9 @@  discard block
 block discarded – undo
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780 780
     }
781 781
 
782
+	/**
783
+	 * @param string $function
784
+	 */
782 785
 	public static function recursive_function_map( $value, $function ) {
783 786
 		if ( is_array( $value ) ) {
784 787
 			$original_function = $function;
@@ -1198,6 +1201,9 @@  discard block
 block discarded – undo
1198 1201
         return $sub . (($len < $original_len) ? $continue : '');
1199 1202
     }
1200 1203
 
1204
+	/**
1205
+	 * @param string[] $function_names
1206
+	 */
1201 1207
 	public static function mb_function( $function_names, $args ) {
1202 1208
 		$mb_function_name = $function_names[0];
1203 1209
 		$function_name = $function_names[1];
@@ -1231,6 +1237,9 @@  discard block
 block discarded – undo
1231 1237
         return $formatted;
1232 1238
     }
1233 1239
 
1240
+	/**
1241
+	 * @param string $time_format
1242
+	 */
1234 1243
 	private static function add_time_to_date( $time_format, $date ) {
1235 1244
 		if ( empty( $time_format ) ) {
1236 1245
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1040 added lines, -1040 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.02.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -75,83 +75,83 @@  discard block
 block discarded – undo
75 75
 		return $affiliate_id;
76 76
 	}
77 77
 
78
-    /**
79
-     * Get the Formidable settings
80
-     *
81
-     * @since 2.0
82
-     *
83
-     * @param None
84
-     * @return FrmSettings $frm_setings
85
-     */
86
-    public static function get_settings() {
87
-        global $frm_settings;
88
-        if ( empty($frm_settings) ) {
89
-            $frm_settings = new FrmSettings();
90
-        }
91
-        return $frm_settings;
92
-    }
78
+	/**
79
+	 * Get the Formidable settings
80
+	 *
81
+	 * @since 2.0
82
+	 *
83
+	 * @param None
84
+	 * @return FrmSettings $frm_setings
85
+	 */
86
+	public static function get_settings() {
87
+		global $frm_settings;
88
+		if ( empty($frm_settings) ) {
89
+			$frm_settings = new FrmSettings();
90
+		}
91
+		return $frm_settings;
92
+	}
93 93
 
94 94
 	public static function get_menu_name() {
95 95
 		$frm_settings = FrmAppHelper::get_settings();
96 96
 		return $frm_settings->menu;
97 97
 	}
98 98
 
99
-    /**
100
-     * Show a message in place of pro features
101
-     *
102
-     * @since 2.0
103
-     */
99
+	/**
100
+	 * Show a message in place of pro features
101
+	 *
102
+	 * @since 2.0
103
+	 */
104 104
 	public static function update_message() {
105 105
 		_deprecated_function( __FUNCTION__, '2.0.19' );
106
-    }
107
-
108
-    public static function pro_is_installed() {
109
-        return apply_filters('frm_pro_installed', false);
110
-    }
111
-
112
-    /**
113
-     * Check for certain page in Formidable settings
114
-     *
115
-     * @since 2.0
116
-     *
117
-     * @param string $page The name of the page to check
118
-     * @return boolean
119
-     */
106
+	}
107
+
108
+	public static function pro_is_installed() {
109
+		return apply_filters('frm_pro_installed', false);
110
+	}
111
+
112
+	/**
113
+	 * Check for certain page in Formidable settings
114
+	 *
115
+	 * @since 2.0
116
+	 *
117
+	 * @param string $page The name of the page to check
118
+	 * @return boolean
119
+	 */
120 120
 	public static function is_admin_page( $page = 'formidable' ) {
121
-        global $pagenow;
121
+		global $pagenow;
122 122
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
123
-        if ( $pagenow ) {
123
+		if ( $pagenow ) {
124 124
 			return $pagenow == 'admin.php' && $get_page == $page;
125
-        }
125
+		}
126 126
 
127 127
 		return is_admin() && $get_page == $page;
128
-    }
129
-
130
-    /**
131
-     * Check for the form preview page
132
-     *
133
-     * @since 2.0
134
-     *
135
-     * @param None
136
-     * @return boolean
137
-     */
138
-    public static function is_preview_page() {
139
-        global $pagenow;
128
+	}
129
+
130
+	/**
131
+	 * Check for the form preview page
132
+	 *
133
+	 * @since 2.0
134
+	 *
135
+	 * @param None
136
+	 * @return boolean
137
+	 */
138
+	public static function is_preview_page() {
139
+		global $pagenow;
140 140
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
141 141
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
142
-    }
142
+	}
143 143
 
144
-    /**
145
-     * Check for ajax except the form preview page
146
-     *
147
-     * @since 2.0
148
-     *
149
-     * @param None
150
-     * @return boolean
151
-     */
152
-    public static function doing_ajax() {
153
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
-    }
144
+	/**
145
+	 * Check for ajax except the form preview page
146
+	 *
147
+	 * @since 2.0
148
+	 *
149
+	 * @param None
150
+	 * @return boolean
151
+	 */
152
+	public static function doing_ajax() {
153
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+	}
155 155
 
156 156
 	/**
157 157
 	 * @since 2.0.8
@@ -161,102 +161,102 @@  discard block
 block discarded – undo
161 161
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
162 162
 	}
163 163
 
164
-    /**
165
-     * Check if on an admin page
166
-     *
167
-     * @since 2.0
168
-     *
169
-     * @param None
170
-     * @return boolean
171
-     */
172
-    public static function is_admin() {
173
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
-    }
175
-
176
-    /**
177
-     * Check if value contains blank value or empty array
178
-     *
179
-     * @since 2.0
180
-     * @param mixed $value - value to check
164
+	/**
165
+	 * Check if on an admin page
166
+	 *
167
+	 * @since 2.0
168
+	 *
169
+	 * @param None
170
+	 * @return boolean
171
+	 */
172
+	public static function is_admin() {
173
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+	}
175
+
176
+	/**
177
+	 * Check if value contains blank value or empty array
178
+	 *
179
+	 * @since 2.0
180
+	 * @param mixed $value - value to check
181 181
 	 * @param string
182
-     * @return boolean
183
-     */
184
-    public static function is_empty_value( $value, $empty = '' ) {
185
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
186
-    }
187
-
188
-    public static function is_not_empty_value( $value, $empty = '' ) {
189
-        return ! self::is_empty_value( $value, $empty );
190
-    }
191
-
192
-    /**
193
-     * Get any value from the $_SERVER
194
-     *
195
-     * @since 2.0
196
-     * @param string $value
197
-     * @return string
198
-     */
182
+	 * @return boolean
183
+	 */
184
+	public static function is_empty_value( $value, $empty = '' ) {
185
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
186
+	}
187
+
188
+	public static function is_not_empty_value( $value, $empty = '' ) {
189
+		return ! self::is_empty_value( $value, $empty );
190
+	}
191
+
192
+	/**
193
+	 * Get any value from the $_SERVER
194
+	 *
195
+	 * @since 2.0
196
+	 * @param string $value
197
+	 * @return string
198
+	 */
199 199
 	public static function get_server_value( $value ) {
200
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
-    }
202
-
203
-    /**
204
-     * Check for the IP address in several places
205
-     * Used by [ip] shortcode
206
-     *
207
-     * @return string The IP address of the current user
208
-     */
209
-    public static function get_ip_address() {
200
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+	}
202
+
203
+	/**
204
+	 * Check for the IP address in several places
205
+	 * Used by [ip] shortcode
206
+	 *
207
+	 * @return string The IP address of the current user
208
+	 */
209
+	public static function get_ip_address() {
210 210
 		$ip = '';
211
-        foreach ( array(
212
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
213
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
214
-        ) as $key ) {
215
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
-                continue;
217
-            }
218
-
219
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
220
-                $ip = trim($ip); // just to be safe
221
-
222
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
-                    return $ip;
224
-                }
225
-            }
226
-        }
211
+		foreach ( array(
212
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
213
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
214
+		) as $key ) {
215
+			if ( ! isset( $_SERVER[ $key ] ) ) {
216
+				continue;
217
+			}
218
+
219
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
220
+				$ip = trim($ip); // just to be safe
221
+
222
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+					return $ip;
224
+				}
225
+			}
226
+		}
227 227
 
228 228
 		return sanitize_text_field( $ip );
229
-    }
229
+	}
230 230
 
231
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
232
-        if ( strpos($param, '[') ) {
233
-            $params = explode('[', $param);
234
-            $param = $params[0];
235
-        }
231
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
232
+		if ( strpos($param, '[') ) {
233
+			$params = explode('[', $param);
234
+			$param = $params[0];
235
+		}
236 236
 
237 237
 		if ( $src == 'get' ) {
238
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
239
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
240
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
241
-            }
238
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
239
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
240
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
241
+			}
242 242
 			self::sanitize_value( $sanitize, $value );
243 243
 		} else {
244
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
245
-        }
244
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
245
+		}
246 246
 
247 247
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
248
-            foreach ( $params as $k => $p ) {
249
-                if ( ! $k || ! is_array($value) ) {
250
-                    continue;
251
-                }
248
+			foreach ( $params as $k => $p ) {
249
+				if ( ! $k || ! is_array($value) ) {
250
+					continue;
251
+				}
252 252
 
253
-                $p = trim($p, ']');
254
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
255
-            }
256
-        }
253
+				$p = trim($p, ']');
254
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
255
+			}
256
+		}
257 257
 
258
-        return $value;
259
-    }
258
+		return $value;
259
+	}
260 260
 
261 261
 	/**
262 262
 	 *
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
281 281
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
282
-    }
282
+	}
283 283
 
284 284
 	/**
285 285
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	}
316 316
 
317 317
 	/**
318
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
319
-	*
320
-	* @since 2.0.8
321
-	* @param string $value
322
-	* @return string $value
323
-	*/
318
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
319
+	 *
320
+	 * @since 2.0.8
321
+	 * @param string $value
322
+	 * @return string $value
323
+	 */
324 324
 	public static function preserve_backslashes( $value ) {
325 325
 		// If backslashes have already been added, don't add them again
326 326
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 		}
343 343
 	}
344 344
 
345
-    public static function sanitize_request( $sanitize_method, &$values ) {
346
-        $temp_values = $values;
347
-        foreach ( $temp_values as $k => $val ) {
348
-            if ( isset( $sanitize_method[ $k ] ) ) {
345
+	public static function sanitize_request( $sanitize_method, &$values ) {
346
+		$temp_values = $values;
347
+		foreach ( $temp_values as $k => $val ) {
348
+			if ( isset( $sanitize_method[ $k ] ) ) {
349 349
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
350
-            }
351
-        }
352
-    }
350
+			}
351
+		}
352
+	}
353 353
 
354 354
 	public static function sanitize_array( &$values ) {
355 355
 		$temp_values = $values;
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	public static function kses( $value, $allowed = array() ) {
369 369
 		$html = array(
370
-		    'a' => array(
370
+			'a' => array(
371 371
 				'href'  => array(),
372 372
 				'title' => array(),
373 373
 				'id'    => array(),
374 374
 				'class' => array(),
375
-		    ),
375
+			),
376 376
 		);
377 377
 
378 378
 		$allowed_html = array();
@@ -383,126 +383,126 @@  discard block
 block discarded – undo
383 383
 		return wp_kses( $value, $allowed_html );
384 384
 	}
385 385
 
386
-    /**
387
-     * Used when switching the action for a bulk action
388
-     * @since 2.0
389
-     */
390
-    public static function remove_get_action() {
391
-        if ( ! isset($_GET) ) {
392
-            return;
393
-        }
386
+	/**
387
+	 * Used when switching the action for a bulk action
388
+	 * @since 2.0
389
+	 */
390
+	public static function remove_get_action() {
391
+		if ( ! isset($_GET) ) {
392
+			return;
393
+		}
394 394
 
395
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
396
-        if ( ! empty( $new_action ) ) {
395
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
396
+		if ( ! empty( $new_action ) ) {
397 397
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
398
-        }
399
-    }
400
-
401
-    /**
402
-     * Check the WP query for a parameter
403
-     *
404
-     * @since 2.0
405
-     * @return string|array
406
-     */
407
-    public static function get_query_var( $value, $param ) {
408
-        if ( $value != '' ) {
409
-            return $value;
410
-        }
411
-
412
-        global $wp_query;
413
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
414
-            $value = $wp_query->query_vars[ $param ];
415
-        }
416
-
417
-        return $value;
418
-    }
419
-
420
-    /**
421
-     * @param string $type
422
-     */
423
-    public static function trigger_hook_load( $type, $object = null ) {
424
-        // only load the form hooks once
398
+		}
399
+	}
400
+
401
+	/**
402
+	 * Check the WP query for a parameter
403
+	 *
404
+	 * @since 2.0
405
+	 * @return string|array
406
+	 */
407
+	public static function get_query_var( $value, $param ) {
408
+		if ( $value != '' ) {
409
+			return $value;
410
+		}
411
+
412
+		global $wp_query;
413
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
414
+			$value = $wp_query->query_vars[ $param ];
415
+		}
416
+
417
+		return $value;
418
+	}
419
+
420
+	/**
421
+	 * @param string $type
422
+	 */
423
+	public static function trigger_hook_load( $type, $object = null ) {
424
+		// only load the form hooks once
425 425
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
426
-        if ( ! $hooks_loaded ) {
426
+		if ( ! $hooks_loaded ) {
427 427
 			do_action( 'frm_load_' . $type . '_hooks' );
428
-        }
429
-    }
430
-
431
-    /**
432
-     * Check cache before fetching values and saving to cache
433
-     *
434
-     * @since 2.0
435
-     *
436
-     * @param string $cache_key The unique name for this cache
437
-     * @param string $group The name of the cache group
438
-     * @param string $query If blank, don't run a db call
439
-     * @param string $type The wpdb function to use with this query
440
-     * @return mixed $results The cache or query results
441
-     */
442
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
443
-        $results = wp_cache_get($cache_key, $group);
444
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
445
-            return $results;
446
-        }
447
-
448
-        if ( 'get_posts' == $type ) {
449
-            $results = get_posts($query);
428
+		}
429
+	}
430
+
431
+	/**
432
+	 * Check cache before fetching values and saving to cache
433
+	 *
434
+	 * @since 2.0
435
+	 *
436
+	 * @param string $cache_key The unique name for this cache
437
+	 * @param string $group The name of the cache group
438
+	 * @param string $query If blank, don't run a db call
439
+	 * @param string $type The wpdb function to use with this query
440
+	 * @return mixed $results The cache or query results
441
+	 */
442
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
443
+		$results = wp_cache_get($cache_key, $group);
444
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
445
+			return $results;
446
+		}
447
+
448
+		if ( 'get_posts' == $type ) {
449
+			$results = get_posts($query);
450 450
 		} else if ( 'get_associative_results' == $type ) {
451 451
 			global $wpdb;
452 452
 			$results = $wpdb->get_results( $query, OBJECT_K );
453
-        } else {
454
-            global $wpdb;
455
-            $results = $wpdb->{$type}($query);
456
-        }
453
+		} else {
454
+			global $wpdb;
455
+			$results = $wpdb->{$type}($query);
456
+		}
457 457
 
458 458
 		if ( ! self::prevent_caching() ) {
459 459
 			wp_cache_set( $cache_key, $results, $group, $time );
460 460
 		}
461 461
 
462
-        return $results;
463
-    }
462
+		return $results;
463
+	}
464 464
 
465
-    /**
466
-     * Data that should be stored for a long time can be stored in a transient.
467
-     * First check the cache, then check the transient
468
-     * @since 2.0
469
-     * @return mixed The cached value or false
470
-     */
465
+	/**
466
+	 * Data that should be stored for a long time can be stored in a transient.
467
+	 * First check the cache, then check the transient
468
+	 * @since 2.0
469
+	 * @return mixed The cached value or false
470
+	 */
471 471
 	public static function check_cache_and_transient( $cache_key ) {
472
-        // check caching layer first
473
-        $results = self::check_cache( $cache_key );
474
-        if ( $results ) {
475
-            return $results;
476
-        }
477
-
478
-        // then check the transient
479
-        $results = get_transient($cache_key);
480
-        if ( $results ) {
481
-            wp_cache_set($cache_key, $results);
482
-        }
483
-
484
-        return $results;
485
-    }
486
-
487
-    /**
488
-     * @since 2.0
489
-     * @param string $cache_key
490
-     */
472
+		// check caching layer first
473
+		$results = self::check_cache( $cache_key );
474
+		if ( $results ) {
475
+			return $results;
476
+		}
477
+
478
+		// then check the transient
479
+		$results = get_transient($cache_key);
480
+		if ( $results ) {
481
+			wp_cache_set($cache_key, $results);
482
+		}
483
+
484
+		return $results;
485
+	}
486
+
487
+	/**
488
+	 * @since 2.0
489
+	 * @param string $cache_key
490
+	 */
491 491
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
492 492
 		delete_transient($cache_key);
493 493
 		wp_cache_delete( $cache_key, $group );
494 494
 	}
495 495
 
496
-    /**
497
-     * Delete all caching in a single group
498
-     *
499
-     * @since 2.0
500
-     *
501
-     * @param string $group The name of the cache group
502
-     * @return boolean True or False
503
-     */
496
+	/**
497
+	 * Delete all caching in a single group
498
+	 *
499
+	 * @since 2.0
500
+	 *
501
+	 * @param string $group The name of the cache group
502
+	 * @return boolean True or False
503
+	 */
504 504
 	public static function cache_delete_group( $group ) {
505
-    	global $wp_object_cache;
505
+		global $wp_object_cache;
506 506
 
507 507
 		if ( is_callable( array( $wp_object_cache, '__get' ) ) ) {
508 508
 			$group_cache = $wp_object_cache->__get('cache');
@@ -522,37 +522,37 @@  discard block
 block discarded – undo
522 522
 			return true;
523 523
 		}
524 524
 
525
-    	return false;
526
-    }
525
+		return false;
526
+	}
527 527
 
528
-    /**
529
-     * Check a value from a shortcode to see if true or false.
530
-     * True when value is 1, true, 'true', 'yes'
531
-     *
532
-     * @since 1.07.10
533
-     *
534
-     * @param string $value The value to compare
535
-     * @return boolean True or False
536
-     */
528
+	/**
529
+	 * Check a value from a shortcode to see if true or false.
530
+	 * True when value is 1, true, 'true', 'yes'
531
+	 *
532
+	 * @since 1.07.10
533
+	 *
534
+	 * @param string $value The value to compare
535
+	 * @return boolean True or False
536
+	 */
537 537
 	public static function is_true( $value ) {
538
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
539
-    }
538
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
539
+	}
540 540
 
541
-    /**
542
-     * Used to filter shortcode in text widgets
543
-     */
544
-    public static function widget_text_filter_callback( $matches ) {
545
-        return do_shortcode( $matches[0] );
546
-    }
541
+	/**
542
+	 * Used to filter shortcode in text widgets
543
+	 */
544
+	public static function widget_text_filter_callback( $matches ) {
545
+		return do_shortcode( $matches[0] );
546
+	}
547 547
 
548
-    public static function get_pages() {
548
+	public static function get_pages() {
549 549
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
550
-    }
550
+	}
551 551
 
552
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
553
-        $pages = self::get_pages();
552
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
553
+		$pages = self::get_pages();
554 554
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
555
-    ?>
555
+	?>
556 556
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
557 557
             <option value=""> </option>
558 558
             <?php foreach ( $pages as $page ) { ?>
@@ -562,108 +562,108 @@  discard block
 block discarded – undo
562 562
             <?php } ?>
563 563
         </select>
564 564
     <?php
565
-    }
565
+	}
566 566
 
567 567
 	public static function post_edit_link( $post_id ) {
568
-        $post = get_post($post_id);
569
-        if ( $post ) {
568
+		$post = get_post($post_id);
569
+		if ( $post ) {
570 570
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
571 571
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
572
-        }
573
-        return '';
574
-    }
572
+		}
573
+		return '';
574
+	}
575 575
 
576 576
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
577
-    ?>
577
+	?>
578 578
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
579
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
580
-            ?> class="frm_multiselect">
579
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
580
+			?> class="frm_multiselect">
581 581
             <?php self::roles_options($capability); ?>
582 582
         </select>
583 583
     <?php
584
-    }
584
+	}
585 585
 
586 586
 	public static function roles_options( $capability ) {
587
-        global $frm_vars;
588
-        if ( isset($frm_vars['editable_roles']) ) {
589
-            $editable_roles = $frm_vars['editable_roles'];
590
-        } else {
591
-            $editable_roles = get_editable_roles();
592
-            $frm_vars['editable_roles'] = $editable_roles;
593
-        }
594
-
595
-        foreach ( $editable_roles as $role => $details ) {
596
-            $name = translate_user_role($details['name'] ); ?>
587
+		global $frm_vars;
588
+		if ( isset($frm_vars['editable_roles']) ) {
589
+			$editable_roles = $frm_vars['editable_roles'];
590
+		} else {
591
+			$editable_roles = get_editable_roles();
592
+			$frm_vars['editable_roles'] = $editable_roles;
593
+		}
594
+
595
+		foreach ( $editable_roles as $role => $details ) {
596
+			$name = translate_user_role($details['name'] ); ?>
597 597
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
598 598
 <?php
599
-            unset($role, $details);
600
-        }
601
-    }
599
+			unset($role, $details);
600
+		}
601
+	}
602 602
 
603 603
 	public static function frm_capabilities( $type = 'auto' ) {
604
-        $cap = array(
605
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
606
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
607
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
608
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
609
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
610
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
611
-        );
604
+		$cap = array(
605
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
606
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
607
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
608
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
609
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
610
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
611
+		);
612 612
 
613 613
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
614
-            return $cap;
615
-        }
614
+			return $cap;
615
+		}
616 616
 
617
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
618
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
619
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
620
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
617
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
618
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
619
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
620
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
621 621
 
622
-        return $cap;
623
-    }
622
+		return $cap;
623
+	}
624 624
 
625 625
 	public static function user_has_permission( $needed_role ) {
626
-        if ( $needed_role == '-1' ) {
627
-            return false;
626
+		if ( $needed_role == '-1' ) {
627
+			return false;
628 628
 		}
629 629
 
630
-        // $needed_role will be equal to blank if "Logged-in users" is selected
631
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
632
-            return true;
633
-        }
630
+		// $needed_role will be equal to blank if "Logged-in users" is selected
631
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
632
+			return true;
633
+		}
634 634
 
635
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
636
-        foreach ( $roles as $role ) {
635
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
636
+		foreach ( $roles as $role ) {
637 637
 			if ( current_user_can( $role ) ) {
638
-        		return true;
638
+				return true;
639 639
 			}
640
-        	if ( $role == $needed_role ) {
641
-        		break;
640
+			if ( $role == $needed_role ) {
641
+				break;
642 642
 			}
643
-        }
644
-        return false;
645
-    }
646
-
647
-    /**
648
-     * Make sure administrators can see Formidable menu
649
-     *
650
-     * @since 2.0
651
-     */
652
-    public static function maybe_add_permissions() {
643
+		}
644
+		return false;
645
+	}
646
+
647
+	/**
648
+	 * Make sure administrators can see Formidable menu
649
+	 *
650
+	 * @since 2.0
651
+	 */
652
+	public static function maybe_add_permissions() {
653 653
 		self::force_capability( 'frm_view_entries' );
654 654
 
655
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
656
-            return;
657
-        }
655
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
656
+			return;
657
+		}
658 658
 
659 659
 		$user_id = get_current_user_id();
660 660
 		$user = new WP_User( $user_id );
661
-        $frm_roles = self::frm_capabilities();
662
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
661
+		$frm_roles = self::frm_capabilities();
662
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
663 663
 			$user->add_cap( $frm_role );
664
-            unset($frm_role, $frm_role_description);
665
-        }
666
-    }
664
+			unset($frm_role, $frm_role_description);
665
+		}
666
+	}
667 667
 
668 668
 	/**
669 669
 	 * Make sure admins have permission to see the menu items
@@ -679,28 +679,28 @@  discard block
 block discarded – undo
679 679
 		}
680 680
 	}
681 681
 
682
-    /**
683
-     * Check if the user has permision for action.
684
-     * Return permission message and stop the action if no permission
685
-     * @since 2.0
686
-     * @param string $permission
687
-     */
682
+	/**
683
+	 * Check if the user has permision for action.
684
+	 * Return permission message and stop the action if no permission
685
+	 * @since 2.0
686
+	 * @param string $permission
687
+	 */
688 688
 	public static function permission_check( $permission, $show_message = 'show' ) {
689
-        $permission_error = self::permission_nonce_error($permission);
690
-        if ( $permission_error !== false ) {
691
-            if ( 'hide' == $show_message ) {
692
-                $permission_error = '';
693
-            }
694
-            wp_die($permission_error);
695
-        }
696
-    }
697
-
698
-    /**
699
-     * Check user permission and nonce
700
-     * @since 2.0
701
-     * @param string $permission
702
-     * @return false|string The permission message or false if allowed
703
-     */
689
+		$permission_error = self::permission_nonce_error($permission);
690
+		if ( $permission_error !== false ) {
691
+			if ( 'hide' == $show_message ) {
692
+				$permission_error = '';
693
+			}
694
+			wp_die($permission_error);
695
+		}
696
+	}
697
+
698
+	/**
699
+	 * Check user permission and nonce
700
+	 * @since 2.0
701
+	 * @param string $permission
702
+	 * @return false|string The permission message or false if allowed
703
+	 */
704 704
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
705 705
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
706 706
 			$frm_settings = self::get_settings();
@@ -708,23 +708,23 @@  discard block
 block discarded – undo
708 708
 		}
709 709
 
710 710
 		$error = false;
711
-        if ( empty($nonce_name) ) {
712
-            return $error;
713
-        }
711
+		if ( empty($nonce_name) ) {
712
+			return $error;
713
+		}
714 714
 
715
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
716
-            $frm_settings = self::get_settings();
717
-            $error = $frm_settings->admin_permission;
718
-        }
715
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
716
+			$frm_settings = self::get_settings();
717
+			$error = $frm_settings->admin_permission;
718
+		}
719 719
 
720
-        return $error;
721
-    }
720
+		return $error;
721
+	}
722 722
 
723
-    public static function checked( $values, $current ) {
723
+	public static function checked( $values, $current ) {
724 724
 		if ( self::check_selected( $values, $current ) ) {
725
-            echo ' checked="checked"';
725
+			echo ' checked="checked"';
726 726
 		}
727
-    }
727
+	}
728 728
 
729 729
 	public static function check_selected( $values, $current ) {
730 730
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -734,50 +734,50 @@  discard block
 block discarded – undo
734 734
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
735 735
 	}
736 736
 
737
-    /**
738
-    * Check if current field option is an "other" option
739
-    *
740
-    * @since 2.0
741
-    *
742
-    * @param string $opt_key
743
-    * @return boolean Returns true if current field option is an "Other" option
744
-    */
745
-    public static function is_other_opt( $opt_key ) {
746
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
747
-        return FrmFieldsHelper::is_other_opt( $opt_key );
748
-    }
749
-
750
-    /**
751
-    * Get value that belongs in "Other" text box
752
-    *
753
-    * @since 2.0
754
-    *
755
-    * @param string $opt_key
756
-    * @param array $field
757
-    * @return string $other_val
758
-    */
759
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
737
+	/**
738
+	 * Check if current field option is an "other" option
739
+	 *
740
+	 * @since 2.0
741
+	 *
742
+	 * @param string $opt_key
743
+	 * @return boolean Returns true if current field option is an "Other" option
744
+	 */
745
+	public static function is_other_opt( $opt_key ) {
746
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
747
+		return FrmFieldsHelper::is_other_opt( $opt_key );
748
+	}
749
+
750
+	/**
751
+	 * Get value that belongs in "Other" text box
752
+	 *
753
+	 * @since 2.0
754
+	 *
755
+	 * @param string $opt_key
756
+	 * @param array $field
757
+	 * @return string $other_val
758
+	 */
759
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
760 760
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
761 761
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
762
-    }
763
-
764
-    /**
765
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
766
-    * Intended for front-end use
767
-    *
768
-    * @since 2.0
769
-    *
770
-    * @param array $field
771
-    * @param boolean $other_opt
772
-    * @param string $checked
773
-    * @param array $args should include opt_key and field name
774
-    * @return string $other_val
775
-    */
776
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
762
+	}
763
+
764
+	/**
765
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
766
+	 * Intended for front-end use
767
+	 *
768
+	 * @since 2.0
769
+	 *
770
+	 * @param array $field
771
+	 * @param boolean $other_opt
772
+	 * @param string $checked
773
+	 * @param array $args should include opt_key and field name
774
+	 * @return string $other_val
775
+	 */
776
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
777 777
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
778 778
 		$args['field'] = $field;
779 779
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
780
-    }
780
+	}
781 781
 
782 782
 	public static function recursive_function_map( $value, $function ) {
783 783
 		if ( is_array( $value ) ) {
@@ -807,24 +807,24 @@  discard block
 block discarded – undo
807 807
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
808 808
 	}
809 809
 
810
-    /**
811
-     * Flatten a multi-dimensional array
812
-     */
810
+	/**
811
+	 * Flatten a multi-dimensional array
812
+	 */
813 813
 	public static function array_flatten( $array, $keys = 'keep' ) {
814
-        $return = array();
815
-        foreach ( $array as $key => $value ) {
816
-            if ( is_array($value) ) {
814
+		$return = array();
815
+		foreach ( $array as $key => $value ) {
816
+			if ( is_array($value) ) {
817 817
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
818
-            } else {
818
+			} else {
819 819
 				if ( $keys == 'keep' ) {
820 820
 					$return[ $key ] = $value;
821 821
 				} else {
822 822
 					$return[] = $value;
823 823
 				}
824
-            }
825
-        }
826
-        return $return;
827
-    }
824
+			}
825
+		}
826
+		return $return;
827
+	}
828 828
 
829 829
 	public static function esc_textarea( $text, $is_rich_text = false ) {
830 830
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -835,308 +835,308 @@  discard block
 block discarded – undo
835 835
 		return apply_filters( 'esc_textarea', $safe_text, $text );
836 836
 	}
837 837
 
838
-    /**
839
-     * Add auto paragraphs to text areas
840
-     * @since 2.0
841
-     */
838
+	/**
839
+	 * Add auto paragraphs to text areas
840
+	 * @since 2.0
841
+	 */
842 842
 	public static function use_wpautop( $content ) {
843
-        if ( apply_filters('frm_use_wpautop', true) ) {
844
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
845
-        }
846
-        return $content;
847
-    }
843
+		if ( apply_filters('frm_use_wpautop', true) ) {
844
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
845
+		}
846
+		return $content;
847
+	}
848 848
 
849 849
 	public static function replace_quotes( $val ) {
850
-        //Replace double quotes
850
+		//Replace double quotes
851 851
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
852
-        //Replace single quotes
853
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
854
-        return $val;
855
-    }
856
-
857
-    /**
858
-     * @since 2.0
859
-     * @return string The base Google APIS url for the current version of jQuery UI
860
-     */
861
-    public static function jquery_ui_base_url() {
852
+		//Replace single quotes
853
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
854
+		return $val;
855
+	}
856
+
857
+	/**
858
+	 * @since 2.0
859
+	 * @return string The base Google APIS url for the current version of jQuery UI
860
+	 */
861
+	public static function jquery_ui_base_url() {
862 862
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
863
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
864
-        return $url;
865
-    }
863
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
864
+		return $url;
865
+	}
866 866
 
867
-    /**
868
-     * @param string $handle
869
-     */
867
+	/**
868
+	 * @param string $handle
869
+	 */
870 870
 	public static function script_version( $handle ) {
871
-        global $wp_scripts;
872
-    	if ( ! $wp_scripts ) {
873
-    	    return false;
874
-    	}
871
+		global $wp_scripts;
872
+		if ( ! $wp_scripts ) {
873
+			return false;
874
+		}
875 875
 
876
-        $ver = 0;
876
+		$ver = 0;
877 877
 
878
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
879
-            return $ver;
880
-        }
878
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
879
+			return $ver;
880
+		}
881 881
 
882
-        $query = $wp_scripts->registered[ $handle ];
883
-    	if ( is_object( $query ) ) {
884
-    	    $ver = $query->ver;
885
-    	}
882
+		$query = $wp_scripts->registered[ $handle ];
883
+		if ( is_object( $query ) ) {
884
+			$ver = $query->ver;
885
+		}
886 886
 
887
-    	return $ver;
888
-    }
887
+		return $ver;
888
+	}
889 889
 
890 890
 	public static function js_redirect( $url ) {
891 891
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
892
-    }
892
+	}
893 893
 
894 894
 	public static function get_user_id_param( $user_id ) {
895
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
896
-            return $user_id;
897
-        }
895
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
896
+			return $user_id;
897
+		}
898 898
 
899 899
 		if ( $user_id == 'current' ) {
900 900
 			$user_id = get_current_user_id();
901 901
 		} else {
902
-            if ( is_email($user_id) ) {
903
-                $user = get_user_by('email', $user_id);
904
-            } else {
905
-                $user = get_user_by('login', $user_id);
906
-            }
902
+			if ( is_email($user_id) ) {
903
+				$user = get_user_by('email', $user_id);
904
+			} else {
905
+				$user = get_user_by('login', $user_id);
906
+			}
907 907
 
908
-            if ( $user ) {
909
-                $user_id = $user->ID;
910
-            }
911
-            unset($user);
912
-        }
908
+			if ( $user ) {
909
+				$user_id = $user->ID;
910
+			}
911
+			unset($user);
912
+		}
913 913
 
914
-        return $user_id;
915
-    }
914
+		return $user_id;
915
+	}
916 916
 
917 917
 	public static function get_file_contents( $filename, $atts = array() ) {
918
-        if ( ! is_file($filename) ) {
919
-            return false;
920
-        }
921
-
922
-        extract($atts);
923
-        ob_start();
924
-        include($filename);
925
-        $contents = ob_get_contents();
926
-        ob_end_clean();
927
-        return $contents;
928
-    }
929
-
930
-    /**
931
-     * @param string $table_name
932
-     * @param string $column
918
+		if ( ! is_file($filename) ) {
919
+			return false;
920
+		}
921
+
922
+		extract($atts);
923
+		ob_start();
924
+		include($filename);
925
+		$contents = ob_get_contents();
926
+		ob_end_clean();
927
+		return $contents;
928
+	}
929
+
930
+	/**
931
+	 * @param string $table_name
932
+	 * @param string $column
933 933
 	 * @param int $id
934 934
 	 * @param int $num_chars
935
-     */
936
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
937
-        $key = '';
935
+	 */
936
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
937
+		$key = '';
938 938
 
939
-        if ( ! empty( $name ) ) {
940
-            $key = sanitize_key($name);
941
-        }
939
+		if ( ! empty( $name ) ) {
940
+			$key = sanitize_key($name);
941
+		}
942 942
 
943 943
 		if ( empty( $key ) ) {
944
-            $max_slug_value = pow(36, $num_chars);
945
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
946
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
947
-        }
944
+			$max_slug_value = pow(36, $num_chars);
945
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
946
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
947
+		}
948 948
 
949 949
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
950 950
 			$key = $key . 'a';
951
-        }
951
+		}
952 952
 
953 953
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
954 954
 
955
-        if ( $key_check || is_numeric($key_check) ) {
956
-            $suffix = 2;
955
+		if ( $key_check || is_numeric($key_check) ) {
956
+			$suffix = 2;
957 957
 			do {
958 958
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
959 959
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
960 960
 				$suffix++;
961 961
 			} while ($key_check || is_numeric($key_check));
962 962
 			$key = $alt_post_name;
963
-        }
964
-        return $key;
965
-    }
966
-
967
-    /**
968
-     * Editing a Form or Entry
969
-     * @param string $table
970
-     * @return bool|array
971
-     */
972
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
973
-        if ( ! $record ) {
974
-            return false;
975
-        }
976
-
977
-        if ( empty($post_values) ) {
978
-            $post_values = stripslashes_deep($_POST);
979
-        }
963
+		}
964
+		return $key;
965
+	}
966
+
967
+	/**
968
+	 * Editing a Form or Entry
969
+	 * @param string $table
970
+	 * @return bool|array
971
+	 */
972
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
973
+		if ( ! $record ) {
974
+			return false;
975
+		}
976
+
977
+		if ( empty($post_values) ) {
978
+			$post_values = stripslashes_deep($_POST);
979
+		}
980 980
 
981 981
 		$values = array( 'id' => $record->id, 'fields' => array() );
982 982
 
983 983
 		foreach ( array( 'name', 'description' ) as $var ) {
984
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
984
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
985 985
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
986
-            unset($var, $default_val);
987
-        }
988
-
989
-        $values['description'] = self::use_wpautop($values['description']);
990
-        $frm_settings = self::get_settings();
991
-        $is_form_builder = self::is_admin_page('formidable' );
992
-
993
-        foreach ( (array) $fields as $field ) {
994
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
995
-            if ( ! $is_form_builder ) {
996
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
997
-            }
986
+			unset($var, $default_val);
987
+		}
988
+
989
+		$values['description'] = self::use_wpautop($values['description']);
990
+		$frm_settings = self::get_settings();
991
+		$is_form_builder = self::is_admin_page('formidable' );
992
+
993
+		foreach ( (array) $fields as $field ) {
994
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
995
+			if ( ! $is_form_builder ) {
996
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
997
+			}
998 998
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
999 999
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1000
-        }
1000
+		}
1001 1001
 
1002
-        self::fill_form_opts($record, $table, $post_values, $values);
1002
+		self::fill_form_opts($record, $table, $post_values, $values);
1003 1003
 
1004
-        if ( $table == 'entries' ) {
1005
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1006
-        } else if ( $table == 'forms' ) {
1007
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1008
-        }
1004
+		if ( $table == 'entries' ) {
1005
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1006
+		} else if ( $table == 'forms' ) {
1007
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1008
+		}
1009 1009
 
1010
-        return $values;
1011
-    }
1010
+		return $values;
1011
+	}
1012 1012
 
1013 1013
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1014
-        $post_values = $args['post_values'];
1015
-
1016
-        if ( $args['default'] ) {
1017
-            $meta_value = $field->default_value;
1018
-        } else {
1019
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1020
-                if ( ! isset($field->field_options['custom_field']) ) {
1021
-                    $field->field_options['custom_field'] = '';
1022
-                }
1014
+		$post_values = $args['post_values'];
1015
+
1016
+		if ( $args['default'] ) {
1017
+			$meta_value = $field->default_value;
1018
+		} else {
1019
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1020
+				if ( ! isset($field->field_options['custom_field']) ) {
1021
+					$field->field_options['custom_field'] = '';
1022
+				}
1023 1023
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
1024
-            } else {
1024
+			} else {
1025 1025
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1026
-            }
1027
-        }
1026
+			}
1027
+		}
1028 1028
 
1029 1029
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1030
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
-
1032
-        $field_array = array(
1033
-            'id'            => $field->id,
1034
-            'value'         => $new_value,
1035
-            'default_value' => $field->default_value,
1036
-            'name'          => $field->name,
1037
-            'description'   => $field->description,
1038
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1039
-            'options'       => $field->options,
1040
-            'required'      => $field->required,
1041
-            'field_key'     => $field->field_key,
1042
-            'field_order'   => $field->field_order,
1043
-            'form_id'       => $field->form_id,
1030
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
+
1032
+		$field_array = array(
1033
+			'id'            => $field->id,
1034
+			'value'         => $new_value,
1035
+			'default_value' => $field->default_value,
1036
+			'name'          => $field->name,
1037
+			'description'   => $field->description,
1038
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1039
+			'options'       => $field->options,
1040
+			'required'      => $field->required,
1041
+			'field_key'     => $field->field_key,
1042
+			'field_order'   => $field->field_order,
1043
+			'form_id'       => $field->form_id,
1044 1044
 			'parent_form_id' => $args['parent_form_id'],
1045
-        );
1045
+		);
1046 1046
 
1047
-        $args['field_type'] = $field_type;
1048
-        self::fill_field_opts($field, $field_array, $args);
1047
+		$args['field_type'] = $field_type;
1048
+		self::fill_field_opts($field, $field_array, $args);
1049 1049
 		// Track the original field's type
1050 1050
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1051 1051
 
1052
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1052
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1053 1053
 
1054
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1055
-            $field_array['unique_msg'] = '';
1056
-        }
1054
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1055
+			$field_array['unique_msg'] = '';
1056
+		}
1057 1057
 
1058
-        $field_array = array_merge( $field->field_options, $field_array );
1058
+		$field_array = array_merge( $field->field_options, $field_array );
1059 1059
 
1060
-        $values['fields'][ $field->id ] = $field_array;
1061
-    }
1060
+		$values['fields'][ $field->id ] = $field_array;
1061
+	}
1062 1062
 
1063 1063
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1064
-        $post_values = $args['post_values'];
1065
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1064
+		$post_values = $args['post_values'];
1065
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1066 1066
 
1067
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1067
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1068 1068
 			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1069
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1070
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1071
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1072
-                if ( $args['field_type'] == 'captcha' ) {
1073
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1074
-                } else {
1075
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1076
-                }
1077
-            }
1078
-        }
1079
-
1080
-        if ( $field_array['custom_html'] == '' ) {
1081
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1082
-        }
1083
-    }
1084
-
1085
-    /**
1086
-     * @param string $table
1087
-     */
1069
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1070
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1071
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1072
+				if ( $args['field_type'] == 'captcha' ) {
1073
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1074
+				} else {
1075
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1076
+				}
1077
+			}
1078
+		}
1079
+
1080
+		if ( $field_array['custom_html'] == '' ) {
1081
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1082
+		}
1083
+	}
1084
+
1085
+	/**
1086
+	 * @param string $table
1087
+	 */
1088 1088
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1089
-        if ( $table == 'entries' ) {
1090
-            $form = $record->form_id;
1089
+		if ( $table == 'entries' ) {
1090
+			$form = $record->form_id;
1091 1091
 			FrmForm::maybe_get_form( $form );
1092
-        } else {
1093
-            $form = $record;
1094
-        }
1092
+		} else {
1093
+			$form = $record;
1094
+		}
1095 1095
 
1096
-        if ( ! $form ) {
1097
-            return;
1098
-        }
1096
+		if ( ! $form ) {
1097
+			return;
1098
+		}
1099 1099
 
1100
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1100
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1101 1101
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1102 1102
 
1103
-        if ( ! is_array($form->options) ) {
1104
-            return;
1105
-        }
1103
+		if ( ! is_array($form->options) ) {
1104
+			return;
1105
+		}
1106 1106
 
1107
-        foreach ( $form->options as $opt => $value ) {
1108
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1109
-        }
1107
+		foreach ( $form->options as $opt => $value ) {
1108
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1109
+		}
1110 1110
 
1111
-        self::fill_form_defaults($post_values, $values);
1112
-    }
1111
+		self::fill_form_defaults($post_values, $values);
1112
+	}
1113 1113
 
1114
-    /**
1115
-     * Set to POST value or default
1116
-     */
1114
+	/**
1115
+	 * Set to POST value or default
1116
+	 */
1117 1117
 	private static function fill_form_defaults( $post_values, array &$values ) {
1118
-        $form_defaults = FrmFormsHelper::get_default_opts();
1118
+		$form_defaults = FrmFormsHelper::get_default_opts();
1119 1119
 
1120
-        foreach ( $form_defaults as $opt => $default ) {
1121
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1120
+		foreach ( $form_defaults as $opt => $default ) {
1121
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1122 1122
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1123
-            }
1123
+			}
1124 1124
 
1125
-            unset($opt, $defaut);
1126
-        }
1125
+			unset($opt, $defaut);
1126
+		}
1127 1127
 
1128
-        if ( ! isset($values['custom_style']) ) {
1129
-            $frm_settings = self::get_settings();
1128
+		if ( ! isset($values['custom_style']) ) {
1129
+			$frm_settings = self::get_settings();
1130 1130
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1131
-        }
1131
+		}
1132 1132
 
1133 1133
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1134 1134
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1135 1135
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1136
-            }
1137
-            unset($h);
1138
-        }
1139
-    }
1136
+			}
1137
+			unset($h);
1138
+		}
1139
+	}
1140 1140
 
1141 1141
 	public static function get_meta_value( $field_id, $entry ) {
1142 1142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1144,59 +1144,59 @@  discard block
 block discarded – undo
1144 1144
 	}
1145 1145
 
1146 1146
 	public static function insert_opt_html( $args ) {
1147
-        $class = '';
1148
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1149
-            $class .= 'show_frm_not_email_to';
1150
-        }
1151
-    ?>
1147
+		$class = '';
1148
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1149
+			$class .= 'show_frm_not_email_to';
1150
+		}
1151
+	?>
1152 1152
 <li>
1153 1153
     <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>
1154 1154
     <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>
1155 1155
     <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>
1156 1156
 </li>
1157 1157
     <?php
1158
-    }
1158
+	}
1159 1159
 
1160 1160
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1161
-        if ( is_array( $str ) ) {
1162
-            return '';
1161
+		if ( is_array( $str ) ) {
1162
+			return '';
1163 1163
 		}
1164 1164
 
1165
-        $length = (int) $length;
1165
+		$length = (int) $length;
1166 1166
 		$str = wp_strip_all_tags( $str );
1167 1167
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1168 1168
 
1169 1169
 		if ( $length == 0 ) {
1170
-            return '';
1171
-        } else if ( $length <= 10 ) {
1170
+			return '';
1171
+		} else if ( $length <= 10 ) {
1172 1172
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1173
-            return $sub . (($length < $original_len) ? $continue : '');
1174
-        }
1173
+			return $sub . (($length < $original_len) ? $continue : '');
1174
+		}
1175 1175
 
1176
-        $sub = '';
1177
-        $len = 0;
1176
+		$sub = '';
1177
+		$len = 0;
1178 1178
 
1179 1179
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1180 1180
 
1181 1181
 		foreach ( $words as $word ) {
1182
-            $part = (($sub != '') ? ' ' : '') . $word;
1182
+			$part = (($sub != '') ? ' ' : '') . $word;
1183 1183
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1184
-            if ( $total_len > $length && str_word_count($sub) ) {
1185
-                break;
1186
-            }
1184
+			if ( $total_len > $length && str_word_count($sub) ) {
1185
+				break;
1186
+			}
1187 1187
 
1188
-            $sub .= $part;
1188
+			$sub .= $part;
1189 1189
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1190 1190
 
1191
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1192
-                break;
1193
-            }
1191
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1192
+				break;
1193
+			}
1194 1194
 
1195
-            unset($total_len, $word);
1196
-        }
1195
+			unset($total_len, $word);
1196
+		}
1197 1197
 
1198
-        return $sub . (($len < $original_len) ? $continue : '');
1199
-    }
1198
+		return $sub . (($len < $original_len) ? $continue : '');
1199
+	}
1200 1200
 
1201 1201
 	public static function mb_function( $function_names, $args ) {
1202 1202
 		$mb_function_name = $function_names[0];
@@ -1208,18 +1208,18 @@  discard block
 block discarded – undo
1208 1208
 	}
1209 1209
 
1210 1210
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1211
-        if ( empty($date) ) {
1212
-            return $date;
1213
-        }
1211
+		if ( empty($date) ) {
1212
+			return $date;
1213
+		}
1214 1214
 
1215
-        if ( empty($date_format) ) {
1216
-            $date_format = get_option('date_format');
1217
-        }
1215
+		if ( empty($date_format) ) {
1216
+			$date_format = get_option('date_format');
1217
+		}
1218 1218
 
1219
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1220
-            $frmpro_settings = new FrmProSettings();
1221
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1222
-        }
1219
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1220
+			$frmpro_settings = new FrmProSettings();
1221
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1222
+		}
1223 1223
 
1224 1224
 		$formatted = self::get_localized_date( $date_format, $date );
1225 1225
 
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 			$formatted .= self::add_time_to_date( $time_format, $date );
1229 1229
 		}
1230 1230
 
1231
-        return $formatted;
1232
-    }
1231
+		return $formatted;
1232
+	}
1233 1233
 
1234 1234
 	private static function add_time_to_date( $time_format, $date ) {
1235 1235
 		if ( empty( $time_format ) ) {
@@ -1310,61 +1310,61 @@  discard block
 block discarded – undo
1310 1310
 		);
1311 1311
 	}
1312 1312
 
1313
-    /**
1314
-     * Added for < WP 4.0 compatability
1315
-     *
1316
-     * @since 1.07.10
1317
-     *
1318
-     * @param string $term The value to escape
1319
-     * @return string The escaped value
1320
-     */
1313
+	/**
1314
+	 * Added for < WP 4.0 compatability
1315
+	 *
1316
+	 * @since 1.07.10
1317
+	 *
1318
+	 * @param string $term The value to escape
1319
+	 * @return string The escaped value
1320
+	 */
1321 1321
 	public static function esc_like( $term ) {
1322
-        global $wpdb;
1323
-        if ( method_exists($wpdb, 'esc_like') ) {
1322
+		global $wpdb;
1323
+		if ( method_exists($wpdb, 'esc_like') ) {
1324 1324
 			// WP 4.0
1325
-            $term = $wpdb->esc_like( $term );
1326
-        } else {
1327
-            $term = like_escape( $term );
1328
-        }
1325
+			$term = $wpdb->esc_like( $term );
1326
+		} else {
1327
+			$term = like_escape( $term );
1328
+		}
1329 1329
 
1330
-        return $term;
1331
-    }
1330
+		return $term;
1331
+	}
1332 1332
 
1333
-    /**
1334
-     * @param string $order_query
1335
-     */
1333
+	/**
1334
+	 * @param string $order_query
1335
+	 */
1336 1336
 	public static function esc_order( $order_query ) {
1337
-        if ( empty($order_query) ) {
1338
-            return '';
1339
-        }
1340
-
1341
-        // remove ORDER BY before santizing
1342
-        $order_query = strtolower($order_query);
1343
-        if ( strpos($order_query, 'order by') !== false ) {
1344
-            $order_query = str_replace('order by', '', $order_query);
1345
-        }
1346
-
1347
-        $order_query = explode(' ', trim($order_query));
1348
-
1349
-        $order_fields = array(
1350
-            'id', 'form_key', 'name', 'description',
1351
-            'parent_form_id', 'logged_in', 'is_template',
1352
-            'default_template', 'status', 'created_at',
1353
-        );
1354
-
1355
-        $order = trim(trim(reset($order_query), ','));
1356
-        if ( ! in_array($order, $order_fields) ) {
1357
-            return '';
1358
-        }
1359
-
1360
-        $order_by = '';
1361
-        if ( count($order_query) > 1 ) {
1337
+		if ( empty($order_query) ) {
1338
+			return '';
1339
+		}
1340
+
1341
+		// remove ORDER BY before santizing
1342
+		$order_query = strtolower($order_query);
1343
+		if ( strpos($order_query, 'order by') !== false ) {
1344
+			$order_query = str_replace('order by', '', $order_query);
1345
+		}
1346
+
1347
+		$order_query = explode(' ', trim($order_query));
1348
+
1349
+		$order_fields = array(
1350
+			'id', 'form_key', 'name', 'description',
1351
+			'parent_form_id', 'logged_in', 'is_template',
1352
+			'default_template', 'status', 'created_at',
1353
+		);
1354
+
1355
+		$order = trim(trim(reset($order_query), ','));
1356
+		if ( ! in_array($order, $order_fields) ) {
1357
+			return '';
1358
+		}
1359
+
1360
+		$order_by = '';
1361
+		if ( count($order_query) > 1 ) {
1362 1362
 			$order_by = end( $order_query );
1363 1363
 			self::esc_order_by( $order_by );
1364
-        }
1364
+		}
1365 1365
 
1366 1366
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1367
-    }
1367
+	}
1368 1368
 
1369 1369
 	/**
1370 1370
 	 * Make sure this is ordering by either ASC or DESC
@@ -1376,169 +1376,169 @@  discard block
 block discarded – undo
1376 1376
 		}
1377 1377
 	}
1378 1378
 
1379
-    /**
1380
-     * @param string $limit
1381
-     */
1379
+	/**
1380
+	 * @param string $limit
1381
+	 */
1382 1382
 	public static function esc_limit( $limit ) {
1383
-        if ( empty($limit) ) {
1384
-            return '';
1385
-        }
1383
+		if ( empty($limit) ) {
1384
+			return '';
1385
+		}
1386 1386
 
1387
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1388
-        if ( is_numeric($limit) ) {
1387
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1388
+		if ( is_numeric($limit) ) {
1389 1389
 			return ' LIMIT ' . $limit;
1390
-        }
1390
+		}
1391 1391
 
1392
-        $limit = explode(',', trim($limit));
1393
-        foreach ( $limit as $k => $l ) {
1394
-            if ( is_numeric( $l ) ) {
1395
-                $limit[ $k ] = $l;
1396
-            }
1397
-        }
1392
+		$limit = explode(',', trim($limit));
1393
+		foreach ( $limit as $k => $l ) {
1394
+			if ( is_numeric( $l ) ) {
1395
+				$limit[ $k ] = $l;
1396
+			}
1397
+		}
1398 1398
 
1399
-        $limit = implode(',', $limit);
1399
+		$limit = implode(',', $limit);
1400 1400
 		return ' LIMIT ' . $limit;
1401
-    }
1402
-
1403
-    /**
1404
-     * Get an array of values ready to go through $wpdb->prepare
1405
-     * @since 2.0
1406
-     */
1407
-    public static function prepare_array_values( $array, $type = '%s' ) {
1408
-        $placeholders = array_fill(0, count($array), $type);
1409
-        return implode(', ', $placeholders);
1410
-    }
1411
-
1412
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1413
-        if ( empty($where) ) {
1414
-            return '';
1415
-        }
1401
+	}
1402
+
1403
+	/**
1404
+	 * Get an array of values ready to go through $wpdb->prepare
1405
+	 * @since 2.0
1406
+	 */
1407
+	public static function prepare_array_values( $array, $type = '%s' ) {
1408
+		$placeholders = array_fill(0, count($array), $type);
1409
+		return implode(', ', $placeholders);
1410
+	}
1411
+
1412
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1413
+		if ( empty($where) ) {
1414
+			return '';
1415
+		}
1416 1416
 
1417 1417
 		if ( is_array( $where ) ) {
1418
-            global $wpdb;
1419
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1418
+			global $wpdb;
1419
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1420 1420
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1421 1421
 		} else {
1422
-            $where = $starts_with . $where;
1423
-        }
1422
+			$where = $starts_with . $where;
1423
+		}
1424 1424
 
1425
-        return $where;
1426
-    }
1425
+		return $where;
1426
+	}
1427 1427
 
1428
-    // Pagination Methods
1428
+	// Pagination Methods
1429 1429
 
1430
-    /**
1431
-     * @param integer $current_p
1432
-     */
1430
+	/**
1431
+	 * @param integer $current_p
1432
+	 */
1433 1433
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1434 1434
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1435 1435
 	}
1436 1436
 
1437
-    /**
1438
-     * @param integer $current_p
1439
-     */
1440
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1441
-        if ( $current_p == 1 ) {
1442
-            return 1;
1443
-        } else {
1444
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1445
-        }
1446
-    }
1437
+	/**
1438
+	 * @param integer $current_p
1439
+	 */
1440
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1441
+		if ( $current_p == 1 ) {
1442
+			return 1;
1443
+		} else {
1444
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1445
+		}
1446
+	}
1447 1447
 
1448 1448
 	/**
1449 1449
 	 * @return array
1450 1450
 	 */
1451 1451
 	public static function json_to_array( $json_vars ) {
1452
-        $vars = array();
1453
-        foreach ( $json_vars as $jv ) {
1454
-            $jv_name = explode('[', $jv['name']);
1455
-            $last = count($jv_name) - 1;
1456
-            foreach ( $jv_name as $p => $n ) {
1457
-                $name = trim($n, ']');
1458
-                if ( ! isset($l1) ) {
1459
-                    $l1 = $name;
1460
-                }
1461
-
1462
-                if ( ! isset($l2) ) {
1463
-                    $l2 = $name;
1464
-                }
1465
-
1466
-                if ( ! isset($l3) ) {
1467
-                    $l3 = $name;
1468
-                }
1469
-
1470
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1471
-
1472
-                switch ( $p ) {
1473
-                    case 0:
1474
-                        $l1 = $name;
1475
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1476
-                    break;
1477
-
1478
-                    case 1:
1479
-                        $l2 = $name;
1480
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1481
-                    break;
1482
-
1483
-                    case 2:
1484
-                        $l3 = $name;
1485
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1486
-                    break;
1487
-
1488
-                    case 3:
1489
-                        $l4 = $name;
1490
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1491
-                    break;
1492
-                }
1493
-
1494
-                unset($this_val, $n);
1495
-            }
1496
-
1497
-            unset($last, $jv);
1498
-        }
1499
-
1500
-        return $vars;
1501
-    }
1502
-
1503
-    /**
1504
-     * @param string $name
1505
-     * @param string $l1
1506
-     */
1507
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1508
-        if ( $name == '' ) {
1509
-            $vars[] = $val;
1510
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1511
-            $vars[ $l1 ] = $val;
1512
-        }
1513
-    }
1452
+		$vars = array();
1453
+		foreach ( $json_vars as $jv ) {
1454
+			$jv_name = explode('[', $jv['name']);
1455
+			$last = count($jv_name) - 1;
1456
+			foreach ( $jv_name as $p => $n ) {
1457
+				$name = trim($n, ']');
1458
+				if ( ! isset($l1) ) {
1459
+					$l1 = $name;
1460
+				}
1461
+
1462
+				if ( ! isset($l2) ) {
1463
+					$l2 = $name;
1464
+				}
1465
+
1466
+				if ( ! isset($l3) ) {
1467
+					$l3 = $name;
1468
+				}
1469
+
1470
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1471
+
1472
+				switch ( $p ) {
1473
+					case 0:
1474
+						$l1 = $name;
1475
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1476
+					break;
1477
+
1478
+					case 1:
1479
+						$l2 = $name;
1480
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1481
+					break;
1482
+
1483
+					case 2:
1484
+						$l3 = $name;
1485
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1486
+					break;
1487
+
1488
+					case 3:
1489
+						$l4 = $name;
1490
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1491
+					break;
1492
+				}
1493
+
1494
+				unset($this_val, $n);
1495
+			}
1496
+
1497
+			unset($last, $jv);
1498
+		}
1499
+
1500
+		return $vars;
1501
+	}
1502
+
1503
+	/**
1504
+	 * @param string $name
1505
+	 * @param string $l1
1506
+	 */
1507
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1508
+		if ( $name == '' ) {
1509
+			$vars[] = $val;
1510
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1511
+			$vars[ $l1 ] = $val;
1512
+		}
1513
+	}
1514 1514
 
1515 1515
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1516
-        $tooltips = array(
1517
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1518
-            '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' ),
1519
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1520
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
-            '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' ),
1522
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1523
-            '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() ) ),
1524
-        );
1525
-
1526
-        if ( ! isset( $tooltips[ $name ] ) ) {
1527
-            return;
1528
-        }
1529
-
1530
-        if ( 'open' == $class ) {
1531
-            echo ' frm_help"';
1532
-        } else {
1533
-            echo ' class="frm_help"';
1534
-        }
1516
+		$tooltips = array(
1517
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1518
+			'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' ),
1519
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1520
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1521
+			'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' ),
1522
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1523
+			'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() ) ),
1524
+		);
1525
+
1526
+		if ( ! isset( $tooltips[ $name ] ) ) {
1527
+			return;
1528
+		}
1529
+
1530
+		if ( 'open' == $class ) {
1531
+			echo ' frm_help"';
1532
+		} else {
1533
+			echo ' class="frm_help"';
1534
+		}
1535 1535
 
1536 1536
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1537 1537
 
1538
-        if ( 'open' != $class ) {
1539
-            echo '"';
1540
-        }
1541
-    }
1538
+		if ( 'open' != $class ) {
1539
+			echo '"';
1540
+		}
1541
+	}
1542 1542
 
1543 1543
 	/**
1544 1544
 	 * Add the current_page class to that page in the form nav
@@ -1554,35 +1554,35 @@  discard block
 block discarded – undo
1554 1554
 		}
1555 1555
 	}
1556 1556
 
1557
-    /**
1558
-     * Prepare and json_encode post content
1559
-     *
1560
-     * @since 2.0
1561
-     *
1562
-     * @param array $post_content
1563
-     * @return string $post_content ( json encoded array )
1564
-     */
1565
-    public static function prepare_and_encode( $post_content ) {
1566
-        //Loop through array to strip slashes and add only the needed ones
1557
+	/**
1558
+	 * Prepare and json_encode post content
1559
+	 *
1560
+	 * @since 2.0
1561
+	 *
1562
+	 * @param array $post_content
1563
+	 * @return string $post_content ( json encoded array )
1564
+	 */
1565
+	public static function prepare_and_encode( $post_content ) {
1566
+		//Loop through array to strip slashes and add only the needed ones
1567 1567
 		foreach ( $post_content as $key => $val ) {
1568 1568
 			// Replace problematic characters (like &quot;)
1569 1569
 			$val = str_replace( '&quot;', '"', $val );
1570 1570
 
1571 1571
 			self::prepare_action_slashes( $val, $key, $post_content );
1572
-            unset( $key, $val );
1573
-        }
1572
+			unset( $key, $val );
1573
+		}
1574 1574
 
1575
-        // json_encode the array
1576
-        $post_content = json_encode( $post_content );
1575
+		// json_encode the array
1576
+		$post_content = json_encode( $post_content );
1577 1577
 
1578
-	    // add extra slashes for \r\n since WP strips them
1578
+		// add extra slashes for \r\n since WP strips them
1579 1579
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1580 1580
 
1581
-        // allow for &quot
1582
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1581
+		// allow for &quot
1582
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1583 1583
 
1584
-        return $post_content;
1585
-    }
1584
+		return $post_content;
1585
+	}
1586 1586
 
1587 1587
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1588 1588
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1650,64 +1650,64 @@  discard block
 block discarded – undo
1650 1650
 	}
1651 1651
 
1652 1652
 	public static function maybe_json_decode( $string ) {
1653
-        if ( is_array($string) ) {
1654
-            return $string;
1655
-        }
1653
+		if ( is_array($string) ) {
1654
+			return $string;
1655
+		}
1656 1656
 
1657
-        $new_string = json_decode($string, true);
1658
-        if ( function_exists('json_last_error') ) {
1657
+		$new_string = json_decode($string, true);
1658
+		if ( function_exists('json_last_error') ) {
1659 1659
 			// php 5.3+
1660
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1661
-                $string = $new_string;
1662
-            }
1663
-        } else if ( isset($new_string) ) {
1660
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1661
+				$string = $new_string;
1662
+			}
1663
+		} else if ( isset($new_string) ) {
1664 1664
 			// php < 5.3 fallback
1665
-            $string = $new_string;
1666
-        }
1667
-        return $string;
1668
-    }
1669
-
1670
-    /**
1671
-     * @since 1.07.10
1672
-     *
1673
-     * @param string $post_type The name of the post type that may need to be highlighted
1674
-     * echo The javascript to open and highlight the Formidable menu
1675
-     */
1665
+			$string = $new_string;
1666
+		}
1667
+		return $string;
1668
+	}
1669
+
1670
+	/**
1671
+	 * @since 1.07.10
1672
+	 *
1673
+	 * @param string $post_type The name of the post type that may need to be highlighted
1674
+	 * echo The javascript to open and highlight the Formidable menu
1675
+	 */
1676 1676
 	public static function maybe_highlight_menu( $post_type ) {
1677
-        global $post;
1677
+		global $post;
1678 1678
 
1679
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1680
-            return;
1681
-        }
1679
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1680
+			return;
1681
+		}
1682 1682
 
1683
-        if ( is_object($post) && $post->post_type != $post_type ) {
1684
-            return;
1685
-        }
1683
+		if ( is_object($post) && $post->post_type != $post_type ) {
1684
+			return;
1685
+		}
1686 1686
 
1687
-        self::load_admin_wide_js();
1688
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1689
-    }
1687
+		self::load_admin_wide_js();
1688
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1689
+	}
1690 1690
 
1691
-    /**
1692
-     * Load the JS file on non-Formidable pages in the admin area
1693
-     * @since 2.0
1694
-     */
1691
+	/**
1692
+	 * Load the JS file on non-Formidable pages in the admin area
1693
+	 * @since 2.0
1694
+	 */
1695 1695
 	public static function load_admin_wide_js( $load = true ) {
1696
-        $version = FrmAppHelper::plugin_version();
1696
+		$version = FrmAppHelper::plugin_version();
1697 1697
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1698 1698
 
1699
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1699
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1700 1700
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1701
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1701
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1702 1702
 			'url'          => FrmAppHelper::plugin_url(),
1703 1703
 			'loading'      => __( 'Loading&hellip;' ),
1704 1704
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1705
-        ) );
1705
+		) );
1706 1706
 
1707 1707
 		if ( $load ) {
1708 1708
 			wp_enqueue_script( 'formidable_admin_global' );
1709 1709
 		}
1710
-    }
1710
+	}
1711 1711
 
1712 1712
 	/**
1713 1713
 	 * @since 2.0.9
@@ -1716,9 +1716,9 @@  discard block
 block discarded – undo
1716 1716
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1717 1717
 	}
1718 1718
 
1719
-    /**
1720
-     * @param string $location
1721
-     */
1719
+	/**
1720
+	 * @param string $location
1721
+	 */
1722 1722
 	public static function localize_script( $location ) {
1723 1723
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1724 1724
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1770,81 +1770,81 @@  discard block
 block discarded – undo
1770 1770
 		}
1771 1771
 	}
1772 1772
 
1773
-    /**
1773
+	/**
1774 1774
 	 * echo the message on the plugins listing page
1775
-     * @since 1.07.10
1776
-     *
1777
-     * @param float $min_version The version the add-on requires
1778
-     */
1775
+	 * @since 1.07.10
1776
+	 *
1777
+	 * @param float $min_version The version the add-on requires
1778
+	 */
1779 1779
 	public static function min_version_notice( $min_version ) {
1780
-        $frm_version = self::plugin_version();
1780
+		$frm_version = self::plugin_version();
1781 1781
 
1782
-        // check if Formidable meets minimum requirements
1783
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1784
-            return;
1785
-        }
1782
+		// check if Formidable meets minimum requirements
1783
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1784
+			return;
1785
+		}
1786 1786
 
1787
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1787
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1788 1788
 		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">' .
1789
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1790
-        '</div></td></tr>';
1791
-    }
1792
-
1793
-    public static function locales( $type = 'date' ) {
1794
-        $locales = array(
1795
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1796
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1797
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1799
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1800
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1801
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1802
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1803
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1804
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1805
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1806
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1807
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1808
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1809
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1810
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1811
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1812
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1813
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1814
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1815
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1816
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1817
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1818
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1819
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1820
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1821
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1822
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1823
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1824
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1825
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1826
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
-        );
1828
-
1829
-        if ( $type == 'captcha' ) {
1830
-            // remove the languages unavailable for the captcha
1831
-            $unset = array(
1832
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1833
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1834
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1835
-            );
1836
-        } else {
1837
-            // remove the languages unavailable for the datepicker
1838
-            $unset = array(
1839
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1840
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1841
-                'es-419', 'tr',
1842
-            );
1843
-        }
1844
-
1845
-        $locales = array_diff_key($locales, array_flip($unset));
1846
-        $locales = apply_filters('frm_locales', $locales);
1847
-
1848
-        return $locales;
1849
-    }
1789
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1790
+		'</div></td></tr>';
1791
+	}
1792
+
1793
+	public static function locales( $type = 'date' ) {
1794
+		$locales = array(
1795
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1796
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1797
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1799
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1800
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1801
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1802
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1803
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1804
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1805
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1806
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1807
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1808
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1809
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1810
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1811
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1812
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1813
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1814
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1815
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1816
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1817
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1818
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1819
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1820
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1821
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1822
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1823
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1824
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1825
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1826
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
+		);
1828
+
1829
+		if ( $type == 'captcha' ) {
1830
+			// remove the languages unavailable for the captcha
1831
+			$unset = array(
1832
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1833
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1834
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1835
+			);
1836
+		} else {
1837
+			// remove the languages unavailable for the datepicker
1838
+			$unset = array(
1839
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1840
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1841
+				'es-419', 'tr',
1842
+			);
1843
+		}
1844
+
1845
+		$locales = array_diff_key($locales, array_flip($unset));
1846
+		$locales = apply_filters('frm_locales', $locales);
1847
+
1848
+		return $locales;
1849
+	}
1850 1850
 }
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +765 added lines, -765 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71 71
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72
-    }
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
158
-
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
163
-
164
-    /**
165
-     * @since 2.0
166
-     */
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158
+
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 		return $msg;
184 184
 	}
185 185
 
186
-    public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
-        return $fields;
190
-    }
186
+	public static function get_form_fields( $form_id, $error = false ) {
187
+		$fields = FrmField::get_all_for_form($form_id);
188
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
+		return $fields;
190
+	}
191 191
 
192 192
 	public static function get_default_html( $type = 'text' ) {
193 193
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
194 194
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
195
-            $for = '';
195
+			$for = '';
196 196
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
197
-                $for = 'for="field_[key]"';
198
-            }
197
+				$for = 'for="field_[key]"';
198
+			}
199 199
 
200
-            $default_html = <<<DEFAULT_HTML
200
+			$default_html = <<<DEFAULT_HTML
201 201
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
202 202
     <label $for class="frm_primary_label">[field_name]
203 203
         <span class="frm_required">[required_label]</span>
@@ -207,138 +207,138 @@  discard block
 block discarded – undo
207 207
     [if error]<div class="frm_error">[error]</div>[/if error]
208 208
 </div>
209 209
 DEFAULT_HTML;
210
-        } else {
210
+		} else {
211 211
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
-        }
212
+		}
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
215
-    }
214
+		return apply_filters('frm_custom_html', $default_html, $type);
215
+	}
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219 219
 
220
-        $defaults = array(
220
+		$defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
222 222
 			'field_id'      => $field['id'],
223
-            'field_plus_id' => '',
224
-            'section_id'    => '',
225
-        );
226
-        $args = wp_parse_args($args, $defaults);
227
-        $field_name = $args['field_name'];
228
-        $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
223
+			'field_plus_id' => '',
224
+			'section_id'    => '',
225
+		);
226
+		$args = wp_parse_args($args, $defaults);
227
+		$field_name = $args['field_name'];
228
+		$field_id = $args['field_id'];
229
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
232
-            $field_name .= '[]';
233
-        }
231
+		if ( FrmField::is_multiple_select($field) ) {
232
+			$field_name .= '[]';
233
+		}
234 234
 
235
-        //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
235
+		//replace [id]
236
+		$html = str_replace('[id]', $field_id, $html);
237 237
 
238
-        // Remove the for attribute for captcha
239
-        if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
241
-        }
238
+		// Remove the for attribute for captcha
239
+		if ( $field['type'] == 'captcha' ) {
240
+			$html = str_replace(' for="field_[key]"', '', $html);
241
+		}
242 242
 
243
-        // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
243
+		// set the label for
244
+		$html = str_replace('field_[key]', $html_id, $html);
245 245
 
246
-        //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
246
+		//replace [key]
247
+		$html = str_replace('[key]', $field['field_key'], $html);
248 248
 
249
-        //replace [description] and [required_label] and [error]
249
+		//replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251
-        if ( ! is_array( $errors ) ) {
252
-            $errors = array();
253
-        }
251
+		if ( ! is_array( $errors ) ) {
252
+			$errors = array();
253
+		}
254 254
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255 255
 
256
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
-        if ( $field['type'] == 'divider' ) {
258
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
259
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
-            } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
-            }
263
-        }
256
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
+		if ( $field['type'] == 'divider' ) {
258
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
259
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
+			} else {
261
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+			}
263
+		}
264 264
 
265 265
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
266
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
-        }
266
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
+		}
268 268
 
269
-        //replace [required_class]
269
+		//replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+		$html = str_replace('[required_class]', $required_class, $html);
272 272
 
273
-        //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273
+		//replace [label_position]
274
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287
-        //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
-        global $frm_vars;
290
-        $frm_settings = FrmAppHelper::get_settings();
287
+		//replace [input]
288
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
+		global $frm_vars;
290
+		$frm_settings = FrmAppHelper::get_settings();
291 291
 
292
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
292
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
293
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296
-            $replace_with = '';
296
+			$replace_with = '';
297 297
 
298
-            if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
301
-                }
298
+			if ( $tag == 'input' ) {
299
+				if ( isset($atts['opt']) ) {
300
+					$atts['opt']--;
301
+				}
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
306
-                }
303
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
+				if ( isset($atts['class']) ) {
305
+					unset($atts['class']);
306
+				}
307 307
 
308
-                $field['shortcodes'] = $atts;
309
-                ob_start();
308
+				$field['shortcodes'] = $atts;
309
+				ob_start();
310 310
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
311
-                $replace_with = ob_get_contents();
312
-                ob_end_clean();
313
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
315
-            }
311
+				$replace_with = ob_get_contents();
312
+				ob_end_clean();
313
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
315
+			}
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
-        }
317
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
+		}
319 319
 
320 320
 		if ( $form ) {
321
-            $form = (array) $form;
321
+			$form = (array) $form;
322 322
 
323
-            //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
323
+			//replace [form_key]
324
+			$html = str_replace('[form_key]', $form['form_key'], $html);
325 325
 
326
-            //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
328
-        }
329
-        $html .= "\n";
326
+			//replace [form_name]
327
+			$html = str_replace('[form_name]', $form['name'], $html);
328
+		}
329
+		$html .= "\n";
330 330
 
331
-        //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
-            return $html;
334
-        }
331
+		//Return html if conf_field to prevent loop
332
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
+			return $html;
334
+		}
335 335
 
336
-        //If field is in repeating section
337
-        if ( $args['section_id'] ) {
338
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
339
-        } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
-        }
336
+		//If field is in repeating section
337
+		if ( $args['section_id'] ) {
338
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
339
+		} else {
340
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
+		}
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			$html = do_shortcode( $html );
347 347
 		}
348 348
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * Add classes to a field div
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
 		return $classes;
402 402
 	}
403 403
 
404
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
-        if ( $no_vars ) {
404
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
+		if ( $no_vars ) {
406 406
 			$html = str_replace( '[if ' . $code . ']', '', $html );
407 407
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
408
-        } else {
408
+		} else {
409 409
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
410
-        }
410
+		}
411 411
 
412 412
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
413
-    }
413
+	}
414 414
 
415 415
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
416 416
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
417
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
-            $args['conditional_check'] = true;
419
-        }
420
-
421
-        $prefix = '';
422
-        if ( $args['conditional_check'] ) {
423
-            if ( $args['conditional'] ) {
424
-                $prefix = 'if ';
425
-            } else if ( $args['foreach'] ) {
426
-                $prefix = 'foreach ';
427
-            }
428
-        }
429
-
430
-        $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
436
-                $tag = $tags[0];
437
-            }
438
-        } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
-        }
441
-
442
-        return $tag;
443
-    }
417
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
+			$args['conditional_check'] = true;
419
+		}
420
+
421
+		$prefix = '';
422
+		if ( $args['conditional_check'] ) {
423
+			if ( $args['conditional'] ) {
424
+				$prefix = 'if ';
425
+			} else if ( $args['foreach'] ) {
426
+				$prefix = 'foreach ';
427
+			}
428
+		}
429
+
430
+		$with_tags = $args['conditional_check'] ? 3 : 2;
431
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
+			$tag = str_replace(']', '', $tag);
434
+			$tags = explode(' ', $tag);
435
+			if ( is_array($tags) ) {
436
+				$tag = $tags[0];
437
+			}
438
+		} else {
439
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
+		}
441
+
442
+		return $tag;
443
+	}
444 444
 
445 445
 	/**
446 446
 	 * Remove [collapse_this] if it's still included after all processing
@@ -465,124 +465,124 @@  discard block
 block discarded – undo
465 465
 			$class_prefix = 'frm-';
466 466
 		}
467 467
 
468
-        if ( $lang != 'en' ) {
468
+		if ( $lang != 'en' ) {
469 469
 			$api_js_url .= '&hl=' . $lang;
470
-        }
470
+		}
471 471
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
472 472
 
473
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
-        wp_enqueue_script( 'recaptcha-api' );
473
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
+		wp_enqueue_script( 'recaptcha-api' );
475 475
 
476 476
 ?>
477 477
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div>
478 478
 <?php
479
-    }
479
+	}
480 480
 
481 481
 	public static function show_single_option( $field ) {
482
-        $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
484
-        foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
482
+		$field_name = $field['name'];
483
+		$html_id = self::get_html_id($field);
484
+		foreach ( $field['options'] as $opt_key => $opt ) {
485
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
487 487
 
488
-            // If this is an "Other" option, get the HTML for it
488
+			// If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
490
-                // Get string for Other text field, if needed
490
+				// Get string for Other text field, if needed
491 491
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
492 492
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
493
-            } else {
493
+			} else {
494 494
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
495
-            }
496
-        }
497
-    }
495
+			}
496
+		}
497
+	}
498 498
 
499 499
 	public static function dropdown_categories( $args ) {
500 500
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
501
-        $args = wp_parse_args($args, $defaults);
501
+		$args = wp_parse_args($args, $defaults);
502 502
 
503
-        if ( ! $args['field'] ) {
504
-            return;
505
-        }
503
+		if ( ! $args['field'] ) {
504
+			return;
505
+		}
506 506
 
507
-        if ( ! $args['name'] ) {
507
+		if ( ! $args['name'] ) {
508 508
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
509
-        }
509
+		}
510 510
 
511
-        $id = self::get_html_id($args['field']);
512
-        $class = $args['field']['type'];
511
+		$id = self::get_html_id($args['field']);
512
+		$class = $args['field']['type'];
513 513
 
514
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
515
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
514
+		$exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
515
+		$exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
516 516
 
517
-        if ( is_array($args['field']['value']) ) {
518
-            if ( ! empty($exclude) ) {
519
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
520
-            }
521
-            $selected = reset($args['field']['value']);
522
-        } else {
523
-            $selected = $args['field']['value'];
524
-        }
517
+		if ( is_array($args['field']['value']) ) {
518
+			if ( ! empty($exclude) ) {
519
+				$args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
520
+			}
521
+			$selected = reset($args['field']['value']);
522
+		} else {
523
+			$selected = $args['field']['value'];
524
+		}
525 525
 
526
-        $tax_atts = array(
527
-            'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
528
-            'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
529
-            'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
530
-        );
526
+		$tax_atts = array(
527
+			'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
528
+			'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
529
+			'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
530
+		);
531 531
 
532
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
532
+		$tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
533 533
 
534
-        if ( FrmAppHelper::pro_is_installed() ) {
535
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
536
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
537
-            if ( ! $tax_atts['taxonomy'] ) {
538
-                return;
539
-            }
534
+		if ( FrmAppHelper::pro_is_installed() ) {
535
+			$post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
536
+			$tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
537
+			if ( ! $tax_atts['taxonomy'] ) {
538
+				return;
539
+			}
540 540
 
541
-            // If field type is dropdown (not Dynamic), exclude children when parent is excluded
542
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
543
-                $tax_atts['exclude_tree'] = $exclude;
544
-            }
545
-        }
541
+			// If field type is dropdown (not Dynamic), exclude children when parent is excluded
542
+			if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
543
+				$tax_atts['exclude_tree'] = $exclude;
544
+			}
545
+		}
546 546
 
547
-        $dropdown = wp_dropdown_categories($tax_atts);
547
+		$dropdown = wp_dropdown_categories($tax_atts);
548 548
 
549
-        $add_html = FrmFieldsController::input_html($args['field'], false);
549
+		$add_html = FrmFieldsController::input_html($args['field'], false);
550 550
 
551
-        if ( FrmAppHelper::pro_is_installed() ) {
552
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
553
-        }
551
+		if ( FrmAppHelper::pro_is_installed() ) {
552
+			$add_html .= FrmProFieldsController::input_html($args['field'], false);
553
+		}
554 554
 
555 555
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
556 556
 
557
-        if ( is_array($args['field']['value']) ) {
558
-            $skip = true;
559
-            foreach ( $args['field']['value'] as $v ) {
557
+		if ( is_array($args['field']['value']) ) {
558
+			$skip = true;
559
+			foreach ( $args['field']['value'] as $v ) {
560 560
 				if ( $skip ) {
561
-                    $skip = false;
562
-                    continue;
563
-                }
561
+					$skip = false;
562
+					continue;
563
+				}
564 564
 				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
565
-                unset($v);
566
-            }
567
-        }
565
+				unset($v);
566
+			}
567
+		}
568 568
 
569
-        return $dropdown;
570
-    }
569
+		return $dropdown;
570
+	}
571 571
 
572 572
 	public static function get_term_link( $tax_id ) {
573
-        $tax = get_taxonomy($tax_id);
574
-        if ( ! $tax ) {
575
-            return;
576
-        }
573
+		$tax = get_taxonomy($tax_id);
574
+		if ( ! $tax ) {
575
+			return;
576
+		}
577 577
 
578
-        $link = sprintf(
579
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
578
+		$link = sprintf(
579
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
580 580
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
581
-        );
582
-        unset($tax);
581
+		);
582
+		unset($tax);
583 583
 
584
-        return $link;
585
-    }
584
+		return $link;
585
+	}
586 586
 
587 587
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
588 588
 		// Remove white space from hide_opt
@@ -593,195 +593,195 @@  discard block
 block discarded – undo
593 593
 		$observed_value = wp_kses_post( $observed_value );
594 594
 		$hide_opt = wp_kses_post( $hide_opt );
595 595
 
596
-        if ( is_array($observed_value) ) {
597
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
598
-        }
599
-
600
-        $m = false;
601
-        if ( $cond == '==' ) {
602
-            $m = $observed_value == $hide_opt;
603
-        } else if ( $cond == '!=' ) {
604
-            $m = $observed_value != $hide_opt;
605
-        } else if ( $cond == '>' ) {
606
-            $m = $observed_value > $hide_opt;
607
-        } else if ( $cond == '<' ) {
608
-            $m = $observed_value < $hide_opt;
609
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
610
-            $m = stripos($observed_value, $hide_opt);
611
-            if ( $cond == 'not LIKE' ) {
612
-                $m = ( $m === false ) ? true : false;
613
-            } else {
614
-                $m = ( $m === false ) ? false : true;
615
-            }
616
-        }
617
-        return $m;
618
-    }
596
+		if ( is_array($observed_value) ) {
597
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
598
+		}
599
+
600
+		$m = false;
601
+		if ( $cond == '==' ) {
602
+			$m = $observed_value == $hide_opt;
603
+		} else if ( $cond == '!=' ) {
604
+			$m = $observed_value != $hide_opt;
605
+		} else if ( $cond == '>' ) {
606
+			$m = $observed_value > $hide_opt;
607
+		} else if ( $cond == '<' ) {
608
+			$m = $observed_value < $hide_opt;
609
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
610
+			$m = stripos($observed_value, $hide_opt);
611
+			if ( $cond == 'not LIKE' ) {
612
+				$m = ( $m === false ) ? true : false;
613
+			} else {
614
+				$m = ( $m === false ) ? false : true;
615
+			}
616
+		}
617
+		return $m;
618
+	}
619 619
 
620 620
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
621
-        $m = false;
622
-        if ( $cond == '==' ) {
623
-            if ( is_array($hide_opt) ) {
624
-                $m = array_intersect($hide_opt, $observed_value);
625
-                $m = empty($m) ? false : true;
626
-            } else {
627
-                $m = in_array($hide_opt, $observed_value);
628
-            }
629
-        } else if ( $cond == '!=' ) {
630
-            $m = ! in_array($hide_opt, $observed_value);
631
-        } else if ( $cond == '>' ) {
632
-            $min = min($observed_value);
633
-            $m = $min > $hide_opt;
634
-        } else if ( $cond == '<' ) {
635
-            $max = max($observed_value);
636
-            $m = $max < $hide_opt;
637
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
638
-            foreach ( $observed_value as $ob ) {
639
-                $m = strpos($ob, $hide_opt);
640
-                if ( $m !== false ) {
641
-                    $m = true;
642
-                    break;
643
-                }
644
-            }
645
-
646
-            if ( $cond == 'not LIKE' ) {
647
-                $m = ( $m === false ) ? true : false;
648
-            }
649
-        }
650
-
651
-        return $m;
652
-    }
653
-
654
-    /**
655
-     * Replace a few basic shortcodes and field ids
656
-     * @since 2.0
657
-     * @return string
658
-     */
621
+		$m = false;
622
+		if ( $cond == '==' ) {
623
+			if ( is_array($hide_opt) ) {
624
+				$m = array_intersect($hide_opt, $observed_value);
625
+				$m = empty($m) ? false : true;
626
+			} else {
627
+				$m = in_array($hide_opt, $observed_value);
628
+			}
629
+		} else if ( $cond == '!=' ) {
630
+			$m = ! in_array($hide_opt, $observed_value);
631
+		} else if ( $cond == '>' ) {
632
+			$min = min($observed_value);
633
+			$m = $min > $hide_opt;
634
+		} else if ( $cond == '<' ) {
635
+			$max = max($observed_value);
636
+			$m = $max < $hide_opt;
637
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
638
+			foreach ( $observed_value as $ob ) {
639
+				$m = strpos($ob, $hide_opt);
640
+				if ( $m !== false ) {
641
+					$m = true;
642
+					break;
643
+				}
644
+			}
645
+
646
+			if ( $cond == 'not LIKE' ) {
647
+				$m = ( $m === false ) ? true : false;
648
+			}
649
+		}
650
+
651
+		return $m;
652
+	}
653
+
654
+	/**
655
+	 * Replace a few basic shortcodes and field ids
656
+	 * @since 2.0
657
+	 * @return string
658
+	 */
659 659
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
660
-        if ( strpos($value, '[sitename]') !== false ) {
661
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
662
-            $value = str_replace('[sitename]', $new_value, $value);
663
-        }
660
+		if ( strpos($value, '[sitename]') !== false ) {
661
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
662
+			$value = str_replace('[sitename]', $new_value, $value);
663
+		}
664 664
 
665
-        $value = apply_filters('frm_content', $value, $form, $entry);
666
-        $value = do_shortcode($value);
665
+		$value = apply_filters('frm_content', $value, $form, $entry);
666
+		$value = do_shortcode($value);
667 667
 
668
-        return $value;
669
-    }
668
+		return $value;
669
+	}
670 670
 
671 671
 	public static function get_shortcodes( $content, $form_id ) {
672
-        if ( FrmAppHelper::pro_is_installed() ) {
673
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
674
-        }
672
+		if ( FrmAppHelper::pro_is_installed() ) {
673
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
674
+		}
675 675
 
676
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
676
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
677 677
 
678
-        $tagregexp = self::allowed_shortcodes($fields);
678
+		$tagregexp = self::allowed_shortcodes($fields);
679 679
 
680
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
680
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
681 681
 
682
-        return $matches;
683
-    }
682
+		return $matches;
683
+	}
684 684
 
685 685
 	public static function allowed_shortcodes( $fields = array() ) {
686
-        $tagregexp = array(
687
-            'editlink', 'id', 'key', 'ip',
688
-            'siteurl', 'sitename', 'admin_email',
689
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
686
+		$tagregexp = array(
687
+			'editlink', 'id', 'key', 'ip',
688
+			'siteurl', 'sitename', 'admin_email',
689
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
690 690
 			'parent[-|_]id',
691
-        );
691
+		);
692 692
 
693
-        foreach ( $fields as $field ) {
694
-            $tagregexp[] = $field->id;
695
-            $tagregexp[] = $field->field_key;
696
-        }
693
+		foreach ( $fields as $field ) {
694
+			$tagregexp[] = $field->id;
695
+			$tagregexp[] = $field->field_key;
696
+		}
697 697
 
698
-        $tagregexp = implode('|', $tagregexp);
699
-        return $tagregexp;
700
-    }
698
+		$tagregexp = implode('|', $tagregexp);
699
+		return $tagregexp;
700
+	}
701 701
 
702 702
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
703
-        $shortcode_values = array(
704
-           'id'     => $entry->id,
705
-           'key'    => $entry->item_key,
706
-           'ip'     => $entry->ip,
707
-        );
703
+		$shortcode_values = array(
704
+		   'id'     => $entry->id,
705
+		   'key'    => $entry->item_key,
706
+		   'ip'     => $entry->ip,
707
+		);
708 708
 
709
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
710
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
709
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
710
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
711 711
 
712
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
712
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
713 713
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
714
-                $tags = explode(' ', $tag);
715
-                if ( is_array($tags) ) {
716
-                    $tag = $tags[0];
717
-                }
718
-            } else {
719
-                $tag = $shortcodes[2][ $short_key ];
720
-            }
721
-
722
-            switch ( $tag ) {
723
-                case 'id':
724
-                case 'key':
725
-                case 'ip':
726
-                    $replace_with = $shortcode_values[ $tag ];
727
-                break;
728
-
729
-                case 'user_agent':
730
-                case 'user-agent':
731
-                    $entry->description = maybe_unserialize($entry->description);
714
+				$tags = explode(' ', $tag);
715
+				if ( is_array($tags) ) {
716
+					$tag = $tags[0];
717
+				}
718
+			} else {
719
+				$tag = $shortcodes[2][ $short_key ];
720
+			}
721
+
722
+			switch ( $tag ) {
723
+				case 'id':
724
+				case 'key':
725
+				case 'ip':
726
+					$replace_with = $shortcode_values[ $tag ];
727
+				break;
728
+
729
+				case 'user_agent':
730
+				case 'user-agent':
731
+					$entry->description = maybe_unserialize($entry->description);
732 732
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
733
-                break;
734
-
735
-                case 'created_at':
736
-                case 'created-at':
737
-                case 'updated_at':
738
-                case 'updated-at':
739
-                    if ( isset($atts['format']) ) {
740
-                        $time_format = ' ';
741
-                    } else {
742
-                        $atts['format'] = get_option('date_format');
743
-                        $time_format = '';
744
-                    }
745
-
746
-                    $this_tag = str_replace('-', '_', $tag);
747
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
748
-                    unset($this_tag);
749
-                break;
750
-
751
-                case 'created_by':
752
-                case 'created-by':
753
-                case 'updated_by':
754
-                case 'updated-by':
755
-                    $this_tag = str_replace('-', '_', $tag);
733
+				break;
734
+
735
+				case 'created_at':
736
+				case 'created-at':
737
+				case 'updated_at':
738
+				case 'updated-at':
739
+					if ( isset($atts['format']) ) {
740
+						$time_format = ' ';
741
+					} else {
742
+						$atts['format'] = get_option('date_format');
743
+						$time_format = '';
744
+					}
745
+
746
+					$this_tag = str_replace('-', '_', $tag);
747
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
748
+					unset($this_tag);
749
+				break;
750
+
751
+				case 'created_by':
752
+				case 'created-by':
753
+				case 'updated_by':
754
+				case 'updated-by':
755
+					$this_tag = str_replace('-', '_', $tag);
756 756
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
757
-                    unset($this_tag);
758
-                break;
759
-
760
-                case 'admin_email':
761
-                case 'siteurl':
762
-                case 'frmurl':
763
-                case 'sitename':
764
-                case 'get':
765
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
766
-                break;
767
-
768
-                default:
769
-                    $field = FrmField::getOne( $tag );
770
-                    if ( ! $field ) {
771
-                        break;
772
-                    }
773
-
774
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
775
-
776
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
777
-
778
-                    $atts['entry_id'] = $entry->id;
779
-                    $atts['entry_key'] = $entry->item_key;
780
-
781
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
782
-                        $replace_with = $field->name;
783
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
784
-                        $replace_with = $field->description;
757
+					unset($this_tag);
758
+				break;
759
+
760
+				case 'admin_email':
761
+				case 'siteurl':
762
+				case 'frmurl':
763
+				case 'sitename':
764
+				case 'get':
765
+					$replace_with = self::dynamic_default_values( $tag, $atts );
766
+				break;
767
+
768
+				default:
769
+					$field = FrmField::getOne( $tag );
770
+					if ( ! $field ) {
771
+						break;
772
+					}
773
+
774
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
775
+
776
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
777
+
778
+					$atts['entry_id'] = $entry->id;
779
+					$atts['entry_key'] = $entry->item_key;
780
+
781
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
782
+						$replace_with = $field->name;
783
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
784
+						$replace_with = $field->description;
785 785
 					} else {
786 786
 						$string_value = $replace_with;
787 787
 						if ( is_array( $replace_with ) ) {
@@ -795,82 +795,82 @@  discard block
 block discarded – undo
795 795
 						}
796 796
 					}
797 797
 
798
-                    unset($field);
799
-                break;
800
-            }
798
+					unset($field);
799
+				break;
800
+			}
801 801
 
802
-            if ( isset($replace_with) ) {
803
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
804
-            }
802
+			if ( isset($replace_with) ) {
803
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
804
+			}
805 805
 
806
-            unset($atts, $conditional, $replace_with);
806
+			unset($atts, $conditional, $replace_with);
807 807
 		}
808 808
 
809 809
 		return $content;
810
-    }
811
-
812
-    /**
813
-     * Get the value to replace a few standard shortcodes
814
-     *
815
-     * @since 2.0
816
-     * @return string
817
-     */
818
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
819
-        $new_value = '';
820
-        switch ( $tag ) {
821
-            case 'admin_email':
822
-                $new_value = get_option('admin_email');
823
-                break;
824
-            case 'siteurl':
825
-                $new_value = FrmAppHelper::site_url();
826
-                break;
827
-            case 'frmurl':
828
-                $new_value = FrmAppHelper::plugin_url();
829
-                break;
830
-            case 'sitename':
831
-                $new_value = FrmAppHelper::site_name();
832
-                break;
833
-            case 'get':
834
-                $new_value = self::process_get_shortcode( $atts, $return_array );
835
-                break;
836
-        }
837
-
838
-        return $new_value;
839
-    }
840
-
841
-    /**
842
-     * Process the [get] shortcode
843
-     *
844
-     * @since 2.0
845
-     * @return string|array
846
-     */
847
-    public static function process_get_shortcode( $atts, $return_array = false ) {
848
-        if ( ! isset($atts['param']) ) {
849
-            return '';
850
-        }
851
-
852
-        if ( strpos($atts['param'], '&#91;') ) {
853
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
854
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
855
-        }
856
-
857
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
858
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
859
-
860
-        if ( $new_value == '' ) {
861
-            if ( ! isset($atts['prev_val']) ) {
862
-                $atts['prev_val'] = '';
863
-            }
864
-
865
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
866
-        }
867
-
868
-        if ( is_array($new_value) && ! $return_array ) {
869
-            $new_value = implode(', ', $new_value);
870
-        }
871
-
872
-        return $new_value;
873
-    }
810
+	}
811
+
812
+	/**
813
+	 * Get the value to replace a few standard shortcodes
814
+	 *
815
+	 * @since 2.0
816
+	 * @return string
817
+	 */
818
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
819
+		$new_value = '';
820
+		switch ( $tag ) {
821
+			case 'admin_email':
822
+				$new_value = get_option('admin_email');
823
+				break;
824
+			case 'siteurl':
825
+				$new_value = FrmAppHelper::site_url();
826
+				break;
827
+			case 'frmurl':
828
+				$new_value = FrmAppHelper::plugin_url();
829
+				break;
830
+			case 'sitename':
831
+				$new_value = FrmAppHelper::site_name();
832
+				break;
833
+			case 'get':
834
+				$new_value = self::process_get_shortcode( $atts, $return_array );
835
+				break;
836
+		}
837
+
838
+		return $new_value;
839
+	}
840
+
841
+	/**
842
+	 * Process the [get] shortcode
843
+	 *
844
+	 * @since 2.0
845
+	 * @return string|array
846
+	 */
847
+	public static function process_get_shortcode( $atts, $return_array = false ) {
848
+		if ( ! isset($atts['param']) ) {
849
+			return '';
850
+		}
851
+
852
+		if ( strpos($atts['param'], '&#91;') ) {
853
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
854
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
855
+		}
856
+
857
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
858
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
859
+
860
+		if ( $new_value == '' ) {
861
+			if ( ! isset($atts['prev_val']) ) {
862
+				$atts['prev_val'] = '';
863
+			}
864
+
865
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
866
+		}
867
+
868
+		if ( is_array($new_value) && ! $return_array ) {
869
+			$new_value = implode(', ', $new_value);
870
+		}
871
+
872
+		return $new_value;
873
+	}
874 874
 
875 875
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
876 876
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -878,14 +878,14 @@  discard block
 block discarded – undo
878 878
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
879 879
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
880 880
 
881
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
882
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
883
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
884
-                if ( is_array($replace_with) ) {
885
-                    $replace_with = implode("\n", $replace_with);
886
-                }
887
-                $replace_with = wpautop($replace_with);
888
-            }
881
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
882
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
883
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
884
+				if ( is_array($replace_with) ) {
885
+					$replace_with = implode("\n", $replace_with);
886
+				}
887
+				$replace_with = wpautop($replace_with);
888
+			}
889 889
 			unset( $autop );
890 890
 		} else if ( is_array( $replace_with ) ) {
891 891
 			$replace_with = implode( $sep, $replace_with );
@@ -895,58 +895,58 @@  discard block
 block discarded – undo
895 895
 	}
896 896
 
897 897
 	public static function get_field_types( $type ) {
898
-        $single_input = array(
899
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
900
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
901
-            'user_id', 'tag', 'password',
902
-        );
898
+		$single_input = array(
899
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
900
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
901
+			'user_id', 'tag', 'password',
902
+		);
903 903
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
904 904
 		$other_type = array( 'html', 'break' );
905 905
 
906 906
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
907 907
 
908
-        $field_types = array();
909
-        if ( in_array($type, $single_input) ) {
910
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
911
-        } else if ( in_array($type, $multiple_input) ) {
912
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
913
-        } else if ( in_array($type, $other_type) ) {
914
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
908
+		$field_types = array();
909
+		if ( in_array($type, $single_input) ) {
910
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
911
+		} else if ( in_array($type, $multiple_input) ) {
912
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
913
+		} else if ( in_array($type, $other_type) ) {
914
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
915 915
 		} else if ( isset( $field_selection[ $type ] ) ) {
916
-            $field_types[ $type ] = $field_selection[ $type ];
917
-        }
916
+			$field_types[ $type ] = $field_selection[ $type ];
917
+		}
918 918
 
919 919
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
920
-        return $field_types;
921
-    }
922
-
923
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
924
-        foreach ( $inputs as $input ) {
925
-            $field_types[ $input ] = $fields[ $input ];
926
-            unset($input);
927
-        }
928
-    }
929
-
930
-    /**
931
-    * Check if current field option is an "other" option
932
-    *
933
-    * @since 2.0.6
934
-    *
935
-    * @param string $opt_key
936
-    * @return boolean Returns true if current field option is an "Other" option
937
-    */
938
-    public static function is_other_opt( $opt_key ) {
939
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
940
-    }
941
-
942
-    /**
943
-    * Get value that belongs in "Other" text box
944
-    *
945
-    * @since 2.0.6
946
-    *
947
-    * @param array $args
948
-    */
949
-    public static function get_other_val( $args ) {
920
+		return $field_types;
921
+	}
922
+
923
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
924
+		foreach ( $inputs as $input ) {
925
+			$field_types[ $input ] = $fields[ $input ];
926
+			unset($input);
927
+		}
928
+	}
929
+
930
+	/**
931
+	 * Check if current field option is an "other" option
932
+	 *
933
+	 * @since 2.0.6
934
+	 *
935
+	 * @param string $opt_key
936
+	 * @return boolean Returns true if current field option is an "Other" option
937
+	 */
938
+	public static function is_other_opt( $opt_key ) {
939
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
940
+	}
941
+
942
+	/**
943
+	 * Get value that belongs in "Other" text box
944
+	 *
945
+	 * @since 2.0.6
946
+	 *
947
+	 * @param array $args
948
+	 */
949
+	public static function get_other_val( $args ) {
950 950
 		$defaults = array(
951 951
 			'opt_key' => 0, 'field' => array(),
952 952
 			'parent' => false, 'pointer' => false,
@@ -1022,20 +1022,20 @@  discard block
 block discarded – undo
1022 1022
 		}
1023 1023
 
1024 1024
 		return $other_val;
1025
-    }
1026
-
1027
-    /**
1028
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1029
-    * Intended for front-end use
1030
-    *
1031
-    * @since 2.0.6
1032
-    *
1033
-    * @param array $args should include field, opt_key and field name
1034
-    * @param boolean $other_opt
1035
-    * @param string $checked
1036
-    * @return string $other_val
1037
-    */
1038
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1025
+	}
1026
+
1027
+	/**
1028
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1029
+	 * Intended for front-end use
1030
+	 *
1031
+	 * @since 2.0.6
1032
+	 *
1033
+	 * @param array $args should include field, opt_key and field name
1034
+	 * @param boolean $other_opt
1035
+	 * @param string $checked
1036
+	 * @return string $other_val
1037
+	 */
1038
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1039 1039
 		//Check if this is an "Other" option
1040 1040
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1041 1041
 			return;
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 			$checked = 'checked="checked" ';
1052 1052
 		}
1053 1053
 
1054
-        return $other_args;
1055
-    }
1054
+		return $other_args;
1055
+	}
1056 1056
 
1057 1057
 	/**
1058 1058
 	 * @param array $args
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 	 * @since 2.0.6
1102 1102
 	 */
1103 1103
 	public static function include_other_input( $args ) {
1104
-        if ( ! $args['other_opt'] ) {
1105
-        	return;
1104
+		if ( ! $args['other_opt'] ) {
1105
+			return;
1106 1106
 		}
1107 1107
 
1108 1108
 		$classes = array( 'frm_other_input' );
@@ -1123,15 +1123,15 @@  discard block
 block discarded – undo
1123 1123
 	}
1124 1124
 
1125 1125
 	/**
1126
-	* Get the HTML id for an "Other" text field
1127
-	* Note: This does not affect fields in repeating sections
1128
-	*
1129
-	* @since 2.0.08
1130
-	* @param string $type - field type
1131
-	* @param string $html_id
1132
-	* @param string|boolean $opt_key
1133
-	* @return string $other_id
1134
-	*/
1126
+	 * Get the HTML id for an "Other" text field
1127
+	 * Note: This does not affect fields in repeating sections
1128
+	 *
1129
+	 * @since 2.0.08
1130
+	 * @param string $type - field type
1131
+	 * @param string $html_id
1132
+	 * @param string|boolean $opt_key
1133
+	 * @return string $other_id
1134
+	 */
1135 1135
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1136 1136
 		$other_id = $html_id;
1137 1137
 
@@ -1189,10 +1189,10 @@  discard block
 block discarded – undo
1189 1189
 	}
1190 1190
 
1191 1191
 	public static function switch_field_ids( $val ) {
1192
-        global $frm_duplicate_ids;
1193
-        $replace = array();
1194
-        $replace_with = array();
1195
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1192
+		global $frm_duplicate_ids;
1193
+		$replace = array();
1194
+		$replace_with = array();
1195
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1196 1196
 			$replace[] = '[if ' . $old . ']';
1197 1197
 			$replace_with[] = '[if ' . $new . ']';
1198 1198
 			$replace[] = '[if ' . $old . ' ';
@@ -1207,153 +1207,153 @@  discard block
 block discarded – undo
1207 1207
 			$replace_with[] = '[' . $new . ']';
1208 1208
 			$replace[] = '[' . $old . ' ';
1209 1209
 			$replace_with[] = '[' . $new . ' ';
1210
-            unset($old, $new);
1211
-        }
1210
+			unset($old, $new);
1211
+		}
1212 1212
 		if ( is_array( $val ) ) {
1213 1213
 			foreach ( $val as $k => $v ) {
1214
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1215
-                unset($k, $v);
1216
-            }
1217
-        } else {
1218
-            $val = str_replace($replace, $replace_with, $val);
1219
-        }
1220
-
1221
-        return $val;
1222
-    }
1223
-
1224
-    public static function get_us_states() {
1225
-        return apply_filters( 'frm_us_states', array(
1226
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1227
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1228
-            'DC' => 'District of Columbia',
1229
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1230
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1231
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1232
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1233
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1234
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1235
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1236
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1237
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1238
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1239
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1240
-        ) );
1241
-    }
1242
-
1243
-    public static function get_countries() {
1244
-        return apply_filters( 'frm_countries', array(
1245
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1246
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1247
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1248
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1249
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1250
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1251
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1252
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1253
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1254
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1255
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1256
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1257
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1258
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1259
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1260
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1261
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1262
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1263
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1264
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1265
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1266
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1267
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1268
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1269
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1270
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1271
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1272
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1273
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1274
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1275
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1276
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1277
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1278
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1279
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1280
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1281
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1282
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1283
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1284
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1285
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1286
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1287
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1288
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1289
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1290
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1291
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1292
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1293
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1294
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1295
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1296
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1297
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1298
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1299
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1300
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1301
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1302
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1303
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1304
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1305
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1306
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1307
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1308
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1309
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1310
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1311
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1312
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1313
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1314
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1315
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1316
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1317
-            __( 'Zimbabwe', 'formidable' ),
1318
-        ) );
1319
-    }
1214
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1215
+				unset($k, $v);
1216
+			}
1217
+		} else {
1218
+			$val = str_replace($replace, $replace_with, $val);
1219
+		}
1220
+
1221
+		return $val;
1222
+	}
1223
+
1224
+	public static function get_us_states() {
1225
+		return apply_filters( 'frm_us_states', array(
1226
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1227
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1228
+			'DC' => 'District of Columbia',
1229
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1230
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1231
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1232
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1233
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1234
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1235
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1236
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1237
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1238
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1239
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1240
+		) );
1241
+	}
1242
+
1243
+	public static function get_countries() {
1244
+		return apply_filters( 'frm_countries', array(
1245
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1246
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1247
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1248
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1249
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1250
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1251
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1252
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1253
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1254
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1255
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1256
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1257
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1258
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1259
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1260
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1261
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1262
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1263
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1264
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1265
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1266
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1267
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1268
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1269
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1270
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1271
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1272
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1273
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1274
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1275
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1276
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1277
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1278
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1279
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1280
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1281
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1282
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1283
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1284
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1285
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1286
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1287
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1288
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1289
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1290
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1291
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1292
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1293
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1294
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1295
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1296
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1297
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1298
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1299
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1300
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1301
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1302
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1303
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1304
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1305
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1306
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1307
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1308
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1309
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1310
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1311
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1312
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1313
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1314
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1315
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1316
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1317
+			__( 'Zimbabwe', 'formidable' ),
1318
+		) );
1319
+	}
1320 1320
 
1321 1321
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1322 1322
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1323 1323
 
1324
-        $states = FrmFieldsHelper::get_us_states();
1325
-        $state_abv = array_keys($states);
1326
-        sort($state_abv);
1324
+		$states = FrmFieldsHelper::get_us_states();
1325
+		$state_abv = array_keys($states);
1326
+		sort($state_abv);
1327 1327
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1328 1328
 
1329
-        $states = array_values($states);
1330
-        sort($states);
1329
+		$states = array_values($states);
1330
+		sort($states);
1331 1331
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1332
-        unset($state_abv, $states);
1332
+		unset($state_abv, $states);
1333 1333
 
1334 1334
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1335
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1336
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1337
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1338
-        );
1335
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1336
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1337
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1338
+		);
1339 1339
 
1340 1340
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1341
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1342
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1343
-        );
1341
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1342
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1343
+		);
1344 1344
 
1345 1345
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1346
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1347
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1348
-        );
1346
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1347
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1348
+		);
1349 1349
 
1350 1350
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1351
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1352
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1353
-        );
1351
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1352
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1353
+		);
1354 1354
 
1355 1355
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1356
-    }
1356
+	}
1357 1357
 
1358 1358
 	public static function field_selection() {
1359 1359
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 		return FrmField::is_required( $field );
1391 1391
 	}
1392 1392
 
1393
-    public static function maybe_get_field( &$field ) {
1393
+	public static function maybe_get_field( &$field ) {
1394 1394
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1395 1395
 		FrmField::maybe_get_field( $field );
1396
-    }
1396
+	}
1397 1397
 }
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
173 173
 		$defaults = array(
174
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
175
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
174
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
175
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
176 176
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
177 177
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
178 178
 		);
179 179
 
180 180
 		$msg = FrmField::get_option( $field, $error );
181
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
181
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
182 182
 		$msg = do_shortcode( $msg );
183 183
 		return $msg;
184 184
 	}
185 185
 
186 186
     public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
187
+        $fields = FrmField::get_all_for_form( $form_id );
188
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
189 189
         return $fields;
190 190
     }
191 191
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 </div>
209 209
 DEFAULT_HTML;
210 210
         } else {
211
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
211
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
212 212
         }
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
214
+        return apply_filters( 'frm_custom_html', $default_html, $type );
215 215
     }
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
219 219
 
220 220
         $defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
             'field_plus_id' => '',
224 224
             'section_id'    => '',
225 225
         );
226
-        $args = wp_parse_args($args, $defaults);
226
+        $args = wp_parse_args( $args, $defaults );
227 227
         $field_name = $args['field_name'];
228 228
         $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
229
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
231
+        if ( FrmField::is_multiple_select( $field ) ) {
232 232
             $field_name .= '[]';
233 233
         }
234 234
 
235 235
         //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
236
+        $html = str_replace( '[id]', $field_id, $html );
237 237
 
238 238
         // Remove the for attribute for captcha
239 239
         if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
240
+            $html = str_replace( ' for="field_[key]"', '', $html );
241 241
         }
242 242
 
243 243
         // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
244
+        $html = str_replace( 'field_[key]', $html_id, $html );
245 245
 
246 246
         //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+        $html = str_replace( '[key]', $field['field_key'], $html );
248 248
 
249 249
         //replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251 251
         if ( ! is_array( $errors ) ) {
252 252
             $errors = array();
253 253
         }
254
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
254
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
255 255
 
256 256
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257 257
         if ( $field['type'] == 'divider' ) {
258 258
             if ( FrmField::is_option_true( $field, 'description' ) ) {
259 259
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260 260
             } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
261
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
262 262
             }
263 263
         }
264 264
 
@@ -268,41 +268,41 @@  discard block
 block discarded – undo
268 268
 
269 269
         //replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+        $html = str_replace( '[required_class]', $required_class, $html );
272 272
 
273 273
         //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
274
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
275 275
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278 278
         //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+        $html = str_replace( '[field_name]', $field['name'], $html );
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
         //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
288
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
289 289
         global $frm_vars;
290 290
         $frm_settings = FrmAppHelper::get_settings();
291 291
 
292 292
         foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
293
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296 296
             $replace_with = '';
297 297
 
298 298
             if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
299
+                if ( isset( $atts['opt'] ) ) {
300
+                    $atts['opt'] --;
301 301
                 }
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
303
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
304
+                if ( isset( $atts['class'] ) ) {
305
+                    unset( $atts['class'] );
306 306
                 }
307 307
 
308 308
                 $field['shortcodes'] = $atts;
@@ -311,33 +311,33 @@  discard block
 block discarded – undo
311 311
                 $replace_with = ob_get_contents();
312 312
                 ob_end_clean();
313 313
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
314
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
315 315
             }
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
317
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
318 318
         }
319 319
 
320 320
 		if ( $form ) {
321 321
             $form = (array) $form;
322 322
 
323 323
             //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
324
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
325 325
 
326 326
             //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
327
+            $html = str_replace( '[form_name]', $form['name'], $html );
328 328
         }
329 329
         $html .= "\n";
330 330
 
331 331
         //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
332
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
333 333
             return $html;
334 334
         }
335 335
 
336 336
         //If field is in repeating section
337 337
         if ( $args['section_id'] ) {
338
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
338
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
339 339
         } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
340
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
341 341
         }
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
384 384
 		// Add error class
385
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
385
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
386 386
 
387 387
 		// Add label position class
388 388
 		$classes .= ' frm_' . $field['label'] . '_container';
389 389
 
390 390
 		// Add CSS layout classes
391 391
 		if ( ! empty( $field['classes'] ) ) {
392
-			if ( ! strpos( $html, 'frm_form_field ') ) {
392
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
393 393
 				$classes .= ' frm_form_field';
394 394
 			}
395 395
 			$classes .= ' ' . $field['classes'];
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
431
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
432
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
433
+            $tag = str_replace( ']', '', $tag );
434
+            $tags = explode( ' ', $tag );
435
+            if ( is_array( $tags ) ) {
436 436
                 $tag = $tags[0];
437 437
             }
438 438
         } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
439
+            $tag = $shortcodes[$with_tags - 1][$short_key];
440 440
         }
441 441
 
442 442
         return $tag;
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 
481 481
 	public static function show_single_option( $field ) {
482 482
         $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
483
+        $html_id = self::get_html_id( $field );
484 484
         foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
485
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
486
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
487 487
 
488 488
             // If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 
499 499
 	public static function dropdown_categories( $args ) {
500 500
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
501
-        $args = wp_parse_args($args, $defaults);
501
+        $args = wp_parse_args( $args, $defaults );
502 502
 
503 503
         if ( ! $args['field'] ) {
504 504
             return;
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
509 509
         }
510 510
 
511
-        $id = self::get_html_id($args['field']);
511
+        $id = self::get_html_id( $args['field'] );
512 512
         $class = $args['field']['type'];
513 513
 
514
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
515
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
514
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
515
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
516 516
 
517
-        if ( is_array($args['field']['value']) ) {
518
-            if ( ! empty($exclude) ) {
519
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
517
+        if ( is_array( $args['field']['value'] ) ) {
518
+            if ( ! empty( $exclude ) ) {
519
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
520 520
             }
521
-            $selected = reset($args['field']['value']);
521
+            $selected = reset( $args['field']['value'] );
522 522
         } else {
523 523
             $selected = $args['field']['value'];
524 524
         }
@@ -529,40 +529,40 @@  discard block
 block discarded – undo
529 529
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
530 530
         );
531 531
 
532
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
532
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
533 533
 
534 534
         if ( FrmAppHelper::pro_is_installed() ) {
535
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
536
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
535
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
536
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
537 537
             if ( ! $tax_atts['taxonomy'] ) {
538 538
                 return;
539 539
             }
540 540
 
541 541
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
542
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
542
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
543 543
                 $tax_atts['exclude_tree'] = $exclude;
544 544
             }
545 545
         }
546 546
 
547
-        $dropdown = wp_dropdown_categories($tax_atts);
547
+        $dropdown = wp_dropdown_categories( $tax_atts );
548 548
 
549
-        $add_html = FrmFieldsController::input_html($args['field'], false);
549
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
550 550
 
551 551
         if ( FrmAppHelper::pro_is_installed() ) {
552
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
552
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
553 553
         }
554 554
 
555 555
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
556 556
 
557
-        if ( is_array($args['field']['value']) ) {
557
+        if ( is_array( $args['field']['value'] ) ) {
558 558
             $skip = true;
559 559
             foreach ( $args['field']['value'] as $v ) {
560 560
 				if ( $skip ) {
561 561
                     $skip = false;
562 562
                     continue;
563 563
                 }
564
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
565
-                unset($v);
564
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
565
+                unset( $v );
566 566
             }
567 567
         }
568 568
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     }
571 571
 
572 572
 	public static function get_term_link( $tax_id ) {
573
-        $tax = get_taxonomy($tax_id);
573
+        $tax = get_taxonomy( $tax_id );
574 574
         if ( ! $tax ) {
575 575
             return;
576 576
         }
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
580 580
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
581 581
         );
582
-        unset($tax);
582
+        unset( $tax );
583 583
 
584 584
         return $link;
585 585
     }
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 		$observed_value = wp_kses_post( $observed_value );
594 594
 		$hide_opt = wp_kses_post( $hide_opt );
595 595
 
596
-        if ( is_array($observed_value) ) {
597
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
596
+        if ( is_array( $observed_value ) ) {
597
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
598 598
         }
599 599
 
600 600
         $m = false;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
         } else if ( $cond == '<' ) {
608 608
             $m = $observed_value < $hide_opt;
609 609
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
610
-            $m = stripos($observed_value, $hide_opt);
610
+            $m = stripos( $observed_value, $hide_opt );
611 611
             if ( $cond == 'not LIKE' ) {
612 612
                 $m = ( $m === false ) ? true : false;
613 613
             } else {
@@ -620,23 +620,23 @@  discard block
 block discarded – undo
620 620
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
621 621
         $m = false;
622 622
         if ( $cond == '==' ) {
623
-            if ( is_array($hide_opt) ) {
624
-                $m = array_intersect($hide_opt, $observed_value);
625
-                $m = empty($m) ? false : true;
623
+            if ( is_array( $hide_opt ) ) {
624
+                $m = array_intersect( $hide_opt, $observed_value );
625
+                $m = empty( $m ) ? false : true;
626 626
             } else {
627
-                $m = in_array($hide_opt, $observed_value);
627
+                $m = in_array( $hide_opt, $observed_value );
628 628
             }
629 629
         } else if ( $cond == '!=' ) {
630
-            $m = ! in_array($hide_opt, $observed_value);
630
+            $m = ! in_array( $hide_opt, $observed_value );
631 631
         } else if ( $cond == '>' ) {
632
-            $min = min($observed_value);
632
+            $min = min( $observed_value );
633 633
             $m = $min > $hide_opt;
634 634
         } else if ( $cond == '<' ) {
635
-            $max = max($observed_value);
635
+            $max = max( $observed_value );
636 636
             $m = $max < $hide_opt;
637 637
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
638 638
             foreach ( $observed_value as $ob ) {
639
-                $m = strpos($ob, $hide_opt);
639
+                $m = strpos( $ob, $hide_opt );
640 640
                 if ( $m !== false ) {
641 641
                     $m = true;
642 642
                     break;
@@ -657,27 +657,27 @@  discard block
 block discarded – undo
657 657
      * @return string
658 658
      */
659 659
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
660
-        if ( strpos($value, '[sitename]') !== false ) {
660
+        if ( strpos( $value, '[sitename]' ) !== false ) {
661 661
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
662
-            $value = str_replace('[sitename]', $new_value, $value);
662
+            $value = str_replace( '[sitename]', $new_value, $value );
663 663
         }
664 664
 
665
-        $value = apply_filters('frm_content', $value, $form, $entry);
666
-        $value = do_shortcode($value);
665
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
666
+        $value = do_shortcode( $value );
667 667
 
668 668
         return $value;
669 669
     }
670 670
 
671 671
 	public static function get_shortcodes( $content, $form_id ) {
672 672
         if ( FrmAppHelper::pro_is_installed() ) {
673
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
673
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
674 674
         }
675 675
 
676 676
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
677 677
 
678
-        $tagregexp = self::allowed_shortcodes($fields);
678
+        $tagregexp = self::allowed_shortcodes( $fields );
679 679
 
680
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
680
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
681 681
 
682 682
         return $matches;
683 683
     }
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
             $tagregexp[] = $field->field_key;
696 696
         }
697 697
 
698
-        $tagregexp = implode('|', $tagregexp);
698
+        $tagregexp = implode( '|', $tagregexp );
699 699
         return $tagregexp;
700 700
     }
701 701
 
@@ -707,28 +707,28 @@  discard block
 block discarded – undo
707 707
         );
708 708
 
709 709
         foreach ( $shortcodes[0] as $short_key => $tag ) {
710
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
710
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
711 711
 
712
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
713
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
714
-                $tags = explode(' ', $tag);
715
-                if ( is_array($tags) ) {
712
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
713
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
714
+                $tags = explode( ' ', $tag );
715
+                if ( is_array( $tags ) ) {
716 716
                     $tag = $tags[0];
717 717
                 }
718 718
             } else {
719
-                $tag = $shortcodes[2][ $short_key ];
719
+                $tag = $shortcodes[2][$short_key];
720 720
             }
721 721
 
722 722
             switch ( $tag ) {
723 723
                 case 'id':
724 724
                 case 'key':
725 725
                 case 'ip':
726
-                    $replace_with = $shortcode_values[ $tag ];
726
+                    $replace_with = $shortcode_values[$tag];
727 727
                 break;
728 728
 
729 729
                 case 'user_agent':
730 730
                 case 'user-agent':
731
-                    $entry->description = maybe_unserialize($entry->description);
731
+                    $entry->description = maybe_unserialize( $entry->description );
732 732
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
733 733
                 break;
734 734
 
@@ -736,25 +736,25 @@  discard block
 block discarded – undo
736 736
                 case 'created-at':
737 737
                 case 'updated_at':
738 738
                 case 'updated-at':
739
-                    if ( isset($atts['format']) ) {
739
+                    if ( isset( $atts['format'] ) ) {
740 740
                         $time_format = ' ';
741 741
                     } else {
742
-                        $atts['format'] = get_option('date_format');
742
+                        $atts['format'] = get_option( 'date_format' );
743 743
                         $time_format = '';
744 744
                     }
745 745
 
746
-                    $this_tag = str_replace('-', '_', $tag);
747
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
748
-                    unset($this_tag);
746
+                    $this_tag = str_replace( '-', '_', $tag );
747
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
748
+                    unset( $this_tag );
749 749
                 break;
750 750
 
751 751
                 case 'created_by':
752 752
                 case 'created-by':
753 753
                 case 'updated_by':
754 754
                 case 'updated-by':
755
-                    $this_tag = str_replace('-', '_', $tag);
755
+                    $this_tag = str_replace( '-', '_', $tag );
756 756
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
757
-                    unset($this_tag);
757
+                    unset( $this_tag );
758 758
                 break;
759 759
 
760 760
                 case 'admin_email':
@@ -771,16 +771,16 @@  discard block
 block discarded – undo
771 771
                         break;
772 772
                     }
773 773
 
774
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
774
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
775 775
 
776 776
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
777 777
 
778 778
                     $atts['entry_id'] = $entry->id;
779 779
                     $atts['entry_key'] = $entry->item_key;
780 780
 
781
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
781
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
782 782
                         $replace_with = $field->name;
783
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
783
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
784 784
                         $replace_with = $field->description;
785 785
 					} else {
786 786
 						$string_value = $replace_with;
@@ -795,15 +795,15 @@  discard block
 block discarded – undo
795 795
 						}
796 796
 					}
797 797
 
798
-                    unset($field);
798
+                    unset( $field );
799 799
                 break;
800 800
             }
801 801
 
802
-            if ( isset($replace_with) ) {
803
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
802
+            if ( isset( $replace_with ) ) {
803
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
804 804
             }
805 805
 
806
-            unset($atts, $conditional, $replace_with);
806
+            unset( $atts, $conditional, $replace_with );
807 807
 		}
808 808
 
809 809
 		return $content;
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
         $new_value = '';
820 820
         switch ( $tag ) {
821 821
             case 'admin_email':
822
-                $new_value = get_option('admin_email');
822
+                $new_value = get_option( 'admin_email' );
823 823
                 break;
824 824
             case 'siteurl':
825 825
                 $new_value = FrmAppHelper::site_url();
@@ -845,28 +845,28 @@  discard block
 block discarded – undo
845 845
      * @return string|array
846 846
      */
847 847
     public static function process_get_shortcode( $atts, $return_array = false ) {
848
-        if ( ! isset($atts['param']) ) {
848
+        if ( ! isset( $atts['param'] ) ) {
849 849
             return '';
850 850
         }
851 851
 
852
-        if ( strpos($atts['param'], '&#91;') ) {
853
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
854
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
852
+        if ( strpos( $atts['param'], '&#91;' ) ) {
853
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
854
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
855 855
         }
856 856
 
857
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
857
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
858 858
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
859 859
 
860 860
         if ( $new_value == '' ) {
861
-            if ( ! isset($atts['prev_val']) ) {
861
+            if ( ! isset( $atts['prev_val'] ) ) {
862 862
                 $atts['prev_val'] = '';
863 863
             }
864 864
 
865
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
865
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
866 866
         }
867 867
 
868
-        if ( is_array($new_value) && ! $return_array ) {
869
-            $new_value = implode(', ', $new_value);
868
+        if ( is_array( $new_value ) && ! $return_array ) {
869
+            $new_value = implode( ', ', $new_value );
870 870
         }
871 871
 
872 872
         return $new_value;
@@ -879,12 +879,12 @@  discard block
 block discarded – undo
879 879
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
880 880
 
881 881
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
882
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
883
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
884
-                if ( is_array($replace_with) ) {
885
-                    $replace_with = implode("\n", $replace_with);
882
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
883
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
884
+                if ( is_array( $replace_with ) ) {
885
+                    $replace_with = implode( "\n", $replace_with );
886 886
                 }
887
-                $replace_with = wpautop($replace_with);
887
+                $replace_with = wpautop( $replace_with );
888 888
             }
889 889
 			unset( $autop );
890 890
 		} else if ( is_array( $replace_with ) ) {
@@ -906,14 +906,14 @@  discard block
 block discarded – undo
906 906
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
907 907
 
908 908
         $field_types = array();
909
-        if ( in_array($type, $single_input) ) {
909
+        if ( in_array( $type, $single_input ) ) {
910 910
             self::field_types_for_input( $single_input, $field_selection, $field_types );
911
-        } else if ( in_array($type, $multiple_input) ) {
911
+        } else if ( in_array( $type, $multiple_input ) ) {
912 912
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
913
-        } else if ( in_array($type, $other_type) ) {
913
+        } else if ( in_array( $type, $other_type ) ) {
914 914
             self::field_types_for_input( $other_type, $field_selection, $field_types );
915
-		} else if ( isset( $field_selection[ $type ] ) ) {
916
-            $field_types[ $type ] = $field_selection[ $type ];
915
+		} else if ( isset( $field_selection[$type] ) ) {
916
+            $field_types[$type] = $field_selection[$type];
917 917
         }
918 918
 
919 919
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 
923 923
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
924 924
         foreach ( $inputs as $input ) {
925
-            $field_types[ $input ] = $fields[ $input ];
926
-            unset($input);
925
+            $field_types[$input] = $fields[$input];
926
+            unset( $input );
927 927
         }
928 928
     }
929 929
 
@@ -968,21 +968,21 @@  discard block
 block discarded – undo
968 968
 		// Check posted vals before checking saved values
969 969
 
970 970
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
971
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
971
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
972 972
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
973
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
973
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
974 974
 			} else {
975
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
975
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
976 976
 			}
977 977
 			return $other_val;
978 978
 
979
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
979
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
980 980
 			// For normal fields
981 981
 
982 982
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
983
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
983
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
984 984
 			} else {
985
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
985
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
986 986
 			}
987 987
 			return $other_val;
988 988
 		}
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
992 992
 			// Check if there is an "other" val in saved value and make sure the
993 993
 			// "other" val is not equal to the Other checkbox option
994
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
995
-				$other_val = $field['value'][ $opt_key ];
994
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
995
+				$other_val = $field['value'][$opt_key];
996 996
 			}
997 997
 		} else {
998 998
 			/**
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 				// Multi-select dropdowns - key is not preserved
1005 1005
 				if ( is_array( $field['value'] ) ) {
1006 1006
 					$o_key = array_search( $temp_val, $field['value'] );
1007
-					if ( isset( $field['value'][ $o_key ] ) ) {
1008
-						unset( $field['value'][ $o_key ], $o_key );
1007
+					if ( isset( $field['value'][$o_key] ) ) {
1008
+						unset( $field['value'][$o_key], $o_key );
1009 1009
 					}
1010 1010
 				} else if ( $temp_val == $field['value'] ) {
1011 1011
 					// For radio and regular dropdowns
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 	private static function set_other_name( $args, &$other_args ) {
1063 1063
 		//Set up name for other field
1064 1064
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1065
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1065
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1066 1066
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1067 1067
 
1068 1068
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 		// Count should only be greater than 3 if inside of a repeating section
1089 1089
 		if ( count( $temp_array ) > 3 ) {
1090 1090
 			$parent = str_replace( ']', '', $temp_array[1] );
1091
-			$pointer = str_replace( ']', '', $temp_array[2]);
1091
+			$pointer = str_replace( ']', '', $temp_array[2] );
1092 1092
 		}
1093 1093
 
1094 1094
 		// Get text for "other" text field
@@ -1207,15 +1207,15 @@  discard block
 block discarded – undo
1207 1207
 			$replace_with[] = '[' . $new . ']';
1208 1208
 			$replace[] = '[' . $old . ' ';
1209 1209
 			$replace_with[] = '[' . $new . ' ';
1210
-            unset($old, $new);
1210
+            unset( $old, $new );
1211 1211
         }
1212 1212
 		if ( is_array( $val ) ) {
1213 1213
 			foreach ( $val as $k => $v ) {
1214
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1215
-                unset($k, $v);
1214
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1215
+                unset( $k, $v );
1216 1216
             }
1217 1217
         } else {
1218
-            $val = str_replace($replace, $replace_with, $val);
1218
+            $val = str_replace( $replace, $replace_with, $val );
1219 1219
         }
1220 1220
 
1221 1221
         return $val;
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
             'DC' => 'District of Columbia',
1229 1229
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1230 1230
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1231
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1231
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1232 1232
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1233 1233
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1234 1234
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1319,35 +1319,35 @@  discard block
 block discarded – undo
1319 1319
     }
1320 1320
 
1321 1321
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1322
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1322
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1323 1323
 
1324 1324
         $states = FrmFieldsHelper::get_us_states();
1325
-        $state_abv = array_keys($states);
1326
-        sort($state_abv);
1327
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1325
+        $state_abv = array_keys( $states );
1326
+        sort( $state_abv );
1327
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1328 1328
 
1329
-        $states = array_values($states);
1330
-        sort($states);
1331
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1332
-        unset($state_abv, $states);
1329
+        $states = array_values( $states );
1330
+        sort( $states );
1331
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1332
+        unset( $state_abv, $states );
1333 1333
 
1334
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1334
+		$prepop[__( 'Age', 'formidable' )] = array(
1335 1335
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1336 1336
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1337 1337
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1338 1338
         );
1339 1339
 
1340
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1340
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1341 1341
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1342 1342
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1343 1343
         );
1344 1344
 
1345
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1345
+		$prepop[__( 'Importance', 'formidable' )] = array(
1346 1346
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1347 1347
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1348 1348
         );
1349 1349
 
1350
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1350
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1351 1351
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1352 1352
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1353 1353
         );
Please login to merge, or discard this patch.
classes/models/FrmDb.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
 	 *
309 309
 	 * @since 2.02.05
310 310
 	 * @param string $key
311
-	 * @param int|string $value
311
+	 * @param string $value
312 312
 	 * @param string $where
313 313
 	 */
314 314
     private static function add_query_placeholder( $key, $value, &$where ) {
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     var $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
         global $wpdb;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $frm_db_version = FrmAppHelper::$db_version;
25 25
         $old_db_version = (float) $old_db_version;
26 26
         if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
27
+            $old_db_version = get_option( 'frm_db_version' );
28 28
         }
29 29
 
30 30
         if ( $frm_db_version != $old_db_version ) {
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36 36
             $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
37
+            $this->migrate_data( $frm_db_version, $old_db_version );
38 38
 
39 39
             /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
40
+            update_option( 'frm_db_version', $frm_db_version );
41 41
 
42 42
             /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43 43
             FrmXMLController::add_default_templates();
44 44
         }
45 45
 
46
-        do_action('frm_after_install');
46
+        do_action( 'frm_after_install' );
47 47
 
48 48
         /**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
156
+            unset( $q );
157 157
         }
158 158
     }
159 159
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param string $starts_with
179 179
      */
180 180
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
-        if ( empty($args) ) {
181
+        if ( empty( $args ) ) {
182 182
 			// add an arg to prevent prepare from failing
183 183
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
184 184
 			return;
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
     private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239 239
 		$key = trim( $key );
240 240
 
241
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
-            $k = explode(' ', $key);
241
+        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
242
+            $k = explode( ' ', $key );
243 243
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244 244
             $values[] = '%Y-%m-%d %H:%i:%s';
245 245
         } else {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         if ( is_array( $value ) ) {
253 253
             // translate array of values to "in"
254 254
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
255
-				$where = preg_replace('/' . $key . '$/', '', $where);
255
+				$where = preg_replace( '/' . $key . '$/', '', $where );
256 256
 				$where .= '(';
257 257
 				$start = true;
258 258
 				foreach ( $value as $v ) {
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 		);
404 404
 
405 405
 		$where_is = strtolower( $where_is );
406
-		if ( isset( $switch_to[ $where_is ] ) ) {
407
-			return ' ' . $switch_to[ $where_is ];
406
+		if ( isset( $switch_to[$where_is] ) ) {
407
+			return ' ' . $switch_to[$where_is];
408 408
 		}
409 409
 
410 410
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     private static function get_group_and_table_name( &$table, &$group ) {
427 427
 		global $wpdb, $wpmuBaseTablePrefix;
428 428
 
429
-        $table_parts = explode(' ', $table);
430
-        $group = reset($table_parts);
429
+        $table_parts = explode( ' ', $table );
430
+        $group = reset( $table_parts );
431 431
         $group = str_replace( $wpdb->prefix, '', $group );
432 432
 
433 433
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
445
-        if ( ! is_array($args) ) {
445
+        if ( ! is_array( $args ) ) {
446 446
 			$args = array( 'order_by' => $args );
447 447
         }
448 448
 
@@ -457,16 +457,16 @@  discard block
 block discarded – undo
457 457
         $temp_args = $args;
458 458
         foreach ( $temp_args as $k => $v ) {
459 459
             if ( $v == '' ) {
460
-				unset( $args[ $k ] );
460
+				unset( $args[$k] );
461 461
                 continue;
462 462
             }
463 463
 
464 464
             if ( $k == 'limit' ) {
465
-				$args[ $k ] = FrmAppHelper::esc_limit( $v );
465
+				$args[$k] = FrmAppHelper::esc_limit( $v );
466 466
             }
467 467
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
468 468
             if ( strpos( $v, $db_name ) === false ) {
469
-				$args[ $k ] = $db_name . ' ' . $v;
469
+				$args[$k] = $db_name . ' ' . $v;
470 470
             }
471 471
         }
472 472
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 
494 494
 		$query = self::generate_query_string_from_pieces( $columns, $table, $where );
495 495
 
496
-		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) );
496
+		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) );
497 497
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' );
498 498
 
499 499
 		return $results;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     public function uninstall() {
533 533
 		if ( ! current_user_can( 'administrator' ) ) {
534 534
             $frm_settings = FrmAppHelper::get_settings();
535
-            wp_die($frm_settings->admin_permission);
535
+            wp_die( $frm_settings->admin_permission );
536 536
         }
537 537
 
538 538
         global $wpdb, $wp_roles;
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
543 543
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
544 544
 
545
-        delete_option('frm_options');
546
-        delete_option('frm_db_version');
545
+        delete_option( 'frm_options' );
546
+        delete_option( 'frm_db_version' );
547 547
 
548 548
         //delete roles
549 549
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
552 552
             foreach ( $roles as $role => $details ) {
553 553
                 $wp_roles->remove_cap( $role, $frm_role );
554
-                unset($role, $details);
554
+                unset( $role, $details );
555 555
     		}
556
-    		unset($frm_role, $frm_role_description);
556
+    		unset( $frm_role, $frm_role_description );
557 557
 		}
558
-		unset($roles, $frm_roles);
558
+		unset( $roles, $frm_roles );
559 559
 
560 560
 		// delete actions, views, and styles
561 561
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
579 579
 
580
-        do_action('frm_after_uninstall');
580
+        do_action( 'frm_after_uninstall' );
581 581
         return true;
582 582
     }
583 583
 
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
 
635 635
         $updated = 0;
636 636
         foreach ( $fields as $f ) {
637
-            $f->field_options = maybe_unserialize($f->field_options);
638
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
637
+            $f->field_options = maybe_unserialize( $f->field_options );
638
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
639 639
                 continue;
640 640
             }
641 641
 
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
             $f->field_options['size'] .= 'px';
644 644
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
645 645
             if ( $u ) {
646
-                $updated++;
646
+                $updated ++;
647 647
             }
648
-            unset($f);
648
+            unset( $f );
649 649
         }
650 650
 
651 651
         // Change the characters in widgets to pixels
652
-        $widgets = get_option('widget_frm_show_form');
653
-        if ( empty($widgets) ) {
652
+        $widgets = get_option( 'widget_frm_show_form' );
653
+        if ( empty( $widgets ) ) {
654 654
             return;
655 655
         }
656 656
 
657
-        $widgets = maybe_unserialize($widgets);
657
+        $widgets = maybe_unserialize( $widgets );
658 658
         foreach ( $widgets as $k => $widget ) {
659
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
659
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
660 660
                 continue;
661 661
             }
662 662
 			$size = round( $pixel_conversion * (int) $widget['size'] );
663 663
             $size .= 'px';
664
-			$widgets[ $k ]['size'] = $size;
664
+			$widgets[$k]['size'] = $size;
665 665
         }
666
-        update_option('widget_frm_show_form', $widgets);
666
+        update_option( 'widget_frm_show_form', $widgets );
667 667
     }
668 668
 
669 669
     /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			}
713 713
 
714 714
             // Format form options
715
-            $form_options = maybe_unserialize($form->options);
715
+            $form_options = maybe_unserialize( $form->options );
716 716
 
717 717
             // Migrate settings to actions
718 718
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     private function migrate_to_11() {
723 723
         global $wpdb;
724 724
 
725
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
725
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
726 726
 
727 727
         $sending = __( 'Sending', 'formidable' );
728 728
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
734 734
 </div>
735 735
 DEFAULT_HTML;
736
-        unset($sending, $img);
736
+        unset( $sending, $img );
737 737
 
738
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
738
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
739 739
         $draft_link = FrmFormsHelper::get_draft_link();
740 740
 		foreach ( $forms as $form ) {
741
-            $form->options = maybe_unserialize($form->options);
742
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
741
+            $form->options = maybe_unserialize( $form->options );
742
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
743 743
                 continue;
744 744
             }
745 745
 
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
751 751
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
752 752
             }
753
-            unset($form);
753
+            unset( $form );
754 754
         }
755
-        unset($forms);
755
+        unset( $forms );
756 756
     }
757 757
 
758 758
     private function migrate_to_6() {
@@ -781,16 +781,16 @@  discard block
 block discarded – undo
781 781
 </div>
782 782
 DEFAULT_HTML;
783 783
 
784
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
784
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
785 785
         foreach ( $fields as $field ) {
786
-            $field->field_options = maybe_unserialize($field->field_options);
786
+            $field->field_options = maybe_unserialize( $field->field_options );
787 787
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
788 788
                 $field->field_options['custom_html'] = $new_default_html;
789 789
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
790 790
             }
791
-            unset($field);
791
+            unset( $field );
792 792
         }
793
-        unset($default_html, $old_default_html, $fields);
793
+        unset( $default_html, $old_default_html, $fields );
794 794
     }
795 795
 
796 796
     private function migrate_to_4() {
@@ -808,6 +808,6 @@  discard block
 block discarded – undo
808 808
 
809 809
 	public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
810 810
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
811
-		return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
811
+		return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) );
812 812
 	}
813 813
 }
Please login to merge, or discard this patch.
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    var $fields;
5
-    var $forms;
6
-    var $entries;
7
-    var $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
13
-
14
-        global $wpdb;
15
-        $this->fields         = $wpdb->prefix . 'frm_fields';
16
-        $this->forms          = $wpdb->prefix . 'frm_forms';
17
-        $this->entries        = $wpdb->prefix . 'frm_items';
18
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
-    }
20
-
21
-    public function upgrade( $old_db_version = false ) {
22
-        global $wpdb;
23
-        //$frm_db_version is the version of the database we're moving to
24
-        $frm_db_version = FrmAppHelper::$db_version;
25
-        $old_db_version = (float) $old_db_version;
26
-        if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
28
-        }
29
-
30
-        if ( $frm_db_version != $old_db_version ) {
4
+	var $fields;
5
+	var $forms;
6
+	var $entries;
7
+	var $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13
+
14
+		global $wpdb;
15
+		$this->fields         = $wpdb->prefix . 'frm_fields';
16
+		$this->forms          = $wpdb->prefix . 'frm_forms';
17
+		$this->entries        = $wpdb->prefix . 'frm_items';
18
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
+	}
20
+
21
+	public function upgrade( $old_db_version = false ) {
22
+		global $wpdb;
23
+		//$frm_db_version is the version of the database we're moving to
24
+		$frm_db_version = FrmAppHelper::$db_version;
25
+		$old_db_version = (float) $old_db_version;
26
+		if ( ! $old_db_version ) {
27
+			$old_db_version = get_option('frm_db_version');
28
+		}
29
+
30
+		if ( $frm_db_version != $old_db_version ) {
31 31
 			// update rewrite rules for views and other custom post types
32 32
 			flush_rewrite_rules();
33 33
 
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36
-            $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
36
+			$this->create_tables();
37
+			$this->migrate_data($frm_db_version, $old_db_version);
38 38
 
39
-            /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
39
+			/***** SAVE DB VERSION *****/
40
+			update_option('frm_db_version', $frm_db_version);
41 41
 
42
-            /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
-            FrmXMLController::add_default_templates();
44
-        }
42
+			/**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
+			FrmXMLController::add_default_templates();
44
+		}
45 45
 
46
-        do_action('frm_after_install');
46
+		do_action('frm_after_install');
47 47
 
48
-        /**** update the styling settings ****/
48
+		/**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
50 50
 			$frm_style = new FrmStyle();
51 51
 			$frm_style->update( 'default' );
52 52
 		}
53
-    }
53
+	}
54 54
 
55
-    public function collation() {
56
-        global $wpdb;
57
-        if ( ! $wpdb->has_cap( 'collation' ) ) {
58
-            return '';
59
-        }
55
+	public function collation() {
56
+		global $wpdb;
57
+		if ( ! $wpdb->has_cap( 'collation' ) ) {
58
+			return '';
59
+		}
60 60
 
61
-        $charset_collate = '';
61
+		$charset_collate = '';
62 62
 		if ( ! empty( $wpdb->charset ) ) {
63 63
 			$charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset;
64 64
 		}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 			$charset_collate .= ' COLLATE ' . $wpdb->collate;
68 68
 		}
69 69
 
70
-        return $charset_collate;
71
-    }
70
+		return $charset_collate;
71
+	}
72 72
 
73
-    private function create_tables() {
74
-        $charset_collate = $this->collation();
75
-        $sql = array();
73
+	private function create_tables() {
74
+		$charset_collate = $this->collation();
75
+		$sql = array();
76 76
 
77
-        /* Create/Upgrade Fields Table */
77
+		/* Create/Upgrade Fields Table */
78 78
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
79 79
                 id int(11) NOT NULL auto_increment,
80 80
 				field_key varchar(100) default NULL,
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 UNIQUE KEY field_key (field_key)
94 94
         )';
95 95
 
96
-        /* Create/Upgrade Forms Table */
96
+		/* Create/Upgrade Forms Table */
97 97
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
98 98
                 id int(11) NOT NULL auto_increment,
99 99
 				form_key varchar(100) default NULL,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 UNIQUE KEY form_key (form_key)
112 112
         )';
113 113
 
114
-        /* Create/Upgrade Items Table */
114
+		/* Create/Upgrade Items Table */
115 115
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
116 116
                 id int(11) NOT NULL auto_increment,
117 117
 				item_key varchar(100) default NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 UNIQUE KEY item_key (item_key)
135 135
         )';
136 136
 
137
-        /* Create/Upgrade Meta Table */
137
+		/* Create/Upgrade Meta Table */
138 138
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
139 139
                 id int(11) NOT NULL auto_increment,
140 140
                 meta_value longtext default NULL,
@@ -146,43 +146,43 @@  discard block
 block discarded – undo
146 146
                 KEY item_id (item_id)
147 147
         )';
148 148
 
149
-        foreach ( $sql as $q ) {
149
+		foreach ( $sql as $q ) {
150 150
 			if ( function_exists( 'dbDelta' ) ) {
151 151
 				dbDelta( $q . $charset_collate . ';' );
152 152
 			} else {
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
157
-        }
158
-    }
156
+			unset($q);
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param integer $frm_db_version
160
+	/**
161
+	 * @param integer $frm_db_version
162 162
 	 * @param int $old_db_version
163
-     */
163
+	 */
164 164
 	private function migrate_data( $frm_db_version, $old_db_version ) {
165 165
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
166
-        foreach ( $migrations as $migration ) {
167
-            if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
166
+		foreach ( $migrations as $migration ) {
167
+			if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
168 168
 				$function_name = 'migrate_to_' . $migration;
169
-                $this->$function_name();
170
-            }
171
-        }
172
-    }
169
+				$this->$function_name();
170
+			}
171
+		}
172
+	}
173 173
 
174
-    /**
175
-     * Change array into format $wpdb->prepare can use
174
+	/**
175
+	 * Change array into format $wpdb->prepare can use
176 176
 	 *
177 177
 	 * @param array $args
178 178
 	 * @param string $starts_with
179
-     */
180
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
-        if ( empty($args) ) {
179
+	 */
180
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
+		if ( empty($args) ) {
182 182
 			// add an arg to prevent prepare from failing
183 183
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
184 184
 			return;
185
-        }
185
+		}
186 186
 
187 187
 		$where = '';
188 188
 		$values = array();
@@ -193,64 +193,64 @@  discard block
 block discarded – undo
193 193
 		}
194 194
 
195 195
 		$args = compact( 'where', 'values' );
196
-    }
196
+	}
197 197
 
198
-    /**
198
+	/**
199 199
 	 * @param array $args
200
-     * @param string $base_where
201
-     * @param string $where
200
+	 * @param string $base_where
201
+	 * @param string $where
202 202
 	 * @param array $values
203
-     */
204
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
205
-        $condition = ' AND';
206
-        if ( isset( $args['or'] ) ) {
207
-            $condition = ' OR';
208
-            unset( $args['or'] );
209
-        }
210
-
211
-        foreach ( $args as $key => $value ) {
212
-            $where .= empty( $where ) ? $base_where : $condition;
213
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
214
-            if ( is_numeric( $key ) || $array_inc_null ) {
215
-                $where .= ' ( ';
216
-                $nested_where = '';
217
-                if ( $array_inc_null ) {
218
-                    foreach ( $value as $val ) {
219
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
220
-                    }
221
-                } else {
222
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
223
-                }
224
-                $where .= $nested_where;
225
-                $where .= ' ) ';
226
-            } else {
227
-                self::interpret_array_to_sql( $key, $value, $where, $values );
228
-            }
229
-        }
230
-    }
231
-
232
-    /**
233
-     * @param string $key
203
+	 */
204
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
205
+		$condition = ' AND';
206
+		if ( isset( $args['or'] ) ) {
207
+			$condition = ' OR';
208
+			unset( $args['or'] );
209
+		}
210
+
211
+		foreach ( $args as $key => $value ) {
212
+			$where .= empty( $where ) ? $base_where : $condition;
213
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
214
+			if ( is_numeric( $key ) || $array_inc_null ) {
215
+				$where .= ' ( ';
216
+				$nested_where = '';
217
+				if ( $array_inc_null ) {
218
+					foreach ( $value as $val ) {
219
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
220
+					}
221
+				} else {
222
+					self::parse_where_from_array( $value, '', $nested_where, $values );
223
+				}
224
+				$where .= $nested_where;
225
+				$where .= ' ) ';
226
+			} else {
227
+				self::interpret_array_to_sql( $key, $value, $where, $values );
228
+			}
229
+		}
230
+	}
231
+
232
+	/**
233
+	 * @param string $key
234 234
 	 * @param string|array $value
235
-     * @param string $where
235
+	 * @param string $where
236 236
 	 * @param array $values
237
-     */
238
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
237
+	 */
238
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239 239
 		$key = trim( $key );
240 240
 
241
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
-            $k = explode(' ', $key);
243
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244
-            $values[] = '%Y-%m-%d %H:%i:%s';
245
-        } else {
241
+		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
+			$k = explode(' ', $key);
243
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244
+			$values[] = '%Y-%m-%d %H:%i:%s';
245
+		} else {
246 246
 			$where .= ' ' . $key;
247
-        }
247
+		}
248 248
 
249 249
 		$lowercase_key = explode( ' ', strtolower( $key ) );
250 250
 		$lowercase_key = end( $lowercase_key );
251 251
 
252
-        if ( is_array( $value ) ) {
253
-            // translate array of values to "in"
252
+		if ( is_array( $value ) ) {
253
+			// translate array of values to "in"
254 254
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
255 255
 				$where = preg_replace('/' . $key . '$/', '', $where);
256 256
 				$where .= '(';
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				$where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')';
269 269
 				$values = array_merge( $values, $value );
270 270
 			}
271
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
271
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
272 272
 			/**
273 273
 			 * Allow string to start or end with the value
274 274
 			 * If the key is like% then skip the first % for starts with
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 			$where .= ' %s';
288 288
 			$values[] = $start . FrmAppHelper::esc_like( $value ) . $end;
289 289
 
290
-        } else if ( $value === null ) {
291
-            $where .= ' IS NULL';
292
-        } else {
290
+		} else if ( $value === null ) {
291
+			$where .= ' IS NULL';
292
+		} else {
293 293
 			// allow a - to prevent = from being added
294 294
 			if ( substr( $key, -1 ) == '-' ) {
295 295
 				$where = rtrim( $where, '-' );
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 
300 300
 			self::add_query_placeholder( $key, $value, $where );
301 301
 
302
-            $values[] = $value;
303
-        }
304
-    }
302
+			$values[] = $value;
303
+		}
304
+	}
305 305
 
306 306
 	/**
307 307
 	 * Add %d, or %s to query
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 * @param int|string $value
312 312
 	 * @param string $where
313 313
 	 */
314
-    private static function add_query_placeholder( $key, $value, &$where ) {
314
+	private static function add_query_placeholder( $key, $value, &$where ) {
315 315
 		if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) {
316 316
 			$where .= '%d';
317 317
 		} else {
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 		}
320 320
 	}
321 321
 
322
-    /**
323
-     * @param string $table
322
+	/**
323
+	 * @param string $table
324 324
 	 * @param array $where
325 325
 	 * @param array $args
326 326
 	 * @return int
327
-     */
328
-    public static function get_count( $table, $where = array(), $args = array() ) {
329
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
330
-        return $count;
331
-    }
327
+	 */
328
+	public static function get_count( $table, $where = array(), $args = array() ) {
329
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
330
+		return $count;
331
+	}
332 332
 
333 333
 	/**
334 334
 	 * @param string $table
@@ -339,56 +339,56 @@  discard block
 block discarded – undo
339 339
 	 * @param string $type
340 340
 	 * @return array|null|string|object
341 341
 	 */
342
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
343
-        $group = '';
344
-        self::get_group_and_table_name( $table, $group );
342
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
343
+		$group = '';
344
+		self::get_group_and_table_name( $table, $group );
345 345
 		self::convert_options_to_array( $args, '', $limit );
346 346
 
347 347
 		$query = self::generate_query_string_from_pieces( $field, $table, $where, $args );
348 348
 
349 349
 		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) );
350 350
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type );
351
-        return $results;
352
-    }
351
+		return $results;
352
+	}
353 353
 
354
-    /**
355
-     * @param string $table
356
-     * @param array $where
354
+	/**
355
+	 * @param string $table
356
+	 * @param array $where
357 357
 	 * @param string $field
358 358
 	 * @param array $args
359 359
 	 * @param string $limit
360 360
 	 * @return mixed
361
-     */
362
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
363
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
364
-    }
365
-
366
-    /**
367
-     * @since 2.0
368
-     * @param string $table
361
+	 */
362
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
363
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
364
+	}
365
+
366
+	/**
367
+	 * @since 2.0
368
+	 * @param string $table
369 369
 	 * @param array $where
370 370
 	 * @param string $fields
371 371
 	 * @param array $args
372 372
 	 * @return mixed
373
-     */
374
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
375
-        $args['limit'] = 1;
376
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
377
-    }
378
-
379
-    /**
380
-     * Prepare a key/value array before DB call
373
+	 */
374
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
375
+		$args['limit'] = 1;
376
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
377
+	}
378
+
379
+	/**
380
+	 * Prepare a key/value array before DB call
381 381
 	 *
382
-     * @since 2.0
383
-     * @param string $table
382
+	 * @since 2.0
383
+	 * @param string $table
384 384
 	 * @param array $where
385 385
 	 * @param string $fields
386 386
 	 * @param array $args
387 387
 	 * @return mixed
388
-     */
389
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
390
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
391
-    }
388
+	 */
389
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
390
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
391
+	}
392 392
 
393 393
 	/**
394 394
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -425,59 +425,59 @@  discard block
 block discarded – undo
425 425
 		return '';
426 426
 	}
427 427
 
428
-    /**
429
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
430
-     * Also add the wpdb->prefix to the table if it's missing
431
-     *
432
-     * @param string $table
433
-     * @param string $group
434
-     */
435
-    private static function get_group_and_table_name( &$table, &$group ) {
428
+	/**
429
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
430
+	 * Also add the wpdb->prefix to the table if it's missing
431
+	 *
432
+	 * @param string $table
433
+	 * @param string $group
434
+	 */
435
+	private static function get_group_and_table_name( &$table, &$group ) {
436 436
 		global $wpdb, $wpmuBaseTablePrefix;
437 437
 
438
-        $table_parts = explode(' ', $table);
439
-        $group = reset($table_parts);
440
-        $group = str_replace( $wpdb->prefix, '', $group );
438
+		$table_parts = explode(' ', $table);
439
+		$group = reset($table_parts);
440
+		$group = str_replace( $wpdb->prefix, '', $group );
441 441
 
442 442
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
443 443
 		$group = str_replace( $prefix, '', $group );
444 444
 
445
-        if ( $group == $table ) {
446
-            $table = $wpdb->prefix . $table;
447
-        }
445
+		if ( $group == $table ) {
446
+			$table = $wpdb->prefix . $table;
447
+		}
448 448
 
449 449
 		// switch to singular group name
450 450
 		$group = rtrim( $group, 's' );
451
-    }
451
+	}
452 452
 
453
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
454
-        if ( ! is_array($args) ) {
453
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
454
+		if ( ! is_array($args) ) {
455 455
 			$args = array( 'order_by' => $args );
456
-        }
456
+		}
457 457
 
458
-        if ( ! empty( $order_by ) ) {
459
-            $args['order_by'] = $order_by;
460
-        }
458
+		if ( ! empty( $order_by ) ) {
459
+			$args['order_by'] = $order_by;
460
+		}
461 461
 
462
-        if ( ! empty( $limit ) ) {
463
-            $args['limit'] = $limit;
464
-        }
462
+		if ( ! empty( $limit ) ) {
463
+			$args['limit'] = $limit;
464
+		}
465 465
 
466
-        $temp_args = $args;
467
-        foreach ( $temp_args as $k => $v ) {
468
-            if ( $v == '' ) {
466
+		$temp_args = $args;
467
+		foreach ( $temp_args as $k => $v ) {
468
+			if ( $v == '' ) {
469 469
 				unset( $args[ $k ] );
470
-                continue;
471
-            }
470
+				continue;
471
+			}
472 472
 
473
-            if ( $k == 'limit' ) {
473
+			if ( $k == 'limit' ) {
474 474
 				$args[ $k ] = FrmAppHelper::esc_limit( $v );
475
-            }
476
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
477
-            if ( strpos( $v, $db_name ) === false ) {
475
+			}
476
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
477
+			if ( strpos( $v, $db_name ) === false ) {
478 478
 				$args[ $k ] = $db_name . ' ' . $v;
479
-            }
480
-        }
479
+			}
480
+		}
481 481
 
482 482
 		// Make sure LIMIT is the last argument
483 483
 		if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			unset( $args['limit'] );
486 486
 			$args['limit'] = $temp_limit;
487 487
 		}
488
-    }
488
+	}
489 489
 
490 490
 	/**
491 491
 	 * Get the associative array results for the given columns, table, and where query
@@ -538,31 +538,31 @@  discard block
 block discarded – undo
538 538
 		return $query;
539 539
 	}
540 540
 
541
-    public function uninstall() {
541
+	public function uninstall() {
542 542
 		if ( ! current_user_can( 'administrator' ) ) {
543
-            $frm_settings = FrmAppHelper::get_settings();
544
-            wp_die($frm_settings->admin_permission);
545
-        }
543
+			$frm_settings = FrmAppHelper::get_settings();
544
+			wp_die($frm_settings->admin_permission);
545
+		}
546 546
 
547
-        global $wpdb, $wp_roles;
547
+		global $wpdb, $wp_roles;
548 548
 
549 549
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
550 550
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
551 551
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
552 552
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
553 553
 
554
-        delete_option('frm_options');
555
-        delete_option('frm_db_version');
554
+		delete_option('frm_options');
555
+		delete_option('frm_db_version');
556 556
 
557
-        //delete roles
558
-        $frm_roles = FrmAppHelper::frm_capabilities();
559
-        $roles = get_editable_roles();
560
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
561
-            foreach ( $roles as $role => $details ) {
562
-                $wp_roles->remove_cap( $role, $frm_role );
563
-                unset($role, $details);
564
-    		}
565
-    		unset($frm_role, $frm_role_description);
557
+		//delete roles
558
+		$frm_roles = FrmAppHelper::frm_capabilities();
559
+		$roles = get_editable_roles();
560
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
561
+			foreach ( $roles as $role => $details ) {
562
+				$wp_roles->remove_cap( $role, $frm_role );
563
+				unset($role, $details);
564
+			}
565
+			unset($frm_role, $frm_role_description);
566 566
 		}
567 567
 		unset($roles, $frm_roles);
568 568
 
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 
587 587
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
588 588
 
589
-        do_action('frm_after_uninstall');
590
-        return true;
591
-    }
589
+		do_action('frm_after_uninstall');
590
+		return true;
591
+	}
592 592
 
593 593
 	/**
594 594
 	 * Migrate old styling settings. If sites are using the old
@@ -627,150 +627,150 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 	}
629 629
 
630
-    /**
631
-     * Change field size from character to pixel -- Multiply by 9
632
-     */
633
-    private function migrate_to_17() {
634
-        global $wpdb;
630
+	/**
631
+	 * Change field size from character to pixel -- Multiply by 9
632
+	 */
633
+	private function migrate_to_17() {
634
+		global $wpdb;
635 635
 		$pixel_conversion = 9;
636 636
 
637
-        // Get query arguments
637
+		// Get query arguments
638 638
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
639 639
 		$query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' );
640 640
 
641
-        // Get results
641
+		// Get results
642 642
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
643 643
 
644
-        $updated = 0;
645
-        foreach ( $fields as $f ) {
646
-            $f->field_options = maybe_unserialize($f->field_options);
647
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
648
-                continue;
649
-            }
644
+		$updated = 0;
645
+		foreach ( $fields as $f ) {
646
+			$f->field_options = maybe_unserialize($f->field_options);
647
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
648
+				continue;
649
+			}
650 650
 
651 651
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
652
-            $f->field_options['size'] .= 'px';
653
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
654
-            if ( $u ) {
655
-                $updated++;
656
-            }
657
-            unset($f);
658
-        }
659
-
660
-        // Change the characters in widgets to pixels
661
-        $widgets = get_option('widget_frm_show_form');
662
-        if ( empty($widgets) ) {
663
-            return;
664
-        }
665
-
666
-        $widgets = maybe_unserialize($widgets);
667
-        foreach ( $widgets as $k => $widget ) {
668
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
669
-                continue;
670
-            }
652
+			$f->field_options['size'] .= 'px';
653
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
654
+			if ( $u ) {
655
+				$updated++;
656
+			}
657
+			unset($f);
658
+		}
659
+
660
+		// Change the characters in widgets to pixels
661
+		$widgets = get_option('widget_frm_show_form');
662
+		if ( empty($widgets) ) {
663
+			return;
664
+		}
665
+
666
+		$widgets = maybe_unserialize($widgets);
667
+		foreach ( $widgets as $k => $widget ) {
668
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
669
+				continue;
670
+			}
671 671
 			$size = round( $pixel_conversion * (int) $widget['size'] );
672
-            $size .= 'px';
672
+			$size .= 'px';
673 673
 			$widgets[ $k ]['size'] = $size;
674
-        }
675
-        update_option('widget_frm_show_form', $widgets);
676
-    }
677
-
678
-    /**
679
-     * Migrate post and email notification settings into actions
680
-     */
681
-    private function migrate_to_16() {
682
-        global $wpdb;
683
-
684
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
685
-
686
-        /**
687
-        * Old email settings format:
688
-        * email_to: Email or field id
689
-        * also_email_to: array of fields ids
690
-        * reply_to: Email, field id, 'custom'
691
-        * cust_reply_to: string
692
-        * reply_to_name: field id, 'custom'
693
-        * cust_reply_to_name: string
694
-        * plain_text: 0|1
695
-        * email_message: string or ''
696
-        * email_subject: string or ''
697
-        * inc_user_info: 0|1
698
-        * update_email: 0, 1, 2
699
-        *
700
-        * Old autoresponder settings format:
701
-        * auto_responder: 0|1
702
-        * ar_email_message: string or ''
703
-        * ar_email_to: field id
704
-        * ar_plain_text: 0|1
705
-        * ar_reply_to_name: string
706
-        * ar_reply_to: string
707
-        * ar_email_subject: string
708
-        * ar_update_email: 0, 1, 2
709
-        *
710
-        * New email settings:
711
-        * post_content: json settings
712
-        * post_title: form id
713
-        * post_excerpt: message
714
-        *
715
-        */
716
-
717
-        foreach ( $forms as $form ) {
674
+		}
675
+		update_option('widget_frm_show_form', $widgets);
676
+	}
677
+
678
+	/**
679
+	 * Migrate post and email notification settings into actions
680
+	 */
681
+	private function migrate_to_16() {
682
+		global $wpdb;
683
+
684
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
685
+
686
+		/**
687
+		 * Old email settings format:
688
+		 * email_to: Email or field id
689
+		 * also_email_to: array of fields ids
690
+		 * reply_to: Email, field id, 'custom'
691
+		 * cust_reply_to: string
692
+		 * reply_to_name: field id, 'custom'
693
+		 * cust_reply_to_name: string
694
+		 * plain_text: 0|1
695
+		 * email_message: string or ''
696
+		 * email_subject: string or ''
697
+		 * inc_user_info: 0|1
698
+		 * update_email: 0, 1, 2
699
+		 *
700
+		 * Old autoresponder settings format:
701
+		 * auto_responder: 0|1
702
+		 * ar_email_message: string or ''
703
+		 * ar_email_to: field id
704
+		 * ar_plain_text: 0|1
705
+		 * ar_reply_to_name: string
706
+		 * ar_reply_to: string
707
+		 * ar_email_subject: string
708
+		 * ar_update_email: 0, 1, 2
709
+		 *
710
+		 * New email settings:
711
+		 * post_content: json settings
712
+		 * post_title: form id
713
+		 * post_excerpt: message
714
+		 *
715
+		 */
716
+
717
+		foreach ( $forms as $form ) {
718 718
 			if ( $form->is_template && $form->default_template ) {
719 719
 				// don't migrate the default templates since the email will be added anyway
720 720
 				continue;
721 721
 			}
722 722
 
723
-            // Format form options
724
-            $form_options = maybe_unserialize($form->options);
723
+			// Format form options
724
+			$form_options = maybe_unserialize($form->options);
725 725
 
726
-            // Migrate settings to actions
727
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
728
-        }
729
-    }
726
+			// Migrate settings to actions
727
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
728
+		}
729
+	}
730 730
 
731
-    private function migrate_to_11() {
732
-        global $wpdb;
731
+	private function migrate_to_11() {
732
+		global $wpdb;
733 733
 
734
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
734
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
735 735
 
736
-        $sending = __( 'Sending', 'formidable' );
736
+		$sending = __( 'Sending', 'formidable' );
737 737
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
738
-        $old_default_html = <<<DEFAULT_HTML
738
+		$old_default_html = <<<DEFAULT_HTML
739 739
 <div class="frm_submit">
740 740
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
741 741
 <input type="submit" value="[button_label]" [button_action] />
742 742
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
743 743
 </div>
744 744
 DEFAULT_HTML;
745
-        unset($sending, $img);
745
+		unset($sending, $img);
746 746
 
747
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
748
-        $draft_link = FrmFormsHelper::get_draft_link();
747
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
748
+		$draft_link = FrmFormsHelper::get_draft_link();
749 749
 		foreach ( $forms as $form ) {
750
-            $form->options = maybe_unserialize($form->options);
751
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
752
-                continue;
753
-            }
750
+			$form->options = maybe_unserialize($form->options);
751
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
752
+				continue;
753
+			}
754 754
 
755
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
756
-                $form->options['submit_html'] = $new_default_html;
755
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
756
+				$form->options['submit_html'] = $new_default_html;
757 757
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
758 758
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
759 759
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
760 760
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
761
-            }
762
-            unset($form);
763
-        }
764
-        unset($forms);
765
-    }
761
+			}
762
+			unset($form);
763
+		}
764
+		unset($forms);
765
+	}
766 766
 
767
-    private function migrate_to_6() {
768
-        global $wpdb;
767
+	private function migrate_to_6() {
768
+		global $wpdb;
769 769
 
770 770
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
771 771
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
772 772
 
773
-        $default_html = <<<DEFAULT_HTML
773
+		$default_html = <<<DEFAULT_HTML
774 774
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
775 775
     <label class="frm_pos_[label_position]">[field_name]
776 776
         <span class="frm_required">[required_label]</span>
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 </div>
781 781
 DEFAULT_HTML;
782 782
 
783
-        $old_default_html = <<<DEFAULT_HTML
783
+		$old_default_html = <<<DEFAULT_HTML
784 784
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
785 785
     <label class="frm_pos_[label_position]">[field_name]
786 786
         <span class="frm_required">[required_label]</span>
@@ -790,25 +790,25 @@  discard block
 block discarded – undo
790 790
 </div>
791 791
 DEFAULT_HTML;
792 792
 
793
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
794
-        foreach ( $fields as $field ) {
795
-            $field->field_options = maybe_unserialize($field->field_options);
793
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
794
+		foreach ( $fields as $field ) {
795
+			$field->field_options = maybe_unserialize($field->field_options);
796 796
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
797
-                $field->field_options['custom_html'] = $new_default_html;
797
+				$field->field_options['custom_html'] = $new_default_html;
798 798
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
799
-            }
800
-            unset($field);
801
-        }
802
-        unset($default_html, $old_default_html, $fields);
803
-    }
804
-
805
-    private function migrate_to_4() {
806
-        global $wpdb;
799
+			}
800
+			unset($field);
801
+		}
802
+		unset($default_html, $old_default_html, $fields);
803
+	}
804
+
805
+	private function migrate_to_4() {
806
+		global $wpdb;
807 807
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
808
-        foreach ( $user_ids as $user_id ) {
808
+		foreach ( $user_ids as $user_id ) {
809 809
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
810
-        }
811
-    }
810
+		}
811
+	}
812 812
 
813 813
 	public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
814 814
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
Please login to merge, or discard this patch.
classes/models/FrmField.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmField {
7
-    static $use_cache = true;
7
+	static $use_cache = true;
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
@@ -51,39 +51,39 @@  discard block
 block discarded – undo
51 51
 		));
52 52
 	}
53 53
 
54
-    public static function create( $values, $return = true ) {
55
-        global $wpdb, $frm_duplicate_ids;
54
+	public static function create( $values, $return = true ) {
55
+		global $wpdb, $frm_duplicate_ids;
56 56
 
57
-        $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
57
+		$new_values = array();
58
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62 62
 			$new_values[ $col ] = $values[ $col ];
63
-        }
63
+		}
64 64
 
65
-        $new_values['options'] = $values['options'];
65
+		$new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
-        $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
67
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
+		$new_values['field_options'] = $values['field_options'];
71
+		$new_values['created_at'] = current_time('mysql', 1);
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74 74
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
76
-        }
75
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
76
+		}
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79
-            if ( is_array( $v ) ) {
79
+			if ( is_array( $v ) ) {
80 80
 				$new_values[ $k ] = serialize( $v );
81 81
 			}
82
-            unset( $k, $v );
83
-        }
82
+			unset( $k, $v );
83
+		}
84 84
 
85
-        //if(isset($values['id']) and is_numeric($values['id']))
86
-        //    $new_values['id'] = $values['id'];
85
+		//if(isset($values['id']) and is_numeric($values['id']))
86
+		//    $new_values['id'] = $values['id'];
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
89 89
 		$new_id = 0;
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 		} else {
105 105
 			return false;
106 106
 		}
107
-    }
107
+	}
108 108
 
109
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
-        global $frm_duplicate_ids;
109
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
+		global $frm_duplicate_ids;
111 111
 
112 112
 		$where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) );
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115
-        foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
119
-            }
115
+		foreach ( (array) $fields as $field ) {
116
+			$new_key = ($copy_keys) ? $field->field_key : '';
117
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
+				$new_key = rtrim($new_key, 2);
119
+			}
120 120
 
121
-            $values = array();
122
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
+			$values = array();
122
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
123 123
 
124 124
 			// If this is a repeating section, create new form
125 125
 			if ( self::is_repeating_field( $field ) ) {
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
146
-        }
147
-    }
141
+			$values = apply_filters('frm_duplicated_field', $values);
142
+			$new_id = self::create($values);
143
+			$frm_duplicate_ids[ $field->id ] = $new_id;
144
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
145
+			unset($field);
146
+		}
147
+	}
148 148
 
149 149
 	public static function update( $id, $values ) {
150
-        global $wpdb;
150
+		global $wpdb;
151 151
 
152 152
 		$id = absint( $id );
153 153
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
159
-            $values['required'] = (int) $values['required'];
160
-        }
158
+		if ( isset($values['required']) ) {
159
+			$values['required'] = (int) $values['required'];
160
+		}
161 161
 
162 162
 		self::preserve_format_option_backslashes( $values );
163 163
 
@@ -174,41 +174,41 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
176 176
 
177
-        $form_id = 0;
177
+		$form_id = 0;
178 178
 		if ( isset( $values['form_id'] ) ) {
179
-            $form_id = absint( $values['form_id'] );
179
+			$form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
182
-            if ( $field ) {
183
-                $form_id = $field->form_id;
184
-            }
185
-            unset($field);
186
-        }
187
-        unset($values);
181
+			$field = self::getOne($id);
182
+			if ( $field ) {
183
+				$form_id = $field->form_id;
184
+			}
185
+			unset($field);
186
+		}
187
+		unset($values);
188 188
 
189 189
 		if ( $query_results ) {
190
-            wp_cache_delete( $id, 'frm_field' );
191
-            if ( $form_id ) {
192
-                self::delete_form_transient( $form_id );
193
-            }
194
-        }
190
+			wp_cache_delete( $id, 'frm_field' );
191
+			if ( $form_id ) {
192
+				self::delete_form_transient( $form_id );
193
+			}
194
+		}
195 195
 
196
-        return $query_results;
197
-    }
196
+		return $query_results;
197
+	}
198 198
 
199 199
 	/**
200
-	* Keep backslashes in the phone format option
201
-	*
202
-	* @since 2.0.8
203
-	* @param $values array - pass by reference
204
-	*/
200
+	 * Keep backslashes in the phone format option
201
+	 *
202
+	 * @since 2.0.8
203
+	 * @param $values array - pass by reference
204
+	 */
205 205
 	private static function preserve_format_option_backslashes( &$values ) {
206 206
 		if ( isset( $values['field_options']['format'] ) ) {
207 207
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
208 208
 		}
209 209
 	}
210 210
 
211
-    public static function destroy( $id ) {
211
+	public static function destroy( $id ) {
212 212
 		global $wpdb;
213 213
 
214 214
 		do_action( 'frm_before_destroy_field', $id );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
225 225
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
226
-    }
226
+	}
227 227
 
228 228
 	public static function delete_form_transient( $form_id ) {
229 229
 		$form_id = absint( $form_id );
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
237 237
 
238 238
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
239
-        wp_cache_delete($cache_key, 'frm_field');
239
+		wp_cache_delete($cache_key, 'frm_field');
240 240
 
241 241
 		// this cache key is autogenerated in FrmDb::get_var
242 242
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
243 243
 		wp_cache_delete( '1_' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
244 244
 
245
-        $form = FrmForm::getOne($form_id);
246
-        if ( $form && $form->parent_form_id ) {
247
-            self::delete_form_transient( $form->parent_form_id );
248
-        }
249
-    }
245
+		$form = FrmForm::getOne($form_id);
246
+		if ( $form && $form->parent_form_id ) {
247
+			self::delete_form_transient( $form->parent_form_id );
248
+		}
249
+	}
250 250
 
251 251
 	/**
252 252
 	 * If $field is numeric, get the field object
@@ -262,131 +262,131 @@  discard block
 block discarded – undo
262 262
 			return;
263 263
 		}
264 264
 
265
-        global $wpdb;
265
+		global $wpdb;
266 266
 
267
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
267
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
268 268
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
269 269
 
270
-        $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
270
+		$results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
271 271
 
272
-        if ( empty($results) ) {
273
-            return $results;
274
-        }
272
+		if ( empty($results) ) {
273
+			return $results;
274
+		}
275 275
 
276
-        if ( is_numeric($id) ) {
277
-            wp_cache_set( $results->field_key, $results, 'frm_field' );
278
-        } else if ( $results ) {
279
-            wp_cache_set( $results->id, $results, 'frm_field' );
280
-        }
276
+		if ( is_numeric($id) ) {
277
+			wp_cache_set( $results->field_key, $results, 'frm_field' );
278
+		} else if ( $results ) {
279
+			wp_cache_set( $results->id, $results, 'frm_field' );
280
+		}
281 281
 
282 282
 		self::prepare_options( $results );
283 283
 
284
-        return stripslashes_deep($results);
285
-    }
284
+		return stripslashes_deep($results);
285
+	}
286 286
 
287
-    /**
288
-     * Get the field type by key or id
289
-     * @param int|string The field id or key
287
+	/**
288
+	 * Get the field type by key or id
289
+	 * @param int|string The field id or key
290 290
 	 * @param mixed $col The name of the column in the fields database table
291
-     */
292
-    public static function &get_type( $id, $col = 'type' ) {
293
-        $field = FrmAppHelper::check_cache( $id, 'frm_field' );
294
-        if ( $field ) {
295
-            $type = $field->{$col};
296
-        } else {
297
-            $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
298
-        }
299
-
300
-        return $type;
301
-    }
291
+	 */
292
+	public static function &get_type( $id, $col = 'type' ) {
293
+		$field = FrmAppHelper::check_cache( $id, 'frm_field' );
294
+		if ( $field ) {
295
+			$type = $field->{$col};
296
+		} else {
297
+			$type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
298
+		}
299
+
300
+		return $type;
301
+	}
302 302
 
303 303
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
304
-        if ( ! $form_id ) {
305
-            return array();
306
-        }
304
+		if ( ! $form_id ) {
305
+			return array();
306
+		}
307 307
 
308 308
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) );
309 309
 		if ( ! empty( $results ) ) {
310
-            $fields = array();
311
-            $count = 0;
312
-            foreach ( $results as $result ) {
313
-                if ( $type != $result->type ) {
314
-                    continue;
315
-                }
310
+			$fields = array();
311
+			$count = 0;
312
+			foreach ( $results as $result ) {
313
+				if ( $type != $result->type ) {
314
+					continue;
315
+				}
316 316
 
317 317
 				$fields[ $result->id ] = $result;
318
-                $count++;
319
-                if ( $limit == 1 ) {
320
-                    $fields = $result;
321
-                    break;
322
-                }
318
+				$count++;
319
+				if ( $limit == 1 ) {
320
+					$fields = $result;
321
+					break;
322
+				}
323 323
 
324
-                if ( ! empty($limit) && $count >= $limit ) {
325
-                    break;
326
-                }
324
+				if ( ! empty($limit) && $count >= $limit ) {
325
+					break;
326
+				}
327 327
 
328
-                unset($result);
329
-            }
330
-            return stripslashes_deep($fields);
331
-        }
328
+				unset($result);
329
+			}
330
+			return stripslashes_deep($fields);
331
+		}
332 332
 
333
-        self::$use_cache = false;
333
+		self::$use_cache = false;
334 334
 
335 335
 		$where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type );
336 336
 		self::maybe_include_repeating_fields( $inc_sub, $where );
337 337
 		$results = self::getAll( $where, 'field_order', $limit );
338
-        self::$use_cache = true;
339
-        self::include_sub_fields($results, $inc_sub, $type);
338
+		self::$use_cache = true;
339
+		self::include_sub_fields($results, $inc_sub, $type);
340 340
 
341
-        return $results;
342
-    }
341
+		return $results;
342
+	}
343 343
 
344 344
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
345
-        if ( ! (int) $form_id ) {
346
-            return array();
347
-        }
345
+		if ( ! (int) $form_id ) {
346
+			return array();
347
+		}
348 348
 
349 349
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
350 350
 		if ( ! empty( $results ) ) {
351
-            if ( empty($limit) ) {
351
+			if ( empty($limit) ) {
352 352
 				return $results;
353
-            }
353
+			}
354 354
 
355
-            $fields = array();
356
-            $count = 0;
357
-            foreach ( $results as $result ) {
355
+			$fields = array();
356
+			$count = 0;
357
+			foreach ( $results as $result ) {
358 358
 				$fields[ $result->id ] = $result;
359
-                if ( ! empty($limit) && $count >= $limit ) {
360
-                    break;
361
-                }
362
-            }
359
+				if ( ! empty($limit) && $count >= $limit ) {
360
+					break;
361
+				}
362
+			}
363 363
 
364 364
 			return $fields;
365
-        }
365
+		}
366 366
 
367
-        self::$use_cache = false;
367
+		self::$use_cache = false;
368 368
 
369 369
 		$where = array( 'fi.form_id' => absint( $form_id ) );
370 370
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
371 371
 		$results = self::getAll( $where, 'field_order', $limit );
372 372
 
373
-        self::$use_cache = true;
373
+		self::$use_cache = true;
374 374
 
375 375
 		self::include_sub_fields( $results, $inc_embed, 'all' );
376 376
 
377
-        if ( empty($limit) ) {
377
+		if ( empty($limit) ) {
378 378
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
379
-        }
379
+		}
380 380
 
381 381
 		return $results;
382
-    }
382
+	}
383 383
 
384 384
 	/**
385
-	* If repeating fields should be included, adjust $where accordingly
386
-	*
387
-	* @param string $inc_repeat
388
-	* @param array $where - pass by reference
389
-	*/
385
+	 * If repeating fields should be included, adjust $where accordingly
386
+	 *
387
+	 * @param string $inc_repeat
388
+	 * @param array $where - pass by reference
389
+	 */
390 390
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
391 391
 		if ( $inc_repeat == 'include' ) {
392 392
 			$form_id = $where['fi.form_id'];
@@ -397,77 +397,77 @@  discard block
 block discarded – undo
397 397
 
398 398
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
399 399
 		if ( 'include' != $inc_embed || empty( $results ) ) {
400
-            return;
401
-        }
400
+			return;
401
+		}
402 402
 
403
-        $form_fields = $results;
403
+		$form_fields = $results;
404 404
 		$index_offset = 1;
405
-        foreach ( $form_fields as $k => $field ) {
406
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
407
-                continue;
408
-            }
409
-
410
-            if ( $type == 'all' ) {
411
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412
-            } else {
413
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
414
-            }
415
-
416
-            if ( ! empty($sub_fields) ) {
405
+		foreach ( $form_fields as $k => $field ) {
406
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
407
+				continue;
408
+			}
409
+
410
+			if ( $type == 'all' ) {
411
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412
+			} else {
413
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
414
+			}
415
+
416
+			if ( ! empty($sub_fields) ) {
417 417
 				$index = $k + $index_offset;
418 418
 				$index_offset += count( $sub_fields );
419 419
 				array_splice($results, $index, 0, $sub_fields);
420
-            }
421
-            unset($field, $sub_fields);
422
-        }
423
-    }
420
+			}
421
+			unset($field, $sub_fields);
422
+		}
423
+	}
424 424
 
425 425
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
426 426
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
427
-        if ( self::$use_cache ) {
428
-            // make sure old cache doesn't get saved as a transient
429
-            $results = wp_cache_get($cache_key, 'frm_field');
430
-            if ( false !== $results ) {
431
-                return stripslashes_deep($results);
432
-            }
433
-        }
434
-
435
-        global $wpdb;
436
-
437
-        if ( $blog_id && is_multisite() ) {
438
-            global $wpmuBaseTablePrefix;
439
-            if ( $wpmuBaseTablePrefix ) {
427
+		if ( self::$use_cache ) {
428
+			// make sure old cache doesn't get saved as a transient
429
+			$results = wp_cache_get($cache_key, 'frm_field');
430
+			if ( false !== $results ) {
431
+				return stripslashes_deep($results);
432
+			}
433
+		}
434
+
435
+		global $wpdb;
436
+
437
+		if ( $blog_id && is_multisite() ) {
438
+			global $wpmuBaseTablePrefix;
439
+			if ( $wpmuBaseTablePrefix ) {
440 440
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
441
-            } else {
442
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
443
-            }
441
+			} else {
442
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
443
+			}
444 444
 
445 445
 			$table_name = $prefix . 'frm_fields';
446 446
 			$form_table_name = $prefix . 'frm_forms';
447 447
 		} else {
448 448
 			$table_name = $wpdb->prefix . 'frm_fields';
449 449
 			$form_table_name = $wpdb->prefix . 'frm_forms';
450
-        }
450
+		}
451 451
 
452 452
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
453 453
 			$order_by = ' ORDER BY ' . $order_by;
454 454
 		}
455 455
 
456
-        $limit = FrmAppHelper::esc_limit($limit);
456
+		$limit = FrmAppHelper::esc_limit($limit);
457 457
 
458
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
458
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
460 460
 
461
-        if ( is_array($where) ) {
462
-            $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
461
+		if ( is_array($where) ) {
462
+			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
463 463
 		} else {
464 464
 			// if the query is not an array, then it has already been prepared
465
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
465
+			$query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
466 466
 
467 467
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
468 468
 			$results = $wpdb->$function_name( $query );
469
-        }
470
-        unset( $where );
469
+		}
470
+		unset( $where );
471 471
 
472 472
 		self::format_field_results( $results );
473 473
 
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 
567 567
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
568 568
 		_deprecated_function( __FUNCTION__, '2.0' );
569
-        global $wpdb;
570
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
569
+		global $wpdb;
570
+		if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
571 571
 			$order_by = ' ORDER BY ' . $order_by;
572
-        }
572
+		}
573 573
 
574 574
 		$query = 'SELECT fi.id  FROM ' . $wpdb->prefix . 'frm_fields fi ' .
575 575
 			'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' .
576 576
 			FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
577 577
 
578
-        $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
578
+		$method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
579 579
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
580
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
580
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
581 581
 
582
-        return $results;
583
-    }
582
+		return $results;
583
+	}
584 584
 
585 585
 	public static function is_no_save_field( $type ) {
586 586
 		return in_array( $type, self::no_save_fields() );
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	}
724 724
 
725 725
 	/**
726
-	* @since 2.0.09
727
-	*/
726
+	 * @since 2.0.09
727
+	 */
728 728
 	public static function is_repeating_field( $field ) {
729 729
 		if ( is_array( $field ) ) {
730 730
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
735 735
 	}
736 736
 
737
-    /**
738
-     * @param string $key
739
-     * @return int field id
740
-     */
737
+	/**
738
+	 * @param string $key
739
+	 * @return int field id
740
+	 */
741 741
 	public static function get_id_by_key( $key ) {
742
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
743
-        return $id;
744
-    }
742
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
743
+		return $id;
744
+	}
745 745
 
746 746
 	/**
747 747
 	 * @param string $id
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 		// serialize array values
169 169
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
170
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
171
-				$values[ $opt ] = serialize( $values[ $opt ] );
170
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
171
+				$values[$opt] = serialize( $values[$opt] );
172 172
 			}
173 173
 		}
174 174
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 		if ( isset( $values['form_id'] ) ) {
179 179
             $form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
181
+            $field = self::getOne( $id );
182 182
             if ( $field ) {
183 183
                 $form_id = $field->form_id;
184 184
             }
185
-            unset($field);
185
+            unset( $field );
186 186
         }
187
-        unset($values);
187
+        unset( $values );
188 188
 
189 189
 		if ( $query_results ) {
190 190
             wp_cache_delete( $id, 'frm_field' );
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
237 237
 
238 238
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
239
-        wp_cache_delete($cache_key, 'frm_field');
239
+        wp_cache_delete( $cache_key, 'frm_field' );
240 240
 
241 241
 		// this cache key is autogenerated in FrmDb::get_var
242 242
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
243 243
 		wp_cache_delete( '1_' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
244 244
 
245
-        $form = FrmForm::getOne($form_id);
245
+        $form = FrmForm::getOne( $form_id );
246 246
         if ( $form && $form->parent_form_id ) {
247 247
             self::delete_form_transient( $form->parent_form_id );
248 248
         }
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 
265 265
         global $wpdb;
266 266
 
267
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
267
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
268 268
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
269 269
 
270 270
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
271 271
 
272
-        if ( empty($results) ) {
272
+        if ( empty( $results ) ) {
273 273
             return $results;
274 274
         }
275 275
 
276
-        if ( is_numeric($id) ) {
276
+        if ( is_numeric( $id ) ) {
277 277
             wp_cache_set( $results->field_key, $results, 'frm_field' );
278 278
         } else if ( $results ) {
279 279
             wp_cache_set( $results->id, $results, 'frm_field' );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		self::prepare_options( $results );
283 283
 
284
-        return stripslashes_deep($results);
284
+        return stripslashes_deep( $results );
285 285
     }
286 286
 
287 287
     /**
@@ -314,20 +314,20 @@  discard block
 block discarded – undo
314 314
                     continue;
315 315
                 }
316 316
 
317
-				$fields[ $result->id ] = $result;
318
-                $count++;
317
+				$fields[$result->id] = $result;
318
+                $count ++;
319 319
                 if ( $limit == 1 ) {
320 320
                     $fields = $result;
321 321
                     break;
322 322
                 }
323 323
 
324
-                if ( ! empty($limit) && $count >= $limit ) {
324
+                if ( ! empty( $limit ) && $count >= $limit ) {
325 325
                     break;
326 326
                 }
327 327
 
328
-                unset($result);
328
+                unset( $result );
329 329
             }
330
-            return stripslashes_deep($fields);
330
+            return stripslashes_deep( $fields );
331 331
         }
332 332
 
333 333
         self::$use_cache = false;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		self::maybe_include_repeating_fields( $inc_sub, $where );
337 337
 		$results = self::getAll( $where, 'field_order', $limit );
338 338
         self::$use_cache = true;
339
-        self::include_sub_fields($results, $inc_sub, $type);
339
+        self::include_sub_fields( $results, $inc_sub, $type );
340 340
 
341 341
         return $results;
342 342
     }
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 
349 349
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
350 350
 		if ( ! empty( $results ) ) {
351
-            if ( empty($limit) ) {
351
+            if ( empty( $limit ) ) {
352 352
 				return $results;
353 353
             }
354 354
 
355 355
             $fields = array();
356 356
             $count = 0;
357 357
             foreach ( $results as $result ) {
358
-				$fields[ $result->id ] = $result;
359
-                if ( ! empty($limit) && $count >= $limit ) {
358
+				$fields[$result->id] = $result;
359
+                if ( ! empty( $limit ) && $count >= $limit ) {
360 360
                     break;
361 361
                 }
362 362
             }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 		self::include_sub_fields( $results, $inc_embed, 'all' );
376 376
 
377
-        if ( empty($limit) ) {
377
+        if ( empty( $limit ) ) {
378 378
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
379 379
         }
380 380
 
@@ -403,22 +403,22 @@  discard block
 block discarded – undo
403 403
         $form_fields = $results;
404 404
 		$index_offset = 1;
405 405
         foreach ( $form_fields as $k => $field ) {
406
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
406
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
407 407
                 continue;
408 408
             }
409 409
 
410 410
             if ( $type == 'all' ) {
411 411
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
412 412
             } else {
413
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
413
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
414 414
             }
415 415
 
416
-            if ( ! empty($sub_fields) ) {
416
+            if ( ! empty( $sub_fields ) ) {
417 417
 				$index = $k + $index_offset;
418 418
 				$index_offset += count( $sub_fields );
419
-				array_splice($results, $index, 0, $sub_fields);
419
+				array_splice( $results, $index, 0, $sub_fields );
420 420
             }
421
-            unset($field, $sub_fields);
421
+            unset( $field, $sub_fields );
422 422
         }
423 423
     }
424 424
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
427 427
         if ( self::$use_cache ) {
428 428
             // make sure old cache doesn't get saved as a transient
429
-            $results = wp_cache_get($cache_key, 'frm_field');
429
+            $results = wp_cache_get( $cache_key, 'frm_field' );
430 430
             if ( false !== $results ) {
431
-                return stripslashes_deep($results);
431
+                return stripslashes_deep( $results );
432 432
             }
433 433
         }
434 434
 
@@ -453,16 +453,16 @@  discard block
 block discarded – undo
453 453
 			$order_by = ' ORDER BY ' . $order_by;
454 454
 		}
455 455
 
456
-        $limit = FrmAppHelper::esc_limit($limit);
456
+        $limit = FrmAppHelper::esc_limit( $limit );
457 457
 
458 458
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
459 459
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
460 460
 
461
-        if ( is_array($where) ) {
461
+        if ( is_array( $where ) ) {
462 462
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
463 463
 		} else {
464 464
 			// if the query is not an array, then it has already been prepared
465
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
465
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
466 466
 
467 467
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
468 468
 			$results = $wpdb->$function_name( $query );
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 				wp_cache_set( $result->id, $result, 'frm_field' );
486 486
 				wp_cache_set( $result->field_key, $result, 'frm_field' );
487 487
 
488
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
489
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
490
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
488
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
489
+				$results[$r_key]->options = maybe_unserialize( $result->options );
490
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
491 491
 
492 492
 				unset( $r_key, $result );
493 493
 			}
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	private static function prepare_options( &$results ) {
507 507
 		$results->field_options = maybe_unserialize( $results->field_options );
508 508
 
509
-		$results->options = maybe_unserialize($results->options);
510
-		$results->default_value = maybe_unserialize($results->default_value);
509
+		$results->options = maybe_unserialize( $results->options );
510
+		$results->default_value = maybe_unserialize( $results->default_value );
511 511
 	}
512 512
 
513 513
 	/**
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 
535 535
 			if ( count( $next_fields ) >= self::$transient_size ) {
536 536
 				// if this transient is full, check for another
537
-				$next++;
537
+				$next ++;
538 538
 				self::get_next_transient( $fields, $base_name, $next );
539 539
 			}
540 540
 		}
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 				return;
561 561
 			}
562 562
 
563
-			$next++;
563
+			$next ++;
564 564
 		}
565 565
 	}
566 566
 
567 567
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
568 568
 		_deprecated_function( __FUNCTION__, '2.0' );
569 569
         global $wpdb;
570
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
570
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
571 571
 			$order_by = ' ORDER BY ' . $order_by;
572 572
         }
573 573
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
579 579
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
580
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
580
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
581 581
 
582 582
         return $results;
583 583
     }
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 			$is_multi_value_field = (
609 609
 				$field['type'] == 'checkbox' ||
610 610
 				$field['type'] == 'address' ||
611
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
612
-				( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
611
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
612
+				( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
613 613
 				self::is_multiple_select( $field )
614 614
 			);
615 615
 
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public static function is_multiple_select( $field ) {
636 636
 		if ( is_array( $field ) ) {
637
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
637
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
638 638
 		} else {
639
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
639
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
640 640
 		}
641 641
 	}
642 642
 
@@ -683,23 +683,23 @@  discard block
 block discarded – undo
683 683
 	}
684 684
 
685 685
 	public static function is_option_true_in_array( $field, $option ) {
686
-		return isset( $field[ $option ] ) && $field[ $option ];
686
+		return isset( $field[$option] ) && $field[$option];
687 687
 	}
688 688
 
689 689
 	public static function is_option_true_in_object( $field, $option ) {
690
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
690
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
691 691
 	}
692 692
 
693 693
 	public static function is_option_empty_in_array( $field, $option ) {
694
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
694
+		return ! isset( $field[$option] ) || empty( $field[$option] );
695 695
 	}
696 696
 
697 697
 	public static function is_option_empty_in_object( $field, $option ) {
698
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
698
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
699 699
 	}
700 700
 
701 701
 	public static function is_option_value_in_object( $field, $option ) {
702
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
702
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
703 703
 	}
704 704
 
705 705
 	/**
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 	}
716 716
 
717 717
 	public static function get_option_in_array( $field, $option ) {
718
-		return $field[ $option ];
718
+		return $field[$option];
719 719
 	}
720 720
 
721 721
 	public static function get_option_in_object( $field, $option ) {
722
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
722
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
723 723
 	}
724 724
 
725 725
 	/**
Please login to merge, or discard this patch.
classes/models/FrmNotification.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -2,160 +2,160 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
7
-        }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
-    }
5
+		if ( ! defined('ABSPATH') ) {
6
+			die('You are not allowed to call this page directly.');
7
+		}
8
+		add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
+	}
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
12
-        $notification = $action->post_content;
13
-        $email_key = $action->ID;
14
-
15
-        // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
-        }
19
-
20
-        $plain_text = $notification['plain_text'] ? true : false;
21
-
22
-        //Filter these fields
23
-        $filter_fields = array(
24
-            'email_to', 'cc', 'bcc',
25
-            'reply_to', 'from',
26
-            'email_subject', 'email_message',
27
-        );
28
-
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
-
31
-        //Get all values in entry in order to get User ID field ID
32
-        $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
-        $user_id_field = $user_id_key = '';
34
-        foreach ( $values as $value ) {
35
-            if ( $value->field_type == 'user_id' ) {
36
-                $user_id_field = $value->field_id;
37
-                $user_id_key = $value->field_key;
38
-                break;
39
-            }
40
-            unset($value);
41
-        }
42
-
43
-        //Filter and prepare the email fields
44
-        foreach ( $filter_fields as $f ) {
45
-            //Don't allow empty From
12
+		$notification = $action->post_content;
13
+		$email_key = $action->ID;
14
+
15
+		// Set the subject
16
+		if ( empty($notification['email_subject']) ) {
17
+			$notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
+		}
19
+
20
+		$plain_text = $notification['plain_text'] ? true : false;
21
+
22
+		//Filter these fields
23
+		$filter_fields = array(
24
+			'email_to', 'cc', 'bcc',
25
+			'reply_to', 'from',
26
+			'email_subject', 'email_message',
27
+		);
28
+
29
+		add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
+
31
+		//Get all values in entry in order to get User ID field ID
32
+		$values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
+		$user_id_field = $user_id_key = '';
34
+		foreach ( $values as $value ) {
35
+			if ( $value->field_type == 'user_id' ) {
36
+				$user_id_field = $value->field_id;
37
+				$user_id_key = $value->field_key;
38
+				break;
39
+			}
40
+			unset($value);
41
+		}
42
+
43
+		//Filter and prepare the email fields
44
+		foreach ( $filter_fields as $f ) {
45
+			//Don't allow empty From
46 46
 			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47 47
 				$notification[ $f ] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50
-                //Add a space in case there isn't one
50
+				//Add a space in case there isn't one
51 51
 				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52 52
 				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
53 53
 
54
-                //Switch userID shortcode to email address
54
+				//Switch userID shortcode to email address
55 55
 				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56 56
 					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
57
-                    $user_email = $user_data->user_email;
57
+					$user_email = $user_data->user_email;
58 58
 					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
59
-                }
60
-            }
59
+				}
60
+			}
61 61
 
62 62
 			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
63
-        }
63
+		}
64 64
 
65
-        //Put recipients, cc, and bcc into an array if they aren't empty
65
+		//Put recipients, cc, and bcc into an array if they aren't empty
66 66
 		$to_emails = self::explode_emails( $notification['email_to'] );
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+		$to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
71 71
 
72
-        // Stop now if there aren't any recipients
73
-        if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
-            return;
75
-        }
72
+		// Stop now if there aren't any recipients
73
+		if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
+			return;
75
+		}
76 76
 
77
-        $to_emails = array_unique( (array) $to_emails );
77
+		$to_emails = array_unique( (array) $to_emails );
78 78
 
79
-        $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
-            'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
-        ) );
79
+		$prev_mail_body = $mail_body = $notification['email_message'];
80
+		$mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
+			'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
+			'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
+		) );
84 84
 
85
-        // Add the user info if it isn't already included
86
-        if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
85
+		// Add the user info if it isn't already included
86
+		if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
+			$data = maybe_unserialize($entry->description);
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92
-        }
93
-        unset($prev_mail_body);
94
-
95
-        // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
-
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
-        }
101
-
102
-        // check for a phone number
103
-        foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
106
-
107
-                //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
109
-                    continue;
110
-                }
111
-
112
-                do_action('frm_send_to_not_email', array(
113
-                    'e'         => $e,
114
-                    'subject'   => $notification['email_subject'],
115
-                    'mail_body' => $mail_body,
116
-                    'reply_to'  => $notification['reply_to'],
117
-                    'from'      => $notification['from'],
118
-                    'plain_text' => $plain_text,
119
-                    'attachments' => $attachments,
120
-                    'form'      => $form,
121
-                    'email_key' => $email_key,
122
-                ) );
92
+		}
93
+		unset($prev_mail_body);
94
+
95
+		// Add attachments
96
+		$attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
+
98
+		if ( ! empty($notification['email_subject']) ) {
99
+			$notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
+		}
101
+
102
+		// check for a phone number
103
+		foreach ( (array) $to_emails as $email_key => $e ) {
104
+			if ( $e != '[admin_email]' && ! is_email($e) ) {
105
+				$e = explode(' ', $e);
106
+
107
+				//If to_email has name <[email protected]> format
108
+				if ( is_email(end($e)) ) {
109
+					continue;
110
+				}
111
+
112
+				do_action('frm_send_to_not_email', array(
113
+					'e'         => $e,
114
+					'subject'   => $notification['email_subject'],
115
+					'mail_body' => $mail_body,
116
+					'reply_to'  => $notification['reply_to'],
117
+					'from'      => $notification['from'],
118
+					'plain_text' => $plain_text,
119
+					'attachments' => $attachments,
120
+					'form'      => $form,
121
+					'email_key' => $email_key,
122
+				) );
123 123
 
124 124
 				unset( $to_emails[ $email_key ] );
125
-            }
126
-        }
127
-
128
-        // Send the email now
129
-        $sent_to = self::send_email( array(
130
-            'to_email'      => $to_emails,
131
-            'subject'       => $notification['email_subject'],
132
-            'message'       => $mail_body,
133
-            'from'          => $notification['from'],
134
-            'plain_text'    => $plain_text,
135
-            'reply_to'      => $notification['reply_to'],
136
-            'attachments'   => $attachments,
137
-            'cc'            => $cc,
138
-            'bcc'           => $bcc,
139
-        ) );
140
-
141
-        return $sent_to;
142
-    }
125
+			}
126
+		}
127
+
128
+		// Send the email now
129
+		$sent_to = self::send_email( array(
130
+			'to_email'      => $to_emails,
131
+			'subject'       => $notification['email_subject'],
132
+			'message'       => $mail_body,
133
+			'from'          => $notification['from'],
134
+			'plain_text'    => $plain_text,
135
+			'reply_to'      => $notification['reply_to'],
136
+			'attachments'   => $attachments,
137
+			'cc'            => $cc,
138
+			'bcc'           => $bcc,
139
+		) );
140
+
141
+		return $sent_to;
142
+	}
143 143
 
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
-    }
147
+		FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
+	}
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
151
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
154
-            'to_email', 'subject', 'message',
155
-            'from', 'from_name', 'plain_text',
156
-            'attachments', 'reply_to'
157
-        ));
158
-    }
153
+		return self::send_email(compact(
154
+			'to_email', 'subject', 'message',
155
+			'from', 'from_name', 'plain_text',
156
+			'attachments', 'reply_to'
157
+		));
158
+	}
159 159
 
160 160
 	/**
161 161
 	 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -173,53 +173,53 @@  discard block
 block discarded – undo
173 173
 		return $emails;
174 174
 	}
175 175
 
176
-    /**
177
-    * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
-    * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
-    * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
-    * "First Last" <[email protected]>
181
-    *
182
-    * Things that won't work: First Last (with no email entered)
183
-    * @since 2.0
184
-    * @param array $atts array of email fields, pass by reference
185
-    * @param $admin_email
186
-    */
187
-    private static function format_email_fields( &$atts, $admin_email ) {
188
-
189
-        // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
-
192
-        // Filter values in these fields
176
+	/**
177
+	 * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
+	 * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
+	 * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
+	 * "First Last" <[email protected]>
181
+	 *
182
+	 * Things that won't work: First Last (with no email entered)
183
+	 * @since 2.0
184
+	 * @param array $atts array of email fields, pass by reference
185
+	 * @param $admin_email
186
+	 */
187
+	private static function format_email_fields( &$atts, $admin_email ) {
188
+
189
+		// If from is empty or is set to admin_email, set it now
190
+		$atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
+
192
+		// Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195
-        foreach ( $filter_fields as $f ) {
196
-            // If empty, just skip it
195
+		foreach ( $filter_fields as $f ) {
196
+			// If empty, just skip it
197 197
 			if ( empty( $atts[ $f ] ) ) {
198
-                continue;
199
-            }
198
+				continue;
199
+			}
200 200
 
201
-            // to_email, cc, and bcc can be an array
201
+			// to_email, cc, and bcc can be an array
202 202
 			if ( is_array( $atts[ $f ] ) ) {
203 203
 				foreach ( $atts[ $f ] as $key => $val ) {
204
-                    self::format_single_field( $atts, $f, $val, $key );
205
-                    unset( $key, $val );
206
-                }
207
-                unset($f);
208
-                continue;
209
-            }
204
+					self::format_single_field( $atts, $f, $val, $key );
205
+					unset( $key, $val );
206
+				}
207
+				unset($f);
208
+				continue;
209
+			}
210 210
 
211 211
 			self::format_single_field( $atts, $f, $atts[ $f ] );
212
-        }
212
+		}
213 213
 
214
-        // If reply-to isn't set, make it match the from settings
215
-        if ( empty( $atts['reply_to'] ) ) {
216
-            $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
-        }
214
+		// If reply-to isn't set, make it match the from settings
215
+		if ( empty( $atts['reply_to'] ) ) {
216
+			$atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
+		}
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
-            $atts['to_email'] = $admin_email;
221
-        }
222
-    }
219
+		if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
+			$atts['to_email'] = $admin_email;
221
+		}
222
+	}
223 223
 
224 224
 	private static function get_email_from_formatted_string( $value ) {
225 225
 		if ( strpos( $value, '<' ) !== false ) {
@@ -229,48 +229,48 @@  discard block
 block discarded – undo
229 229
 		return $value;
230 230
 	}
231 231
 
232
-    /**
233
-    * Format individual email fields
234
-    *
235
-    * @since 2.0
236
-    * @param array $atts pass by reference
237
-    * @param string $f (to, from, reply_to, etc)
238
-    * @param string $val value saved in field
239
-    * @param int $key if in array, this will be set
240
-    */
241
-    private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
243
-
244
-        // If just a plain email is used
245
-        if ( is_email($val) ) {
246
-            // add sender's name if not included in $from
247
-            if ( $f == 'from' ) {
232
+	/**
233
+	 * Format individual email fields
234
+	 *
235
+	 * @since 2.0
236
+	 * @param array $atts pass by reference
237
+	 * @param string $f (to, from, reply_to, etc)
238
+	 * @param string $val value saved in field
239
+	 * @param int $key if in array, this will be set
240
+	 */
241
+	private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
+		$val = trim($val);
243
+
244
+		// If just a plain email is used
245
+		if ( is_email($val) ) {
246
+			// add sender's name if not included in $from
247
+			if ( $f == 'from' ) {
248 248
 				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
-            } else {
251
-                return;
252
-            }
253
-        } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
256
-
257
-            // If inputted correcly, $part_2 should be an email
258
-            if ( is_email( $part_2 ) ) {
259
-                $part_1 = trim( str_replace( $part_2, '', $val ) );
260
-            } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
249
+				$part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
+			} else {
251
+				return;
252
+			}
253
+		} else {
254
+			$parts = explode(' ', $val);
255
+			$part_2 = end($parts);
256
+
257
+			// If inputted correcly, $part_2 should be an email
258
+			if ( is_email( $part_2 ) ) {
259
+				$part_1 = trim( str_replace( $part_2, '', $val ) );
260
+			} else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
264
-            } else {
263
+				$part_2 = get_option('admin_email');
264
+			} else {
265 265
 				// In case someone just puts a name in any other email field
266
-                if ( false !== $key ) {
266
+				if ( false !== $key ) {
267 267
 					unset( $atts[ $f ][ $key ] );
268
-                    return;
269
-                }
268
+					return;
269
+				}
270 270
 				$atts[ $f ] = '';
271
-                return;
272
-            }
273
-        }
271
+				return;
272
+			}
273
+		}
274 274
 
275 275
 		// if sending the email from a yahoo address, change it to the WordPress default
276 276
 		if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) {
@@ -283,110 +283,110 @@  discard block
 block discarded – undo
283 283
 			$part_2 = 'wordpress@' . $sitename;
284 284
 		}
285 285
 
286
-        // Set up formatted value
286
+		// Set up formatted value
287 287
 		$final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>';
288 288
 
289
-        // If value is an array
290
-        if ( false !== $key ) {
289
+		// If value is an array
290
+		if ( false !== $key ) {
291 291
 			$atts[ $f ][ $key ] = $final_val;
292
-            return;
293
-        }
292
+			return;
293
+		}
294 294
 		$atts[ $f ] = $final_val;
295
-    }
295
+	}
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
299
-        $defaults = array(
300
-            'to_email'      => $admin_email,
301
-            'subject'       => '',
302
-            'message'       => '',
303
-            'from'          => $admin_email,
304
-            'from_name'     => '',
305
-            'cc'            => '',
306
-            'bcc'           => '',
307
-            'plain_text'    => true,
308
-            'reply_to'      => $admin_email,
309
-            'attachments'   => array(),
310
-        );
311
-        $atts = wp_parse_args($atts, $defaults);
312
-
313
-        // Put To, BCC, CC, Reply To, and From fields in the correct format
314
-        self::format_email_fields( $atts, $admin_email );
315
-
316
-        $recipient      = $atts['to_email']; //recipient
317
-        $header         = array();
318
-        $header[]       = 'From: ' . $atts['from'];
319
-
320
-        //Allow for cc and bcc arrays
298
+		$admin_email = get_option('admin_email');
299
+		$defaults = array(
300
+			'to_email'      => $admin_email,
301
+			'subject'       => '',
302
+			'message'       => '',
303
+			'from'          => $admin_email,
304
+			'from_name'     => '',
305
+			'cc'            => '',
306
+			'bcc'           => '',
307
+			'plain_text'    => true,
308
+			'reply_to'      => $admin_email,
309
+			'attachments'   => array(),
310
+		);
311
+		$atts = wp_parse_args($atts, $defaults);
312
+
313
+		// Put To, BCC, CC, Reply To, and From fields in the correct format
314
+		self::format_email_fields( $atts, $admin_email );
315
+
316
+		$recipient      = $atts['to_email']; //recipient
317
+		$header         = array();
318
+		$header[]       = 'From: ' . $atts['from'];
319
+
320
+		//Allow for cc and bcc arrays
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323
-        foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
325
-                continue;
326
-            }
323
+		foreach ( $array_fields as $key => $a_field ) {
324
+			if ( empty($a_field) ) {
325
+				continue;
326
+			}
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329 329
 				$cc[ $key ][] = $email;
330
-            }
331
-            unset($key, $a_field);
332
-        }
330
+			}
331
+			unset($key, $a_field);
332
+		}
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
335 335
 		foreach ( $cc as $k => $v ) {
336 336
 			$header[] = $k . ': ' . implode( ',', $v );
337 337
 		}
338 338
 
339
-        $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
339
+		$content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
+		$charset        = get_option('blog_charset');
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+		$atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+		$message        = do_shortcode($atts['message']);
347 347
 
348
-        if ( $atts['plain_text'] ) {
349
-            //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
-        } else {
348
+		if ( $atts['plain_text'] ) {
349
+			//$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
+			$message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
+		} else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353
-        	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
-        }
353
+			add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
+		}
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+		$header         = apply_filters('frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+		if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363
-        }
363
+		}
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+		remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
+		remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
-        if ( ! $sent ) {
368
+		$sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
+		if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
373
-        }
371
+			$recipient = implode(',', (array) $recipient);
372
+			$sent = mail($recipient, $atts['subject'], $message, $header);
373
+		}
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+		do_action('frm_notification', $recipient, $atts['subject'], $message);
379 379
 
380
-        if ( $sent ) {
380
+		if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382
-            $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
382
+			$sent_to = array_filter( $sent_to );
383
+			if ( apply_filters('frm_echo_emails', false) ) {
384
+				$temp = str_replace('<', '&lt;', $sent_to);
385 385
 				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
386
-            }
387
-            return $sent_to;
388
-        }
389
-    }
386
+			}
387
+			return $sent_to;
388
+		}
389
+	}
390 390
 
391 391
 	/**
392 392
 	 * This function should only be fired when Mandrill is sending an HTML email
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
5
+        if ( ! defined( 'ABSPATH' ) ) {
6
+            die( 'You are not allowed to call this page directly.' );
7 7
         }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
8
+        add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 );
9 9
     }
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
         $email_key = $action->ID;
14 14
 
15 15
         // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
16
+        if ( empty( $notification['email_subject'] ) ) {
17
+            $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' );
18 18
         }
19 19
 
20 20
         $plain_text = $notification['plain_text'] ? true : false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             'email_subject', 'email_message',
27 27
         );
28 28
 
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
29
+        add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) );
30 30
 
31 31
         //Get all values in entry in order to get User ID field ID
32 32
         $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
                 $user_id_key = $value->field_key;
38 38
                 break;
39 39
             }
40
-            unset($value);
40
+            unset( $value );
41 41
         }
42 42
 
43 43
         //Filter and prepare the email fields
44 44
         foreach ( $filter_fields as $f ) {
45 45
             //Don't allow empty From
46
-			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47
-				$notification[ $f ] = '[admin_email]';
46
+			if ( $f == 'from' && empty( $notification[$f] ) ) {
47
+				$notification[$f] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50 50
                 //Add a space in case there isn't one
51
-				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52
-				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
51
+				$notification[$f] = str_replace( '<', ' ', $notification[$f] );
52
+				$notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] );
53 53
 
54 54
                 //Switch userID shortcode to email address
55
-				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56
-					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
55
+				if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) {
56
+					$user_data = get_userdata( $entry->metas[$user_id_field] );
57 57
                     $user_email = $user_data->user_email;
58
-					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
58
+					$notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] );
59 59
                 }
60 60
             }
61 61
 
62
-			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
62
+			$notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry );
63 63
         }
64 64
 
65 65
         //Put recipients, cc, and bcc into an array if they aren't empty
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+        $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) );
71 71
 
72 72
         // Stop now if there aren't any recipients
73 73
         if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
         $to_emails = array_unique( (array) $to_emails );
78 78
 
79 79
         $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
80
+        $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array(
81 81
             'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
82
+            'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ),
83 83
         ) );
84 84
 
85 85
         // Add the user info if it isn't already included
86 86
         if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
87
+            $data = maybe_unserialize( $entry->description );
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92 92
         }
93
-        unset($prev_mail_body);
93
+        unset( $prev_mail_body );
94 94
 
95 95
         // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
96
+        $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) );
97 97
 
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
98
+        if ( ! empty( $notification['email_subject'] ) ) {
99
+            $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) );
100 100
         }
101 101
 
102 102
         // check for a phone number
103 103
         foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
104
+            if ( $e != '[admin_email]' && ! is_email( $e ) ) {
105
+                $e = explode( ' ', $e );
106 106
 
107 107
                 //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
108
+                if ( is_email( end( $e ) ) ) {
109 109
                     continue;
110 110
                 }
111 111
 
112
-                do_action('frm_send_to_not_email', array(
112
+                do_action( 'frm_send_to_not_email', array(
113 113
                     'e'         => $e,
114 114
                     'subject'   => $notification['email_subject'],
115 115
                     'mail_body' => $mail_body,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                     'email_key' => $email_key,
122 122
                 ) );
123 123
 
124
-				unset( $to_emails[ $email_key ] );
124
+				unset( $to_emails[$email_key] );
125 125
             }
126 126
         }
127 127
 
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
147
+        FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' );
148 148
     }
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151 151
         _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
153
+        return self::send_email( compact(
154 154
             'to_email', 'subject', 'message',
155 155
             'from', 'from_name', 'plain_text',
156 156
             'attachments', 'reply_to'
157
-        ));
157
+        ) );
158 158
     }
159 159
 
160 160
 	/**
@@ -187,28 +187,28 @@  discard block
 block discarded – undo
187 187
     private static function format_email_fields( &$atts, $admin_email ) {
188 188
 
189 189
         // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
190
+        $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191 191
 
192 192
         // Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195 195
         foreach ( $filter_fields as $f ) {
196 196
             // If empty, just skip it
197
-			if ( empty( $atts[ $f ] ) ) {
197
+			if ( empty( $atts[$f] ) ) {
198 198
                 continue;
199 199
             }
200 200
 
201 201
             // to_email, cc, and bcc can be an array
202
-			if ( is_array( $atts[ $f ] ) ) {
203
-				foreach ( $atts[ $f ] as $key => $val ) {
202
+			if ( is_array( $atts[$f] ) ) {
203
+				foreach ( $atts[$f] as $key => $val ) {
204 204
                     self::format_single_field( $atts, $f, $val, $key );
205 205
                     unset( $key, $val );
206 206
                 }
207
-                unset($f);
207
+                unset( $f );
208 208
                 continue;
209 209
             }
210 210
 
211
-			self::format_single_field( $atts, $f, $atts[ $f ] );
211
+			self::format_single_field( $atts, $f, $atts[$f] );
212 212
         }
213 213
 
214 214
         // If reply-to isn't set, make it match the from settings
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217 217
         }
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
219
+        if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) {
220 220
             $atts['to_email'] = $admin_email;
221 221
         }
222 222
     }
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
     * @param int $key if in array, this will be set
240 240
     */
241 241
     private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
242
+        $val = trim( $val );
243 243
 
244 244
         // If just a plain email is used
245
-        if ( is_email($val) ) {
245
+        if ( is_email( $val ) ) {
246 246
             // add sender's name if not included in $from
247 247
             if ( $f == 'from' ) {
248
-				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
248
+				$part_2 = $atts[$f];
249
+                $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250 250
             } else {
251 251
                 return;
252 252
             }
253 253
         } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
254
+            $parts = explode( ' ', $val );
255
+            $part_2 = end( $parts );
256 256
 
257 257
             // If inputted correcly, $part_2 should be an email
258 258
             if ( is_email( $part_2 ) ) {
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
             } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
263
+                $part_2 = get_option( 'admin_email' );
264 264
             } else {
265 265
 				// In case someone just puts a name in any other email field
266 266
                 if ( false !== $key ) {
267
-					unset( $atts[ $f ][ $key ] );
267
+					unset( $atts[$f][$key] );
268 268
                     return;
269 269
                 }
270
-				$atts[ $f ] = '';
270
+				$atts[$f] = '';
271 271
                 return;
272 272
             }
273 273
         }
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 
289 289
         // If value is an array
290 290
         if ( false !== $key ) {
291
-			$atts[ $f ][ $key ] = $final_val;
291
+			$atts[$f][$key] = $final_val;
292 292
             return;
293 293
         }
294
-		$atts[ $f ] = $final_val;
294
+		$atts[$f] = $final_val;
295 295
     }
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
298
+        $admin_email = get_option( 'admin_email' );
299 299
         $defaults = array(
300 300
             'to_email'      => $admin_email,
301 301
             'subject'       => '',
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             'reply_to'      => $admin_email,
309 309
             'attachments'   => array(),
310 310
         );
311
-        $atts = wp_parse_args($atts, $defaults);
311
+        $atts = wp_parse_args( $atts, $defaults );
312 312
 
313 313
         // Put To, BCC, CC, Reply To, and From fields in the correct format
314 314
         self::format_email_fields( $atts, $admin_email );
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323 323
         foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
324
+            if ( empty( $a_field ) ) {
325 325
                 continue;
326 326
             }
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329
-				$cc[ $key ][] = $email;
329
+				$cc[$key][] = $email;
330 330
             }
331
-            unset($key, $a_field);
331
+            unset( $key, $a_field );
332 332
         }
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
@@ -337,52 +337,52 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 
339 339
         $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
340
+        $charset        = get_option( 'blog_charset' );
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+        $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+        $message = do_shortcode( $atts['message'] );
347 347
 
348 348
         if ( $atts['plain_text'] ) {
349 349
             //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
350
+            $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES );
351 351
         } else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353 353
         	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354 354
         }
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+        $header = apply_filters( 'frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+        if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363 363
         }
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+        remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
366
+        remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
368
+        $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] );
369 369
         if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
371
+            $recipient = implode( ',', (array) $recipient );
372
+            $sent = mail( $recipient, $atts['subject'], $message, $header );
373 373
         }
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+        do_action( 'frm_notification', $recipient, $atts['subject'], $message );
379 379
 
380 380
         if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382 382
             $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
385
-				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
383
+            if ( apply_filters( 'frm_echo_emails', false ) ) {
384
+                $temp = str_replace( '<', '&lt;', $sent_to );
385
+				echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) );
386 386
             }
387 387
             return $sent_to;
388 388
         }
Please login to merge, or discard this patch.