Completed
Push — master ( 20018b...f7c85c )
by Jamie
06:26 queued 02:51
created
classes/views/frm-fields/input.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
150
-            }
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
121 121
     }
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +570 added lines, -570 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,99 +127,99 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = array(
131
-                'id'            => (int) $item->id,
132
-                'form_key'      => (string) $item->form_key,
133
-                'name'          => (string) $item->name,
134
-                'description'   => (string) $item->description,
135
-                'options'       => (string) $item->options,
136
-                'logged_in'     => (int) $item->logged_in,
137
-                'is_template'   => (int) $item->is_template,
138
-                'default_template' => (int) $item->default_template,
139
-                'editable'      => (int) $item->editable,
140
-                'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
-            );
144
-
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
130
+			$form = array(
131
+				'id'            => (int) $item->id,
132
+				'form_key'      => (string) $item->form_key,
133
+				'name'          => (string) $item->name,
134
+				'description'   => (string) $item->description,
135
+				'options'       => (string) $item->options,
136
+				'logged_in'     => (int) $item->logged_in,
137
+				'is_template'   => (int) $item->is_template,
138
+				'default_template' => (int) $item->default_template,
139
+				'editable'      => (int) $item->editable,
140
+				'status'        => (string) $item->status,
141
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
+			);
144
+
145
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
149
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
149
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
150 150
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
151
-            if ( ! $form['is_template'] ) {
152
-                $edit_query['created_at'] = $form['created_at'];
153
-            }
151
+			if ( ! $form['is_template'] ) {
152
+				$edit_query['created_at'] = $form['created_at'];
153
+			}
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+			$this_form = FrmForm::getAll($edit_query, '', 1);
158
+			unset($edit_query);
159 159
 
160
-            if ( ! empty( $this_form ) ) {
161
-                $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
164
-                // Keep track of whether this specific form was updated or not
160
+			if ( ! empty( $this_form ) ) {
161
+				$old_id = $form_id = $this_form->id;
162
+				FrmForm::update($form_id, $form );
163
+				$imported['updated']['forms']++;
164
+				// Keep track of whether this specific form was updated or not
165 165
 				$imported['form_status'][ $form_id ] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168
-                $old_fields = array();
169
-                foreach ( $form_fields as $f ) {
168
+				$old_fields = array();
169
+				foreach ( $form_fields as $f ) {
170 170
 					$old_fields[ $f->id ] = $f;
171 171
 					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
173
-                }
174
-                $form_fields = $old_fields;
175
-                unset($old_fields);
176
-            } else {
177
-                $old_id = false;
178
-                //form does not exist, so create it
172
+					unset($f);
173
+				}
174
+				$form_fields = $old_fields;
175
+				unset($old_fields);
176
+			} else {
177
+				$old_id = false;
178
+				//form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180
-                if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
182
-                    // Keep track of whether this specific form was updated or not
180
+				if ( $form_id ) {
181
+					$imported['imported']['forms']++;
182
+					// Keep track of whether this specific form was updated or not
183 183
 					$imported['form_status'][ $form_id ] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185
-                }
186
-            }
185
+				}
186
+			}
187 187
 
188
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189 189
 
190
-    		// Delete any fields attached to this form that were not included in the template
191
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
190
+			// Delete any fields attached to this form that were not included in the template
191
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
195
-                    }
196
-                    unset($field);
197
-                }
198
-                unset($form_fields);
199
-            }
200
-
201
-		    // Update field ids/keys to new ones
193
+					if ( is_object($field) ) {
194
+						FrmField::destroy($field->id);
195
+					}
196
+					unset($field);
197
+				}
198
+				unset($form_fields);
199
+			}
200
+
201
+			// Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204 204
 			$imported['forms'][ (int) $item->id ] = $form_id;
205 205
 
206
-            // Send pre 2.0 form options through function that creates actions
207
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
206
+			// Send pre 2.0 form options through function that creates actions
207
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+			unset($form, $item);
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
213 213
 
214 214
 		return $imported;
215
-    }
215
+	}
216 216
 
217 217
 	/**
218
-	* Put child forms first so they will be imported before parents
219
-	*
220
-	* @since 2.0.16
221
-	* @param array $forms
222
-	*/
218
+	 * Put child forms first so they will be imported before parents
219
+	 *
220
+	 * @since 2.0.16
221
+	 * @param array $forms
222
+	 */
223 223
 	private static function put_child_forms_first( &$forms ) {
224 224
 		$child_forms = array();
225 225
 		$regular_forms = array();
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Keep track of all imported child forms
242
-	*
243
-	* @since 2.0.16
244
-	* @param int $form_id
245
-	* @param int $parent_form_id
246
-	* @param array $child_forms
247
-	*/
241
+	 * Keep track of all imported child forms
242
+	 *
243
+	 * @since 2.0.16
244
+	 * @param int $form_id
245
+	 * @param int $parent_form_id
246
+	 * @param array $child_forms
247
+	 */
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250 250
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Update the parent_form_id on imported child forms
256
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
-	*
258
-	* @since 2.0.6
259
-	* @param array $imported_forms
260
-	* @param array $child_forms
261
-	*/
255
+	 * Update the parent_form_id on imported child forms
256
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
+	 *
258
+	 * @since 2.0.6
259
+	 * @param array $imported_forms
260
+	 * @param array $child_forms
261
+	 */
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Import all fields for a form
276
-	* @since 2.0.13
277
-	*
278
-	* TODO: Cut down on params
279
-	*/
275
+	 * Import all fields for a form
276
+	 * @since 2.0.13
277
+	 *
278
+	 * TODO: Cut down on params
279
+	 */
280 280
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
281 281
 		$in_section = 0;
282 282
 
283 283
 		foreach ( $xml_fields as $field ) {
284
-		    $f = array(
285
-		        'id'            => (int) $field->id,
286
-		        'field_key'     => (string) $field->field_key,
287
-		        'name'          => (string) $field->name,
288
-		        'description'   => (string) $field->description,
289
-		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
-		        'field_order'   => (int) $field->field_order,
292
-		        'form_id'       => (int) $form_id,
293
-		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
284
+			$f = array(
285
+				'id'            => (int) $field->id,
286
+				'field_key'     => (string) $field->field_key,
287
+				'name'          => (string) $field->name,
288
+				'description'   => (string) $field->description,
289
+				'type'          => (string) $field->type,
290
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
+				'field_order'   => (int) $field->field_order,
292
+				'form_id'       => (int) $form_id,
293
+				'required'      => (int) $field->required,
294
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296
-		    );
297
-
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
299
-		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
301
-		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
296
+			);
297
+
298
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
299
+				'text', 'email', 'url', 'textarea',
300
+				'number','phone', 'date', 'time',
301
+				'hidden', 'password', 'tag', 'image',
302
+			)) ) {
303
+				if ( count($f['default_value']) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305
-		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
307
-		        }
308
-		    }
305
+				} else {
306
+					$f['default_value'] = reset($f['default_value']);
307
+				}
308
+			}
309 309
 
310 310
 			self::maybe_update_form_select( $f, $imported );
311 311
 
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
372
-	*
373
-	* @since 2.0.16
374
-	* @param array $f
375
-	* @param array $imported
376
-	*/
371
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
372
+	 *
373
+	 * @since 2.0.16
374
+	 * @param array $f
375
+	 * @param array $imported
376
+	 */
377 377
 	private static function maybe_update_form_select( &$f, $imported ) {
378 378
 		if ( ! isset( $imported['forms'] ) ) {
379 379
 			return;
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	}
405 405
 
406 406
 	/**
407
-	* Updates the custom style setting on import
408
-	*
409
-	* @since 2.0.19
410
-	* @param array $form
411
-	*
412
-	*/
407
+	 * Updates the custom style setting on import
408
+	 *
409
+	 * @since 2.0.19
410
+	 * @param array $form
411
+	 *
412
+	 */
413 413
 	private static function update_custom_style_setting_on_import( &$form ) {
414 414
 		if ( ! isset( $form['options']['custom_style'] ) ) {
415 415
 			return;
@@ -439,16 +439,16 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 
441 441
 	public static function import_xml_views( $views, $imported ) {
442
-        $imported['posts'] = array();
443
-        $form_action_type = FrmFormActionsController::$action_post_type;
442
+		$imported['posts'] = array();
443
+		$form_action_type = FrmFormActionsController::$action_post_type;
444 444
 
445
-        $post_types = array(
446
-            'frm_display' => 'views',
447
-            $form_action_type => 'actions',
448
-            'frm_styles'    => 'styles',
449
-        );
445
+		$post_types = array(
446
+			'frm_display' => 'views',
447
+			$form_action_type => 'actions',
448
+			'frm_styles'    => 'styles',
449
+		);
450 450
 
451
-        foreach ( $views as $item ) {
451
+		foreach ( $views as $item ) {
452 452
 			$post = array(
453 453
 				'post_title'    => (string) $item->title,
454 454
 				'post_name'     => (string) $item->post_name,
@@ -467,52 +467,52 @@  discard block
 block discarded – undo
467 467
 				'post_date'     => (string) $item->post_date,
468 468
 				'post_date_gmt' => (string) $item->post_date_gmt,
469 469
 				'ping_status'   => (string) $item->ping_status,
470
-                'postmeta'      => array(),
471
-                'tax_input'     => array(),
470
+				'postmeta'      => array(),
471
+				'tax_input'     => array(),
472 472
 			);
473 473
 
474
-            $old_id = $post['post_id'];
475
-            self::populate_post($post, $item, $imported);
474
+			$old_id = $post['post_id'];
475
+			self::populate_post($post, $item, $imported);
476 476
 
477 477
 			unset($item);
478 478
 
479 479
 			$post_id = false;
480
-            if ( $post['post_type'] == $form_action_type ) {
481
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
480
+			if ( $post['post_type'] == $form_action_type ) {
481
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
482 482
 				if ( $action_control ) {
483 483
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
484 484
 				}
485
-                unset($action_control);
486
-            } else if ( $post['post_type'] == 'frm_styles' ) {
487
-                // Properly encode post content before inserting the post
488
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
489
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
490
-
491
-                // Create/update post now
492
-                $post_id = wp_insert_post( $post );
493
-            } else {
494
-                // Create/update post now
495
-                $post_id = wp_insert_post( $post );
496
-            }
497
-
498
-            if ( ! is_numeric($post_id) ) {
499
-                continue;
500
-            }
501
-
502
-            self::update_postmeta($post, $post_id);
503
-
504
-            $this_type = 'posts';
485
+				unset($action_control);
486
+			} else if ( $post['post_type'] == 'frm_styles' ) {
487
+				// Properly encode post content before inserting the post
488
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
489
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
490
+
491
+				// Create/update post now
492
+				$post_id = wp_insert_post( $post );
493
+			} else {
494
+				// Create/update post now
495
+				$post_id = wp_insert_post( $post );
496
+			}
497
+
498
+			if ( ! is_numeric($post_id) ) {
499
+				continue;
500
+			}
501
+
502
+			self::update_postmeta($post, $post_id);
503
+
504
+			$this_type = 'posts';
505 505
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
506 506
 				$this_type = $post_types[ $post['post_type'] ];
507
-            }
507
+			}
508 508
 
509
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
510
-                $imported['updated'][ $this_type ]++;
511
-            } else {
512
-                $imported['imported'][ $this_type ]++;
513
-            }
509
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
510
+				$imported['updated'][ $this_type ]++;
511
+			} else {
512
+				$imported['imported'][ $this_type ]++;
513
+			}
514 514
 
515
-            unset($post);
515
+			unset($post);
516 516
 
517 517
 			$imported['posts'][ (int) $old_id ] = $post_id;
518 518
 		}
@@ -520,157 +520,157 @@  discard block
 block discarded – undo
520 520
 		self::maybe_update_stylesheet( $imported );
521 521
 
522 522
 		return $imported;
523
-    }
523
+	}
524 524
 
525
-    private static function populate_post( &$post, $item, $imported ) {
525
+	private static function populate_post( &$post, $item, $imported ) {
526 526
 		if ( isset($item->attachment_url) ) {
527 527
 			$post['attachment_url'] = (string) $item->attachment_url;
528 528
 		}
529 529
 
530 530
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
531
-		    // update to new form id
532
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
531
+			// update to new form id
532
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
533 533
 		}
534 534
 
535 535
 		foreach ( $item->postmeta as $meta ) {
536
-		    self::populate_postmeta($post, $meta, $imported);
536
+			self::populate_postmeta($post, $meta, $imported);
537 537
 			unset($meta);
538 538
 		}
539 539
 
540
-        self::populate_taxonomies($post, $item);
540
+		self::populate_taxonomies($post, $item);
541 541
 
542
-        self::maybe_editing_post($post);
543
-    }
542
+		self::maybe_editing_post($post);
543
+	}
544 544
 
545
-    private static function populate_postmeta( &$post, $meta, $imported ) {
546
-        global $frm_duplicate_ids;
545
+	private static function populate_postmeta( &$post, $meta, $imported ) {
546
+		global $frm_duplicate_ids;
547 547
 
548
-	    $m = array(
548
+		$m = array(
549 549
 			'key'   => (string) $meta->meta_key,
550 550
 			'value' => (string) $meta->meta_value,
551 551
 		);
552 552
 
553 553
 		//switch old form and field ids to new ones
554 554
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
555
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
555
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
556 556
 		} else {
557
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
557
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
558 558
 
559
-		    if ( ! empty($frm_duplicate_ids) ) {
559
+			if ( ! empty($frm_duplicate_ids) ) {
560 560
 
561
-		        if ( $m['key'] == 'frm_dyncontent' ) {
562
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
563
-    		    } else if ( $m['key'] == 'frm_options' ) {
561
+				if ( $m['key'] == 'frm_dyncontent' ) {
562
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
563
+				} else if ( $m['key'] == 'frm_options' ) {
564 564
 
565 565
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
566 566
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
567 567
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
568
-    		            }
569
-    		        }
570
-
571
-                    $check_dup_array = array();
572
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
573
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
574
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
575
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
576
-                            $check_dup_array[] = 'order_by';
577
-    		            }
578
-    		        }
579
-
580
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
581
-    		            $check_dup_array[] = 'where';
582
-    		        }
583
-
584
-                    foreach ( $check_dup_array as $check_k ) {
568
+						}
569
+					}
570
+
571
+					$check_dup_array = array();
572
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
573
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
574
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
575
+						} else if ( is_array( $m['value']['order_by'] ) ) {
576
+							$check_dup_array[] = 'order_by';
577
+						}
578
+					}
579
+
580
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
581
+						$check_dup_array[] = 'where';
582
+					}
583
+
584
+					foreach ( $check_dup_array as $check_k ) {
585 585
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
586 586
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
587 587
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
588
-		                    }
589
-		                    unset($mk, $mv);
590
-		                }
591
-                    }
592
-    		    }
593
-		    }
588
+							}
589
+							unset($mk, $mv);
590
+						}
591
+					}
592
+				}
593
+			}
594 594
 		}
595 595
 
596 596
 		if ( ! is_array($m['value']) ) {
597
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
597
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
598 598
 		}
599 599
 
600 600
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
601
-    }
602
-
603
-    /**
604
-     * Add terms to post
605
-     * @param array $post by reference
606
-     * @param object $item The XML object data
607
-     */
608
-    private static function populate_taxonomies( &$post, $item ) {
601
+	}
602
+
603
+	/**
604
+	 * Add terms to post
605
+	 * @param array $post by reference
606
+	 * @param object $item The XML object data
607
+	 */
608
+	private static function populate_taxonomies( &$post, $item ) {
609 609
 		foreach ( $item->category as $c ) {
610 610
 			$att = $c->attributes();
611 611
 			if ( ! isset( $att['nicename'] ) ) {
612
-                continue;
613
-            }
614
-
615
-		    $taxonomy = (string) $att['domain'];
616
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
617
-		        $name = (string) $att['nicename'];
618
-		        $h_term = get_term_by('slug', $name, $taxonomy);
619
-		        if ( $h_term ) {
620
-		            $name = $h_term->term_id;
621
-		        }
622
-		        unset($h_term);
623
-		    } else {
624
-		        $name = (string) $c;
625
-		    }
612
+				continue;
613
+			}
614
+
615
+			$taxonomy = (string) $att['domain'];
616
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
617
+				$name = (string) $att['nicename'];
618
+				$h_term = get_term_by('slug', $name, $taxonomy);
619
+				if ( $h_term ) {
620
+					$name = $h_term->term_id;
621
+				}
622
+				unset($h_term);
623
+			} else {
624
+				$name = (string) $c;
625
+			}
626 626
 
627 627
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
628 628
 				$post['tax_input'][ $taxonomy ] = array();
629 629
 			}
630 630
 
631 631
 			$post['tax_input'][ $taxonomy ][] = $name;
632
-		    unset($name);
632
+			unset($name);
633 633
 		}
634
-    }
634
+	}
635 635
 
636
-    /**
637
-     * Edit post if the key and created time match
638
-     */
639
-    private static function maybe_editing_post( &$post ) {
636
+	/**
637
+	 * Edit post if the key and created time match
638
+	 */
639
+	private static function maybe_editing_post( &$post ) {
640 640
 		$match_by = array(
641
-		    'post_type'     => $post['post_type'],
642
-		    'name'          => $post['post_name'],
643
-		    'post_status'   => $post['post_status'],
644
-		    'posts_per_page' => 1,
641
+			'post_type'     => $post['post_type'],
642
+			'name'          => $post['post_name'],
643
+			'post_status'   => $post['post_status'],
644
+			'posts_per_page' => 1,
645 645
 		);
646 646
 
647 647
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
648
-		    $match_by['include'] = $post['post_id'];
649
-		    unset($match_by['name']);
648
+			$match_by['include'] = $post['post_id'];
649
+			unset($match_by['name']);
650 650
 		}
651 651
 
652 652
 		$editing = get_posts($match_by);
653 653
 
654
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
655
-            // set the id of the post to edit
656
-            $post['ID'] = current($editing)->ID;
657
-        }
658
-    }
654
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
655
+			// set the id of the post to edit
656
+			$post['ID'] = current($editing)->ID;
657
+		}
658
+	}
659 659
 
660
-    private static function update_postmeta( &$post, $post_id ) {
661
-        foreach ( $post['postmeta'] as $k => $v ) {
662
-            if ( '_edit_last' == $k ) {
663
-                $v = FrmAppHelper::get_user_id_param($v);
664
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
665
-                //change the attachment ID
666
-                $v = FrmProXMLHelper::get_file_id($v);
667
-            }
660
+	private static function update_postmeta( &$post, $post_id ) {
661
+		foreach ( $post['postmeta'] as $k => $v ) {
662
+			if ( '_edit_last' == $k ) {
663
+				$v = FrmAppHelper::get_user_id_param($v);
664
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
665
+				//change the attachment ID
666
+				$v = FrmProXMLHelper::get_file_id($v);
667
+			}
668 668
 
669
-            update_post_meta($post_id, $k, $v);
669
+			update_post_meta($post_id, $k, $v);
670 670
 
671
-            unset($k, $v);
672
-        }
673
-    }
671
+			unset($k, $v);
672
+		}
673
+	}
674 674
 
675 675
 	private static function maybe_update_stylesheet( $imported ) {
676 676
 		if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) {
@@ -681,72 +681,72 @@  discard block
 block discarded – undo
681 681
 		}
682 682
 	}
683 683
 
684
-    /**
685
-     * @param string $message
686
-     */
684
+	/**
685
+	 * @param string $message
686
+	 */
687 687
 	public static function parse_message( $result, &$message, &$errors ) {
688
-        if ( is_wp_error($result) ) {
689
-            $errors[] = $result->get_error_message();
690
-        } else if ( ! $result ) {
691
-            return;
692
-        }
693
-
694
-        if ( ! is_array($result) ) {
695
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
696
-            return;
697
-        }
698
-
699
-        $t_strings = array(
700
-            'imported'  => __( 'Imported', 'formidable' ),
701
-            'updated'   => __( 'Updated', 'formidable' ),
702
-        );
703
-
704
-        $message = '<ul>';
705
-        foreach ( $result as $type => $results ) {
688
+		if ( is_wp_error($result) ) {
689
+			$errors[] = $result->get_error_message();
690
+		} else if ( ! $result ) {
691
+			return;
692
+		}
693
+
694
+		if ( ! is_array($result) ) {
695
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
696
+			return;
697
+		}
698
+
699
+		$t_strings = array(
700
+			'imported'  => __( 'Imported', 'formidable' ),
701
+			'updated'   => __( 'Updated', 'formidable' ),
702
+		);
703
+
704
+		$message = '<ul>';
705
+		foreach ( $result as $type => $results ) {
706 706
 			if ( ! isset( $t_strings[ $type ] ) ) {
707
-                // only print imported and updated
708
-                continue;
709
-            }
707
+				// only print imported and updated
708
+				continue;
709
+			}
710 710
 
711
-            $s_message = array();
712
-            foreach ( $results as $k => $m ) {
713
-                self::item_count_message($m, $k, $s_message);
714
-                unset($k, $m);
715
-            }
711
+			$s_message = array();
712
+			foreach ( $results as $k => $m ) {
713
+				self::item_count_message($m, $k, $s_message);
714
+				unset($k, $m);
715
+			}
716 716
 
717
-            if ( ! empty($s_message) ) {
717
+			if ( ! empty($s_message) ) {
718 718
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
719
-                $message .= implode(', ', $s_message);
720
-                $message .= '</li>';
721
-            }
722
-        }
723
-
724
-        if ( $message == '<ul>' ) {
725
-            $message = '';
726
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
727
-        } else {
728
-            $message .= '</ul>';
729
-        }
730
-    }
719
+				$message .= implode(', ', $s_message);
720
+				$message .= '</li>';
721
+			}
722
+		}
723
+
724
+		if ( $message == '<ul>' ) {
725
+			$message = '';
726
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
727
+		} else {
728
+			$message .= '</ul>';
729
+		}
730
+	}
731 731
 
732 732
 	public static function item_count_message( $m, $type, &$s_message ) {
733
-        if ( ! $m ) {
734
-            return;
735
-        }
736
-
737
-        $strings = array(
738
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
739
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
740
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
741
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
742
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
743
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
744
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
745
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
746
-        );
733
+		if ( ! $m ) {
734
+			return;
735
+		}
736
+
737
+		$strings = array(
738
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
739
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
740
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
741
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
742
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
743
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
744
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
745
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
746
+		);
747 747
 
748 748
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
749
-    }
749
+	}
750 750
 
751 751
 	/**
752 752
 	 * Prepare the form options for export
@@ -777,16 +777,16 @@  discard block
 block discarded – undo
777 777
 	}
778 778
 
779 779
 	public static function cdata( $str ) {
780
-	    $str = maybe_unserialize($str);
781
-	    if ( is_array($str) ) {
782
-	        $str = json_encode($str);
780
+		$str = maybe_unserialize($str);
781
+		if ( is_array($str) ) {
782
+			$str = json_encode($str);
783 783
 		} else if ( seems_utf8( $str ) == false ) {
784 784
 			$str = utf8_encode( $str );
785 785
 		}
786 786
 
787
-        if ( is_numeric($str) ) {
788
-            return $str;
789
-        }
787
+		if ( is_numeric($str) ) {
788
+			return $str;
789
+		}
790 790
 
791 791
 		self::remove_invalid_characters_from_xml( $str );
792 792
 
@@ -807,58 +807,58 @@  discard block
 block discarded – undo
807 807
 		$str = str_replace( '\x1F', '', $str );
808 808
 	}
809 809
 
810
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
811
-        // Get post type
812
-        $post_type = FrmFormActionsController::$action_post_type;
813
-
814
-        // Set up imported index, if not set up yet
815
-        if ( ! isset( $imported['imported']['actions'] ) ) {
816
-            $imported['imported']['actions'] = 0;
817
-        }
818
-
819
-        // Migrate post settings to action
820
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
821
-
822
-        // Migrate email settings to action
823
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
824
-    }
825
-
826
-    /**
827
-    * Migrate post settings to form action
828
-    *
829
-    * @param string $post_type
830
-    */
831
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
832
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
833
-            return;
834
-        }
835
-
836
-        $new_action = array(
837
-            'post_type'     => $post_type,
838
-            'post_excerpt'  => 'wppost',
810
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
811
+		// Get post type
812
+		$post_type = FrmFormActionsController::$action_post_type;
813
+
814
+		// Set up imported index, if not set up yet
815
+		if ( ! isset( $imported['imported']['actions'] ) ) {
816
+			$imported['imported']['actions'] = 0;
817
+		}
818
+
819
+		// Migrate post settings to action
820
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
821
+
822
+		// Migrate email settings to action
823
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
824
+	}
825
+
826
+	/**
827
+	 * Migrate post settings to form action
828
+	 *
829
+	 * @param string $post_type
830
+	 */
831
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
832
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
833
+			return;
834
+		}
835
+
836
+		$new_action = array(
837
+			'post_type'     => $post_type,
838
+			'post_excerpt'  => 'wppost',
839 839
 			'post_title'    => __( 'Create Posts', 'formidable' ),
840
-            'menu_order'    => $form_id,
841
-            'post_status'   => 'publish',
842
-            'post_content'  => array(),
840
+			'menu_order'    => $form_id,
841
+			'post_status'   => 'publish',
842
+			'post_content'  => array(),
843 843
 			'post_name'     => $form_id . '_wppost_1',
844
-        );
844
+		);
845 845
 
846
-        $post_settings = array(
847
-            'post_type', 'post_category', 'post_content',
848
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
846
+		$post_settings = array(
847
+			'post_type', 'post_category', 'post_content',
848
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
849 849
 			'post_status', 'post_custom_fields', 'post_password',
850
-        );
850
+		);
851 851
 
852
-        foreach ( $post_settings as $post_setting ) {
852
+		foreach ( $post_settings as $post_setting ) {
853 853
 			if ( isset( $form_options[ $post_setting ] ) ) {
854 854
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
855
-            }
856
-            unset($post_setting);
857
-        }
855
+			}
856
+			unset($post_setting);
857
+		}
858 858
 
859 859
 		$new_action['event'] = array( 'create', 'update' );
860 860
 
861
-        if ( $switch ) {
861
+		if ( $switch ) {
862 862
 			// Fields with string or int saved
863 863
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
864 864
 
@@ -866,22 +866,22 @@  discard block
 block discarded – undo
866 866
 			$array_fields = array( 'post_category', 'post_custom_fields' );
867 867
 
868 868
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
869
-        }
870
-        $new_action['post_content'] = json_encode($new_action['post_content']);
869
+		}
870
+		$new_action['post_content'] = json_encode($new_action['post_content']);
871 871
 
872
-        $exists = get_posts( array(
873
-            'name'          => $new_action['post_name'],
874
-            'post_type'     => $new_action['post_type'],
875
-            'post_status'   => $new_action['post_status'],
876
-            'numberposts'   => 1,
877
-        ) );
872
+		$exists = get_posts( array(
873
+			'name'          => $new_action['post_name'],
874
+			'post_type'     => $new_action['post_type'],
875
+			'post_status'   => $new_action['post_status'],
876
+			'numberposts'   => 1,
877
+		) );
878 878
 
879
-        if ( ! $exists ) {
879
+		if ( ! $exists ) {
880 880
 			// this isn't an email, but we need to use a class that will always be included
881 881
 			FrmAppHelper::save_json_post( $new_action );
882
-            $imported['imported']['actions']++;
883
-        }
884
-    }
882
+			$imported['imported']['actions']++;
883
+		}
884
+	}
885 885
 
886 886
 	/**
887 887
 	 * Switch old field IDs for new field IDs in emails and post
@@ -894,211 +894,211 @@  discard block
 block discarded – undo
894 894
 	 * @return string $post_content - new field IDs
895 895
 	 */
896 896
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
897
-        global $frm_duplicate_ids;
897
+		global $frm_duplicate_ids;
898 898
 
899
-        // If there aren't IDs that were switched, end now
900
-        if ( ! $frm_duplicate_ids ) {
901
-            return;
902
-        }
899
+		// If there aren't IDs that were switched, end now
900
+		if ( ! $frm_duplicate_ids ) {
901
+			return;
902
+		}
903 903
 
904
-        // Get old IDs
905
-        $old = array_keys( $frm_duplicate_ids );
904
+		// Get old IDs
905
+		$old = array_keys( $frm_duplicate_ids );
906 906
 
907
-        // Get new IDs
908
-        $new = array_values( $frm_duplicate_ids );
907
+		// Get new IDs
908
+		$new = array_values( $frm_duplicate_ids );
909 909
 
910
-        // Do a str_replace with each item to set the new IDs
911
-        foreach ( $post_content as $key => $setting ) {
912
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
913
-                // Replace old IDs with new IDs
910
+		// Do a str_replace with each item to set the new IDs
911
+		foreach ( $post_content as $key => $setting ) {
912
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
913
+				// Replace old IDs with new IDs
914 914
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
915
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
916
-                foreach ( $setting as $k => $val ) {
917
-                    // Replace old IDs with new IDs
915
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
916
+				foreach ( $setting as $k => $val ) {
917
+					// Replace old IDs with new IDs
918 918
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
919
-                }
920
-            }
921
-            unset( $key, $setting );
922
-        }
923
-        return $post_content;
924
-    }
925
-
926
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
927
-        // No old notifications or autoresponders to carry over
919
+				}
920
+			}
921
+			unset( $key, $setting );
922
+		}
923
+		return $post_content;
924
+	}
925
+
926
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
927
+		// No old notifications or autoresponders to carry over
928 928
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
929
-            return;
930
-        }
929
+			return;
930
+		}
931 931
 
932
-        // Initialize notifications array
933
-        $notifications = array();
932
+		// Initialize notifications array
933
+		$notifications = array();
934 934
 
935
-        // Migrate regular notifications
936
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
935
+		// Migrate regular notifications
936
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
937 937
 
938
-        // Migrate autoresponders
939
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
938
+		// Migrate autoresponders
939
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
940 940
 
941
-        if (  empty( $notifications ) ) {
942
-            return;
943
-        }
941
+		if (  empty( $notifications ) ) {
942
+			return;
943
+		}
944 944
 
945
-        foreach ( $notifications as $new_notification ) {
946
-            $new_notification['post_type']      = $post_type;
947
-            $new_notification['post_excerpt']   = 'email';
945
+		foreach ( $notifications as $new_notification ) {
946
+			$new_notification['post_type']      = $post_type;
947
+			$new_notification['post_excerpt']   = 'email';
948 948
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
949
-            $new_notification['menu_order']     = $form_id;
950
-            $new_notification['post_status']    = 'publish';
949
+			$new_notification['menu_order']     = $form_id;
950
+			$new_notification['post_status']    = 'publish';
951 951
 
952
-            // Switch field IDs and keys, if needed
953
-            if ( $switch ) {
952
+			// Switch field IDs and keys, if needed
953
+			if ( $switch ) {
954 954
 
955 955
 				// Switch field IDs in email conditional logic
956 956
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
957 957
 
958 958
 				// Switch all other field IDs in email
959
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
960
-            }
961
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
962
-
963
-            $exists = get_posts( array(
964
-                'name'          => $new_notification['post_name'],
965
-                'post_type'     => $new_notification['post_type'],
966
-                'post_status'   => $new_notification['post_status'],
967
-                'numberposts'   => 1,
968
-            ) );
969
-
970
-            if ( empty($exists) ) {
959
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
960
+			}
961
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
962
+
963
+			$exists = get_posts( array(
964
+				'name'          => $new_notification['post_name'],
965
+				'post_type'     => $new_notification['post_type'],
966
+				'post_status'   => $new_notification['post_status'],
967
+				'numberposts'   => 1,
968
+			) );
969
+
970
+			if ( empty($exists) ) {
971 971
 				FrmAppHelper::save_json_post( $new_notification );
972
-                $imported['imported']['actions']++;
973
-            }
974
-            unset($new_notification);
975
-        }
976
-    }
977
-
978
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
979
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
980
-            // add old settings into notification array
972
+				$imported['imported']['actions']++;
973
+			}
974
+			unset($new_notification);
975
+		}
976
+	}
977
+
978
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
979
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
980
+			// add old settings into notification array
981 981
 			$form_options['notification'] = array( 0 => $form_options );
982
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
983
-            // make sure it's in the correct format
982
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
983
+			// make sure it's in the correct format
984 984
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
985
-        }
985
+		}
986 986
 
987
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
988
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
987
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
988
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
989 989
 
990
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
990
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
991 991
 
992
-                // Format the email data
993
-                self::format_email_data( $atts, $notification );
992
+				// Format the email data
993
+				self::format_email_data( $atts, $notification );
994 994
 
995 995
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
996 996
 					do_action( 'frm_create_twilio_action', $atts, $notification );
997 997
 				}
998 998
 
999
-                // Setup the new notification
1000
-                $new_notification = array();
1001
-                self::setup_new_notification( $new_notification, $notification, $atts );
999
+				// Setup the new notification
1000
+				$new_notification = array();
1001
+				self::setup_new_notification( $new_notification, $notification, $atts );
1002 1002
 
1003
-                $notifications[] = $new_notification;
1004
-            }
1005
-        }
1006
-    }
1003
+				$notifications[] = $new_notification;
1004
+			}
1005
+		}
1006
+	}
1007 1007
 
1008
-    private static function format_email_data( &$atts, $notification ) {
1009
-        // Format email_to
1010
-        self::format_email_to_data( $atts, $notification );
1008
+	private static function format_email_data( &$atts, $notification ) {
1009
+		// Format email_to
1010
+		self::format_email_to_data( $atts, $notification );
1011 1011
 
1012
-        // Format the reply to email and name
1013
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1014
-        foreach ( $reply_fields as $f => $val ) {
1012
+		// Format the reply to email and name
1013
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1014
+		foreach ( $reply_fields as $f => $val ) {
1015 1015
 			if ( isset( $notification[ $f ] ) ) {
1016 1016
 				$atts[ $f ] = $notification[ $f ];
1017 1017
 				if ( 'custom' == $notification[ $f ] ) {
1018 1018
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1019 1019
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1020 1020
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1021
-                }
1022
-            }
1023
-            unset( $f, $val );
1024
-        }
1021
+				}
1022
+			}
1023
+			unset( $f, $val );
1024
+		}
1025 1025
 
1026
-        // Format event
1026
+		// Format event
1027 1027
 		$atts['event'] = array( 'create' );
1028
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1029
-            $atts['event'][] = 'update';
1030
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1028
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1029
+			$atts['event'][] = 'update';
1030
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1031 1031
 			$atts['event'] = array( 'update' );
1032
-        }
1033
-    }
1032
+		}
1033
+	}
1034 1034
 
1035
-    private static function format_email_to_data( &$atts, $notification ) {
1036
-        if ( isset( $notification['email_to'] ) ) {
1035
+	private static function format_email_to_data( &$atts, $notification ) {
1036
+		if ( isset( $notification['email_to'] ) ) {
1037 1037
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1038
-        } else {
1039
-            $atts['email_to'] = array();
1040
-        }
1038
+		} else {
1039
+			$atts['email_to'] = array();
1040
+		}
1041 1041
 
1042
-        if ( isset( $notification['also_email_to'] ) ) {
1043
-            $email_fields = (array) $notification['also_email_to'];
1044
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1045
-            unset( $email_fields );
1046
-        }
1042
+		if ( isset( $notification['also_email_to'] ) ) {
1043
+			$email_fields = (array) $notification['also_email_to'];
1044
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1045
+			unset( $email_fields );
1046
+		}
1047 1047
 
1048
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1048
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1049 1049
 
1050
-            if ( is_numeric( $email_field ) ) {
1050
+			if ( is_numeric( $email_field ) ) {
1051 1051
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1052
-            }
1052
+			}
1053 1053
 
1054
-            if ( strpos( $email_field, '|') ) {
1055
-                $email_opt = explode( '|', $email_field );
1056
-                if ( isset( $email_opt[0] ) ) {
1054
+			if ( strpos( $email_field, '|') ) {
1055
+				$email_opt = explode( '|', $email_field );
1056
+				if ( isset( $email_opt[0] ) ) {
1057 1057
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1058
-                }
1059
-                unset( $email_opt );
1060
-            }
1061
-        }
1062
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1063
-    }
1064
-
1065
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1066
-        // Set up new notification
1067
-        $new_notification = array(
1068
-            'post_content'  => array(
1069
-                'email_to'      => $atts['email_to'],
1070
-                'event'         => $atts['event'],
1071
-            ),
1058
+				}
1059
+				unset( $email_opt );
1060
+			}
1061
+		}
1062
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1063
+	}
1064
+
1065
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1066
+		// Set up new notification
1067
+		$new_notification = array(
1068
+			'post_content'  => array(
1069
+				'email_to'      => $atts['email_to'],
1070
+				'event'         => $atts['event'],
1071
+			),
1072 1072
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1073
-        );
1073
+		);
1074 1074
 
1075
-        // Add more fields to the new notification
1076
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1077
-        foreach ( $add_fields as $add_field ) {
1075
+		// Add more fields to the new notification
1076
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1077
+		foreach ( $add_fields as $add_field ) {
1078 1078
 			if ( isset( $notification[ $add_field ] ) ) {
1079 1079
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1080
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1080
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1081 1081
 				$new_notification['post_content'][ $add_field ] = 0;
1082
-            } else {
1082
+			} else {
1083 1083
 				$new_notification['post_content'][ $add_field ] = '';
1084
-            }
1085
-            unset( $add_field );
1086
-        }
1084
+			}
1085
+			unset( $add_field );
1086
+		}
1087 1087
 
1088 1088
 		// Set reply to
1089 1089
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1090 1090
 
1091
-        // Set from
1091
+		// Set from
1092 1092
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1093 1093
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1094
-        }
1095
-    }
1094
+		}
1095
+	}
1096 1096
 
1097 1097
 	/**
1098
-	* Switch field IDs in pre-2.0 email conditional logic
1099
-	*
1100
-	* @param $post_content array, pass by reference
1101
-	*/
1098
+	 * Switch field IDs in pre-2.0 email conditional logic
1099
+	 *
1100
+	 * @param $post_content array, pass by reference
1101
+	 */
1102 1102
 	private static function switch_email_contition_field_ids( &$post_content ) {
1103 1103
 		// Switch field IDs in conditional logic
1104 1104
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1111,36 +1111,36 @@  discard block
 block discarded – undo
1111 1111
 		}
1112 1112
 	}
1113 1113
 
1114
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1115
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1116
-            // migrate autoresponder
1117
-
1118
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1119
-            if ( strpos($email_field, '|') ) {
1120
-                // data from entries field
1121
-                $email_field = explode('|', $email_field);
1122
-                if ( isset($email_field[1]) ) {
1123
-                    $email_field = $email_field[1];
1124
-                }
1125
-            }
1126
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1114
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1115
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1116
+			// migrate autoresponder
1117
+
1118
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1119
+			if ( strpos($email_field, '|') ) {
1120
+				// data from entries field
1121
+				$email_field = explode('|', $email_field);
1122
+				if ( isset($email_field[1]) ) {
1123
+					$email_field = $email_field[1];
1124
+				}
1125
+			}
1126
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1127 1127
 				$email_field = '[' . $email_field . ']';
1128
-            }
1129
-
1130
-            $notification = $form_options;
1131
-            $new_notification2 = array(
1132
-                'post_content'  => array(
1133
-                    'email_message' => $notification['ar_email_message'],
1134
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1135
-                    'email_to'      => $email_field,
1136
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1137
-                    'inc_user_info' => 0,
1138
-                ),
1128
+			}
1129
+
1130
+			$notification = $form_options;
1131
+			$new_notification2 = array(
1132
+				'post_content'  => array(
1133
+					'email_message' => $notification['ar_email_message'],
1134
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1135
+					'email_to'      => $email_field,
1136
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1137
+					'inc_user_info' => 0,
1138
+				),
1139 1139
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1140
-            );
1140
+			);
1141 1141
 
1142
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1143
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1142
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1143
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1144 1144
 
1145 1145
 			if ( ! empty( $reply_to ) ) {
1146 1146
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1150,9 +1150,9 @@  discard block
 block discarded – undo
1150 1150
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1151 1151
 			}
1152 1152
 
1153
-            $notifications[] = $new_notification2;
1154
-            unset( $new_notification2 );
1155
-        }
1156
-    }
1153
+			$notifications[] = $new_notification2;
1154
+			unset( $new_notification2 );
1155
+		}
1156
+	}
1157 1157
 }
1158 1158
 
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 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
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 'default_template' => (int) $item->default_template,
139 139
                 'editable'      => (int) $item->editable,
140 140
                 'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
141
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
142
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143 143
             );
144 144
 
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
145
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
                 $edit_query['created_at'] = $form['created_at'];
153 153
             }
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
158
+            unset( $edit_query );
159 159
 
160 160
             if ( ! empty( $this_form ) ) {
161 161
                 $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
162
+                FrmForm::update( $form_id, $form );
163
+                $imported['updated']['forms'] ++;
164 164
                 // Keep track of whether this specific form was updated or not
165
-				$imported['form_status'][ $form_id ] = 'updated';
165
+				$imported['form_status'][$form_id] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168 168
                 $old_fields = array();
169 169
                 foreach ( $form_fields as $f ) {
170
-					$old_fields[ $f->id ] = $f;
171
-					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
170
+					$old_fields[$f->id] = $f;
171
+					$old_fields[$f->field_key] = $f->id;
172
+                    unset( $f );
173 173
                 }
174 174
                 $form_fields = $old_fields;
175
-                unset($old_fields);
175
+                unset( $old_fields );
176 176
             } else {
177 177
                 $old_id = false;
178 178
                 //form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180 180
                 if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
181
+                    $imported['imported']['forms'] ++;
182 182
                     // Keep track of whether this specific form was updated or not
183
-					$imported['form_status'][ $form_id ] = 'imported';
183
+					$imported['form_status'][$form_id] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185 185
                 }
186 186
             }
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
     		// Delete any fields attached to this form that were not included in the template
191 191
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
193
+                    if ( is_object( $field ) ) {
194
+                        FrmField::destroy( $field->id );
195 195
                     }
196
-                    unset($field);
196
+                    unset( $field );
197 197
                 }
198
-                unset($form_fields);
198
+                unset( $form_fields );
199 199
             }
200 200
 
201 201
 		    // Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204
-			$imported['forms'][ (int) $item->id ] = $form_id;
204
+			$imported['forms'][(int) $item->id] = $form_id;
205 205
 
206 206
             // Send pre 2.0 form options through function that creates actions
207 207
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+		    unset( $form, $item );
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$regular_forms = array();
226 226
 
227 227
 		foreach ( $forms as $form ) {
228
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
228
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
229 229
 
230 230
 			if ( $parent_form_id ) {
231 231
 				$child_forms[] = $form;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	*/
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250
-			$child_forms[ $form_id ] = $parent_form_id;
250
+			$child_forms[$form_id] = $parent_form_id;
251 251
 		}
252 252
 	}
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
265
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
265
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
266 266
 				// Update all children with this old parent_form_id
267
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
267
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
268 268
 
269 269
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
270 270
 			}
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 		        'name'          => (string) $field->name,
288 288
 		        'description'   => (string) $field->description,
289 289
 		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
291 291
 		        'field_order'   => (int) $field->field_order,
292 292
 		        'form_id'       => (int) $form_id,
293 293
 		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
294
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296 296
 		    );
297 297
 
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
298
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
299 299
 		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
300
+		        'number', 'phone', 'date', 'time',
301 301
 		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
302
+		    ) ) ) {
303
+		        if ( count( $f['default_value'] ) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305 305
 		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
306
+		            $f['default_value'] = reset( $f['default_value'] );
307 307
 		        }
308 308
 		    }
309 309
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 			self::maybe_update_form_select( $f, $imported );
312 312
 			self::maybe_update_get_values_form_setting( $imported, $f );
313 313
 
314
-			if ( ! empty($this_form) ) {
314
+			if ( ! empty( $this_form ) ) {
315 315
 				// check for field to edit by field id
316
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
316
+				if ( isset( $form_fields[$f['id']] ) ) {
317 317
 					FrmField::update( $f['id'], $f );
318
-					$imported['updated']['fields']++;
318
+					$imported['updated']['fields'] ++;
319 319
 
320
-					unset( $form_fields[ $f['id'] ] );
320
+					unset( $form_fields[$f['id']] );
321 321
 
322 322
 					//unset old field key
323
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
-						unset( $form_fields[ $f['field_key'] ] );
323
+					if ( isset( $form_fields[$f['field_key']] ) ) {
324
+						unset( $form_fields[$f['field_key']] );
325 325
 					}
326
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
326
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
327 327
 					// check for field to edit by field key
328
-					unset($f['id']);
328
+					unset( $f['id'] );
329 329
 
330
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
331
-					$imported['updated']['fields']++;
330
+					FrmField::update( $form_fields[$f['field_key']], $f );
331
+					$imported['updated']['fields'] ++;
332 332
 
333
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
334
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
333
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
334
+					unset( $form_fields[$f['field_key']] ); //unset old field key
335 335
 				} else {
336 336
 					// if no matching field id or key in this form, create the field
337 337
 					self::create_imported_field( $f, $imported );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
383 383
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
384 384
 				$form_select = $f['field_options']['form_select'];
385
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
386
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
385
+				if ( isset( $imported['forms'][$form_select] ) ) {
386
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
387 387
 				}
388 388
 			}
389 389
 		}
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 
404 404
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
405 405
 			$old_form = $f['field_options']['get_values_form'];
406
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
407
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
406
+			if ( isset( $imported['forms'][$old_form] ) ) {
407
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
408 408
 			}
409 409
 		}
410 410
 	}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	private static function create_imported_field( $f, &$imported ) {
420 420
 		$new_id = FrmField::create( $f );
421 421
 		if ( $new_id != false ) {
422
-			$imported['imported']['fields']++;
422
+			$imported['imported']['fields'] ++;
423 423
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
424 424
 		}
425 425
 	}
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 				'post_id'       => (int) $item->post_id,
482 482
 				'post_parent'   => (int) $item->post_parent,
483 483
 				'menu_order'    => (int) $item->menu_order,
484
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
485
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
484
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
485
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
486 486
 				'is_sticky'     => (string) $item->is_sticky,
487 487
 				'comment_status' => (string) $item->comment_status,
488 488
 				'post_date'     => (string) $item->post_date,
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 			);
494 494
 
495 495
             $old_id = $post['post_id'];
496
-            self::populate_post($post, $item, $imported);
496
+            self::populate_post( $post, $item, $imported );
497 497
 
498
-			unset($item);
498
+			unset( $item );
499 499
 
500 500
 			$post_id = false;
501 501
             if ( $post['post_type'] == $form_action_type ) {
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 				if ( $action_control && is_object( $action_control ) ) {
504 504
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
505 505
 				}
506
-                unset($action_control);
506
+                unset( $action_control );
507 507
             } else if ( $post['post_type'] == 'frm_styles' ) {
508 508
                 // Properly encode post content before inserting the post
509 509
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -516,26 +516,26 @@  discard block
 block discarded – undo
516 516
                 $post_id = wp_insert_post( $post );
517 517
             }
518 518
 
519
-            if ( ! is_numeric($post_id) ) {
519
+            if ( ! is_numeric( $post_id ) ) {
520 520
                 continue;
521 521
             }
522 522
 
523
-            self::update_postmeta($post, $post_id);
523
+            self::update_postmeta( $post, $post_id );
524 524
 
525 525
             $this_type = 'posts';
526
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
527
-				$this_type = $post_types[ $post['post_type'] ];
526
+			if ( isset( $post_types[$post['post_type']] ) ) {
527
+				$this_type = $post_types[$post['post_type']];
528 528
             }
529 529
 
530
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
531
-                $imported['updated'][ $this_type ]++;
530
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
531
+                $imported['updated'][$this_type] ++;
532 532
             } else {
533
-                $imported['imported'][ $this_type ]++;
533
+                $imported['imported'][$this_type] ++;
534 534
             }
535 535
 
536
-            unset($post);
536
+            unset( $post );
537 537
 
538
-			$imported['posts'][ (int) $old_id ] = $post_id;
538
+			$imported['posts'][(int) $old_id] = $post_id;
539 539
 		}
540 540
 
541 541
 		self::maybe_update_stylesheet( $imported );
@@ -544,23 +544,23 @@  discard block
 block discarded – undo
544 544
     }
545 545
 
546 546
     private static function populate_post( &$post, $item, $imported ) {
547
-		if ( isset($item->attachment_url) ) {
547
+		if ( isset( $item->attachment_url ) ) {
548 548
 			$post['attachment_url'] = (string) $item->attachment_url;
549 549
 		}
550 550
 
551
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
551
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
552 552
 		    // update to new form id
553
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
553
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
554 554
 		}
555 555
 
556 556
 		foreach ( $item->postmeta as $meta ) {
557
-		    self::populate_postmeta($post, $meta, $imported);
558
-			unset($meta);
557
+		    self::populate_postmeta( $post, $meta, $imported );
558
+			unset( $meta );
559 559
 		}
560 560
 
561
-        self::populate_taxonomies($post, $item);
561
+        self::populate_taxonomies( $post, $item );
562 562
 
563
-        self::maybe_editing_post($post);
563
+        self::maybe_editing_post( $post );
564 564
     }
565 565
 
566 566
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -572,27 +572,27 @@  discard block
 block discarded – undo
572 572
 		);
573 573
 
574 574
 		//switch old form and field ids to new ones
575
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
576
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
575
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
576
+		    $m['value'] = $imported['forms'][(int) $m['value']];
577 577
 		} else {
578
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
578
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
579 579
 
580
-		    if ( ! empty($frm_duplicate_ids) ) {
580
+		    if ( ! empty( $frm_duplicate_ids ) ) {
581 581
 
582 582
 		        if ( $m['key'] == 'frm_dyncontent' ) {
583
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
583
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
584 584
     		    } else if ( $m['key'] == 'frm_options' ) {
585 585
 
586 586
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
587
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
588
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
587
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
588
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
589 589
     		            }
590 590
     		        }
591 591
 
592 592
                     $check_dup_array = array();
593 593
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
594
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
595
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
594
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
595
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
596 596
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
597 597
                             $check_dup_array[] = 'order_by';
598 598
     		            }
@@ -603,22 +603,22 @@  discard block
 block discarded – undo
603 603
     		        }
604 604
 
605 605
                     foreach ( $check_dup_array as $check_k ) {
606
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
607
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
608
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
606
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
607
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
608
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
609 609
 		                    }
610
-		                    unset($mk, $mv);
610
+		                    unset( $mk, $mv );
611 611
 		                }
612 612
                     }
613 613
     		    }
614 614
 		    }
615 615
 		}
616 616
 
617
-		if ( ! is_array($m['value']) ) {
618
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
617
+		if ( ! is_array( $m['value'] ) ) {
618
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
619 619
 		}
620 620
 
621
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
621
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
622 622
     }
623 623
 
624 624
     /**
@@ -634,23 +634,23 @@  discard block
 block discarded – undo
634 634
             }
635 635
 
636 636
 		    $taxonomy = (string) $att['domain'];
637
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
637
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
638 638
 		        $name = (string) $att['nicename'];
639
-		        $h_term = get_term_by('slug', $name, $taxonomy);
639
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
640 640
 		        if ( $h_term ) {
641 641
 		            $name = $h_term->term_id;
642 642
 		        }
643
-		        unset($h_term);
643
+		        unset( $h_term );
644 644
 		    } else {
645 645
 		        $name = (string) $c;
646 646
 		    }
647 647
 
648
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
649
-				$post['tax_input'][ $taxonomy ] = array();
648
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
649
+				$post['tax_input'][$taxonomy] = array();
650 650
 			}
651 651
 
652
-			$post['tax_input'][ $taxonomy ][] = $name;
653
-		    unset($name);
652
+			$post['tax_input'][$taxonomy][] = $name;
653
+		    unset( $name );
654 654
 		}
655 655
     }
656 656
 
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
 
668 668
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
669 669
 		    $match_by['include'] = $post['post_id'];
670
-		    unset($match_by['name']);
670
+		    unset( $match_by['name'] );
671 671
 		}
672 672
 
673
-		$editing = get_posts($match_by);
673
+		$editing = get_posts( $match_by );
674 674
 
675
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
675
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
676 676
             // set the id of the post to edit
677
-            $post['ID'] = current($editing)->ID;
677
+            $post['ID'] = current( $editing )->ID;
678 678
         }
679 679
     }
680 680
 
681 681
     private static function update_postmeta( &$post, $post_id ) {
682 682
         foreach ( $post['postmeta'] as $k => $v ) {
683 683
             if ( '_edit_last' == $k ) {
684
-                $v = FrmAppHelper::get_user_id_param($v);
684
+                $v = FrmAppHelper::get_user_id_param( $v );
685 685
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
686 686
                 //change the attachment ID
687
-                $v = FrmProXMLHelper::get_file_id($v);
687
+                $v = FrmProXMLHelper::get_file_id( $v );
688 688
             }
689 689
 
690
-            update_post_meta($post_id, $k, $v);
690
+            update_post_meta( $post_id, $k, $v );
691 691
 
692
-            unset($k, $v);
692
+            unset( $k, $v );
693 693
         }
694 694
     }
695 695
 
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
      * @param string $message
707 707
      */
708 708
 	public static function parse_message( $result, &$message, &$errors ) {
709
-        if ( is_wp_error($result) ) {
709
+        if ( is_wp_error( $result ) ) {
710 710
             $errors[] = $result->get_error_message();
711 711
         } else if ( ! $result ) {
712 712
             return;
713 713
         }
714 714
 
715
-        if ( ! is_array($result) ) {
715
+        if ( ! is_array( $result ) ) {
716 716
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
717 717
             return;
718 718
         }
@@ -724,20 +724,20 @@  discard block
 block discarded – undo
724 724
 
725 725
         $message = '<ul>';
726 726
         foreach ( $result as $type => $results ) {
727
-			if ( ! isset( $t_strings[ $type ] ) ) {
727
+			if ( ! isset( $t_strings[$type] ) ) {
728 728
                 // only print imported and updated
729 729
                 continue;
730 730
             }
731 731
 
732 732
             $s_message = array();
733 733
             foreach ( $results as $k => $m ) {
734
-                self::item_count_message($m, $k, $s_message);
735
-                unset($k, $m);
734
+                self::item_count_message( $m, $k, $s_message );
735
+                unset( $k, $m );
736 736
             }
737 737
 
738
-            if ( ! empty($s_message) ) {
739
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
740
-                $message .= implode(', ', $s_message);
738
+            if ( ! empty( $s_message ) ) {
739
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
740
+                $message .= implode( ', ', $s_message );
741 741
                 $message .= '</li>';
742 742
             }
743 743
         }
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
767 767
         );
768 768
 
769
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
769
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
770 770
     }
771 771
 
772 772
 	/**
@@ -798,14 +798,14 @@  discard block
 block discarded – undo
798 798
 	}
799 799
 
800 800
 	public static function cdata( $str ) {
801
-	    $str = maybe_unserialize($str);
802
-	    if ( is_array($str) ) {
803
-	        $str = json_encode($str);
801
+	    $str = maybe_unserialize( $str );
802
+	    if ( is_array( $str ) ) {
803
+	        $str = json_encode( $str );
804 804
 		} else if ( seems_utf8( $str ) == false ) {
805 805
 			$str = utf8_encode( $str );
806 806
 		}
807 807
 
808
-        if ( is_numeric($str) ) {
808
+        if ( is_numeric( $str ) ) {
809 809
             return $str;
810 810
         }
811 811
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
     * @param string $post_type
851 851
     */
852 852
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
853
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
853
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
854 854
             return;
855 855
         }
856 856
 
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
         );
872 872
 
873 873
         foreach ( $post_settings as $post_setting ) {
874
-			if ( isset( $form_options[ $post_setting ] ) ) {
875
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
874
+			if ( isset( $form_options[$post_setting] ) ) {
875
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
876 876
             }
877
-            unset($post_setting);
877
+            unset( $post_setting );
878 878
         }
879 879
 
880 880
 		$new_action['event'] = array( 'create', 'update' );
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 
889 889
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
890 890
         }
891
-        $new_action['post_content'] = json_encode($new_action['post_content']);
891
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
892 892
 
893 893
         $exists = get_posts( array(
894 894
             'name'          => $new_action['post_name'],
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
         if ( ! $exists ) {
901 901
 			// this isn't an email, but we need to use a class that will always be included
902 902
 			FrmAppHelper::save_json_post( $new_action );
903
-            $imported['imported']['actions']++;
903
+            $imported['imported']['actions'] ++;
904 904
         }
905 905
     }
906 906
 
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
         foreach ( $post_content as $key => $setting ) {
933 933
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
934 934
                 // Replace old IDs with new IDs
935
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
935
+				$post_content[$key] = str_replace( $old, $new, $setting );
936 936
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
937 937
                 foreach ( $setting as $k => $val ) {
938 938
                     // Replace old IDs with new IDs
939
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
939
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
940 940
                 }
941 941
             }
942 942
             unset( $key, $setting );
@@ -959,14 +959,14 @@  discard block
 block discarded – undo
959 959
         // Migrate autoresponders
960 960
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
961 961
 
962
-        if (  empty( $notifications ) ) {
962
+        if ( empty( $notifications ) ) {
963 963
             return;
964 964
         }
965 965
 
966 966
         foreach ( $notifications as $new_notification ) {
967 967
             $new_notification['post_type']      = $post_type;
968 968
             $new_notification['post_excerpt']   = 'email';
969
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
969
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
970 970
             $new_notification['menu_order']     = $form_id;
971 971
             $new_notification['post_status']    = 'publish';
972 972
 
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 				// Switch all other field IDs in email
980 980
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
981 981
             }
982
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
982
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
983 983
 
984 984
             $exists = get_posts( array(
985 985
                 'name'          => $new_notification['post_name'],
@@ -988,11 +988,11 @@  discard block
 block discarded – undo
988 988
                 'numberposts'   => 1,
989 989
             ) );
990 990
 
991
-            if ( empty($exists) ) {
991
+            if ( empty( $exists ) ) {
992 992
 				FrmAppHelper::save_json_post( $new_notification );
993
-                $imported['imported']['actions']++;
993
+                $imported['imported']['actions'] ++;
994 994
             }
995
-            unset($new_notification);
995
+            unset( $new_notification );
996 996
         }
997 997
     }
998 998
 
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1006 1006
         }
1007 1007
 
1008
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1008
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1009 1009
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1010 1010
 
1011 1011
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1033,12 +1033,12 @@  discard block
 block discarded – undo
1033 1033
         // Format the reply to email and name
1034 1034
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1035 1035
         foreach ( $reply_fields as $f => $val ) {
1036
-			if ( isset( $notification[ $f ] ) ) {
1037
-				$atts[ $f ] = $notification[ $f ];
1038
-				if ( 'custom' == $notification[ $f ] ) {
1039
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1040
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1041
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1036
+			if ( isset( $notification[$f] ) ) {
1037
+				$atts[$f] = $notification[$f];
1038
+				if ( 'custom' == $notification[$f] ) {
1039
+					$atts[$f] = $notification['cust_' . $f];
1040
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1041
+					$atts[$f] = '[' . $atts[$f] . ']';
1042 1042
                 }
1043 1043
             }
1044 1044
             unset( $f, $val );
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		$atts['event'] = array( 'create' );
1049 1049
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1050 1050
             $atts['event'][] = 'update';
1051
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1051
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1052 1052
 			$atts['event'] = array( 'update' );
1053 1053
         }
1054 1054
     }
@@ -1069,18 +1069,18 @@  discard block
 block discarded – undo
1069 1069
         foreach ( $atts['email_to'] as $key => $email_field ) {
1070 1070
 
1071 1071
             if ( is_numeric( $email_field ) ) {
1072
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1072
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1073 1073
             }
1074 1074
 
1075
-            if ( strpos( $email_field, '|') ) {
1075
+            if ( strpos( $email_field, '|' ) ) {
1076 1076
                 $email_opt = explode( '|', $email_field );
1077 1077
                 if ( isset( $email_opt[0] ) ) {
1078
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1078
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1079 1079
                 }
1080 1080
                 unset( $email_opt );
1081 1081
             }
1082 1082
         }
1083
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1083
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1084 1084
     }
1085 1085
 
1086 1086
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1096,12 +1096,12 @@  discard block
 block discarded – undo
1096 1096
         // Add more fields to the new notification
1097 1097
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1098 1098
         foreach ( $add_fields as $add_field ) {
1099
-			if ( isset( $notification[ $add_field ] ) ) {
1100
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1099
+			if ( isset( $notification[$add_field] ) ) {
1100
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1101 1101
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1102
-				$new_notification['post_content'][ $add_field ] = 0;
1102
+				$new_notification['post_content'][$add_field] = 0;
1103 1103
             } else {
1104
-				$new_notification['post_content'][ $add_field ] = '';
1104
+				$new_notification['post_content'][$add_field] = '';
1105 1105
             }
1106 1106
             unset( $add_field );
1107 1107
         }
@@ -1125,26 +1125,26 @@  discard block
 block discarded – undo
1125 1125
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1126 1126
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1127 1127
 				if ( is_numeric( $email_key ) ) {
1128
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1128
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1129 1129
 				}
1130
-				unset( $email_key, $val);
1130
+				unset( $email_key, $val );
1131 1131
 			}
1132 1132
 		}
1133 1133
 	}
1134 1134
 
1135 1135
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1136
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1136
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1137 1137
             // migrate autoresponder
1138 1138
 
1139
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1140
-            if ( strpos($email_field, '|') ) {
1139
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1140
+            if ( strpos( $email_field, '|' ) ) {
1141 1141
                 // data from entries field
1142
-                $email_field = explode('|', $email_field);
1143
-                if ( isset($email_field[1]) ) {
1142
+                $email_field = explode( '|', $email_field );
1143
+                if ( isset( $email_field[1] ) ) {
1144 1144
                     $email_field = $email_field[1];
1145 1145
                 }
1146 1146
             }
1147
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1147
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1148 1148
 				$email_field = '[' . $email_field . ']';
1149 1149
             }
1150 1150
 
@@ -1152,16 +1152,16 @@  discard block
 block discarded – undo
1152 1152
             $new_notification2 = array(
1153 1153
                 'post_content'  => array(
1154 1154
                     'email_message' => $notification['ar_email_message'],
1155
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1155
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1156 1156
                     'email_to'      => $email_field,
1157
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1157
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1158 1158
                     'inc_user_info' => 0,
1159 1159
                 ),
1160 1160
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1161 1161
             );
1162 1162
 
1163
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1164
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1163
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1164
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1165 1165
 
1166 1166
 			if ( ! empty( $reply_to ) ) {
1167 1167
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +775 added lines, -775 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,145 +207,145 @@  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
-        //replace [error_class]
281
+		//replace [error_class]
282 282
 		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
283 283
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
284 284
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
285 285
 			// there is no error_class shortcode to use for addign fields
286 286
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
287 287
 		}
288
-        $html = str_replace('[error_class]', $error_class, $html);
288
+		$html = str_replace('[error_class]', $error_class, $html);
289 289
 
290
-        //replace [entry_key]
291
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
292
-        $html = str_replace('[entry_key]', $entry_key, $html);
290
+		//replace [entry_key]
291
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
292
+		$html = str_replace('[entry_key]', $entry_key, $html);
293 293
 
294
-        //replace [input]
295
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
296
-        global $frm_vars;
297
-        $frm_settings = FrmAppHelper::get_settings();
294
+		//replace [input]
295
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
296
+		global $frm_vars;
297
+		$frm_settings = FrmAppHelper::get_settings();
298 298
 
299
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
300
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
299
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
300
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
301 301
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
302 302
 
303
-            $replace_with = '';
303
+			$replace_with = '';
304 304
 
305
-            if ( $tag == 'input' ) {
306
-                if ( isset($atts['opt']) ) {
307
-                    $atts['opt']--;
308
-                }
305
+			if ( $tag == 'input' ) {
306
+				if ( isset($atts['opt']) ) {
307
+					$atts['opt']--;
308
+				}
309 309
 
310
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
311
-                if ( isset($atts['class']) ) {
312
-                    unset($atts['class']);
313
-                }
310
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
311
+				if ( isset($atts['class']) ) {
312
+					unset($atts['class']);
313
+				}
314 314
 
315
-                $field['shortcodes'] = $atts;
316
-                ob_start();
315
+				$field['shortcodes'] = $atts;
316
+				ob_start();
317 317
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
318
-                $replace_with = ob_get_contents();
319
-                ob_end_clean();
320
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
321
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
322
-            }
318
+				$replace_with = ob_get_contents();
319
+				ob_end_clean();
320
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
321
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
322
+			}
323 323
 
324
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
325
-        }
324
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
325
+		}
326 326
 
327 327
 		if ( $form ) {
328
-            $form = (array) $form;
328
+			$form = (array) $form;
329 329
 
330
-            //replace [form_key]
331
-            $html = str_replace('[form_key]', $form['form_key'], $html);
330
+			//replace [form_key]
331
+			$html = str_replace('[form_key]', $form['form_key'], $html);
332 332
 
333
-            //replace [form_name]
334
-            $html = str_replace('[form_name]', $form['name'], $html);
335
-        }
336
-        $html .= "\n";
333
+			//replace [form_name]
334
+			$html = str_replace('[form_name]', $form['name'], $html);
335
+		}
336
+		$html .= "\n";
337 337
 
338
-        //Return html if conf_field to prevent loop
339
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
340
-            return $html;
341
-        }
338
+		//Return html if conf_field to prevent loop
339
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
340
+			return $html;
341
+		}
342 342
 
343
-        //If field is in repeating section
344
-        if ( $args['section_id'] ) {
345
-            $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'] ));
346
-        } else {
347
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
348
-        }
343
+		//If field is in repeating section
344
+		if ( $args['section_id'] ) {
345
+			$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'] ));
346
+		} else {
347
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
348
+		}
349 349
 
350 350
 		self::remove_collapse_shortcode( $html );
351 351
 
@@ -353,18 +353,18 @@  discard block
 block discarded – undo
353 353
 			$html = do_shortcode( $html );
354 354
 		}
355 355
 
356
-        return $html;
357
-    }
356
+		return $html;
357
+	}
358 358
 
359 359
 	/**
360
-	* Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
361
-	*
362
-	* @since 2.0
363
-	* @param $error_class string, pass by reference
364
-	* @param $field array
365
-	* @param $field_id int
366
-	* @param $html string
367
-	*/
360
+	 * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
361
+	 *
362
+	 * @since 2.0
363
+	 * @param $error_class string, pass by reference
364
+	 * @param $field array
365
+	 * @param $field_id int
366
+	 * @param $html string
367
+	 */
368 368
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
369 369
 		$error_class .= ' frm_' . $field['label'] . '_container';
370 370
 		if ( $field['id'] != $field_id ) {
@@ -428,46 +428,46 @@  discard block
 block discarded – undo
428 428
 		}
429 429
 	}
430 430
 
431
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
432
-        if ( $no_vars ) {
431
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
432
+		if ( $no_vars ) {
433 433
 			$html = str_replace( '[if ' . $code . ']', '', $html );
434 434
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
435
-        } else {
435
+		} else {
436 436
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
437
-        }
437
+		}
438 438
 
439 439
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
440
-    }
440
+	}
441 441
 
442 442
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
443 443
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
444
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
445
-            $args['conditional_check'] = true;
446
-        }
447
-
448
-        $prefix = '';
449
-        if ( $args['conditional_check'] ) {
450
-            if ( $args['conditional'] ) {
451
-                $prefix = 'if ';
452
-            } else if ( $args['foreach'] ) {
453
-                $prefix = 'foreach ';
454
-            }
455
-        }
456
-
457
-        $with_tags = $args['conditional_check'] ? 3 : 2;
458
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
459
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
460
-            $tag = str_replace(']', '', $tag);
461
-            $tags = explode(' ', $tag);
462
-            if ( is_array($tags) ) {
463
-                $tag = $tags[0];
464
-            }
465
-        } else {
466
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
467
-        }
468
-
469
-        return $tag;
470
-    }
444
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
445
+			$args['conditional_check'] = true;
446
+		}
447
+
448
+		$prefix = '';
449
+		if ( $args['conditional_check'] ) {
450
+			if ( $args['conditional'] ) {
451
+				$prefix = 'if ';
452
+			} else if ( $args['foreach'] ) {
453
+				$prefix = 'foreach ';
454
+			}
455
+		}
456
+
457
+		$with_tags = $args['conditional_check'] ? 3 : 2;
458
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
459
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
460
+			$tag = str_replace(']', '', $tag);
461
+			$tags = explode(' ', $tag);
462
+			if ( is_array($tags) ) {
463
+				$tag = $tags[0];
464
+			}
465
+		} else {
466
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
467
+		}
468
+
469
+		return $tag;
470
+	}
471 471
 
472 472
 	/**
473 473
 	 * Remove [collapse_this] if it's still included after all processing
@@ -492,124 +492,124 @@  discard block
 block discarded – undo
492 492
 			$class_prefix = 'frm-';
493 493
 		}
494 494
 
495
-        if ( $lang != 'en' ) {
495
+		if ( $lang != 'en' ) {
496 496
 			$api_js_url .= '&hl=' . $lang;
497
-        }
497
+		}
498 498
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
499 499
 
500
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
501
-        wp_enqueue_script( 'recaptcha-api' );
500
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
501
+		wp_enqueue_script( 'recaptcha-api' );
502 502
 
503 503
 ?>
504 504
 <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>
505 505
 <?php
506
-    }
506
+	}
507 507
 
508 508
 	public static function show_single_option( $field ) {
509
-        $field_name = $field['name'];
510
-        $html_id = self::get_html_id($field);
511
-        foreach ( $field['options'] as $opt_key => $opt ) {
512
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
509
+		$field_name = $field['name'];
510
+		$html_id = self::get_html_id($field);
511
+		foreach ( $field['options'] as $opt_key => $opt ) {
512
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
514 514
 
515
-            // If this is an "Other" option, get the HTML for it
515
+			// If this is an "Other" option, get the HTML for it
516 516
 			if ( self::is_other_opt( $opt_key ) ) {
517
-                // Get string for Other text field, if needed
517
+				// Get string for Other text field, if needed
518 518
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
519 519
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
520
-            } else {
520
+			} else {
521 521
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
522
-            }
523
-        }
524
-    }
522
+			}
523
+		}
524
+	}
525 525
 
526 526
 	public static function dropdown_categories( $args ) {
527 527
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
528
-        $args = wp_parse_args($args, $defaults);
528
+		$args = wp_parse_args($args, $defaults);
529 529
 
530
-        if ( ! $args['field'] ) {
531
-            return;
532
-        }
530
+		if ( ! $args['field'] ) {
531
+			return;
532
+		}
533 533
 
534
-        if ( ! $args['name'] ) {
534
+		if ( ! $args['name'] ) {
535 535
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
536
-        }
536
+		}
537 537
 
538
-        $id = self::get_html_id($args['field']);
539
-        $class = $args['field']['type'];
538
+		$id = self::get_html_id($args['field']);
539
+		$class = $args['field']['type'];
540 540
 
541
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
542
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
541
+		$exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
542
+		$exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
543 543
 
544
-        if ( is_array($args['field']['value']) ) {
545
-            if ( ! empty($exclude) ) {
546
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
547
-            }
548
-            $selected = reset($args['field']['value']);
549
-        } else {
550
-            $selected = $args['field']['value'];
551
-        }
544
+		if ( is_array($args['field']['value']) ) {
545
+			if ( ! empty($exclude) ) {
546
+				$args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
547
+			}
548
+			$selected = reset($args['field']['value']);
549
+		} else {
550
+			$selected = $args['field']['value'];
551
+		}
552 552
 
553
-        $tax_atts = array(
554
-            'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
555
-            'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
556
-            'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
557
-        );
553
+		$tax_atts = array(
554
+			'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
555
+			'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
556
+			'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
557
+		);
558 558
 
559
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
559
+		$tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
560 560
 
561
-        if ( FrmAppHelper::pro_is_installed() ) {
562
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
563
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
564
-            if ( ! $tax_atts['taxonomy'] ) {
565
-                return;
566
-            }
561
+		if ( FrmAppHelper::pro_is_installed() ) {
562
+			$post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
563
+			$tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
564
+			if ( ! $tax_atts['taxonomy'] ) {
565
+				return;
566
+			}
567 567
 
568
-            // If field type is dropdown (not Dynamic), exclude children when parent is excluded
569
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
570
-                $tax_atts['exclude_tree'] = $exclude;
571
-            }
572
-        }
568
+			// If field type is dropdown (not Dynamic), exclude children when parent is excluded
569
+			if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
570
+				$tax_atts['exclude_tree'] = $exclude;
571
+			}
572
+		}
573 573
 
574
-        $dropdown = wp_dropdown_categories($tax_atts);
574
+		$dropdown = wp_dropdown_categories($tax_atts);
575 575
 
576
-        $add_html = FrmFieldsController::input_html($args['field'], false);
576
+		$add_html = FrmFieldsController::input_html($args['field'], false);
577 577
 
578
-        if ( FrmAppHelper::pro_is_installed() ) {
579
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
580
-        }
578
+		if ( FrmAppHelper::pro_is_installed() ) {
579
+			$add_html .= FrmProFieldsController::input_html($args['field'], false);
580
+		}
581 581
 
582 582
 		$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 );
583 583
 
584
-        if ( is_array($args['field']['value']) ) {
585
-            $skip = true;
586
-            foreach ( $args['field']['value'] as $v ) {
584
+		if ( is_array($args['field']['value']) ) {
585
+			$skip = true;
586
+			foreach ( $args['field']['value'] as $v ) {
587 587
 				if ( $skip ) {
588
-                    $skip = false;
589
-                    continue;
590
-                }
588
+					$skip = false;
589
+					continue;
590
+				}
591 591
 				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
592
-                unset($v);
593
-            }
594
-        }
592
+				unset($v);
593
+			}
594
+		}
595 595
 
596
-        return $dropdown;
597
-    }
596
+		return $dropdown;
597
+	}
598 598
 
599 599
 	public static function get_term_link( $tax_id ) {
600
-        $tax = get_taxonomy($tax_id);
601
-        if ( ! $tax ) {
602
-            return;
603
-        }
600
+		$tax = get_taxonomy($tax_id);
601
+		if ( ! $tax ) {
602
+			return;
603
+		}
604 604
 
605
-        $link = sprintf(
606
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
605
+		$link = sprintf(
606
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
607 607
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
608
-        );
609
-        unset($tax);
608
+		);
609
+		unset($tax);
610 610
 
611
-        return $link;
612
-    }
611
+		return $link;
612
+	}
613 613
 
614 614
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
615 615
 		// Remove white space from hide_opt
@@ -617,195 +617,195 @@  discard block
 block discarded – undo
617 617
 			$hide_opt = rtrim( $hide_opt );
618 618
 		}
619 619
 
620
-        if ( is_array($observed_value) ) {
621
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
622
-        }
623
-
624
-        $m = false;
625
-        if ( $cond == '==' ) {
626
-            $m = $observed_value == $hide_opt;
627
-        } else if ( $cond == '!=' ) {
628
-            $m = $observed_value != $hide_opt;
629
-        } else if ( $cond == '>' ) {
630
-            $m = $observed_value > $hide_opt;
631
-        } else if ( $cond == '<' ) {
632
-            $m = $observed_value < $hide_opt;
633
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
634
-            $m = stripos($observed_value, $hide_opt);
635
-            if ( $cond == 'not LIKE' ) {
636
-                $m = ( $m === false ) ? true : false;
637
-            } else {
638
-                $m = ( $m === false ) ? false : true;
639
-            }
640
-        }
641
-        return $m;
642
-    }
620
+		if ( is_array($observed_value) ) {
621
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
622
+		}
623
+
624
+		$m = false;
625
+		if ( $cond == '==' ) {
626
+			$m = $observed_value == $hide_opt;
627
+		} else if ( $cond == '!=' ) {
628
+			$m = $observed_value != $hide_opt;
629
+		} else if ( $cond == '>' ) {
630
+			$m = $observed_value > $hide_opt;
631
+		} else if ( $cond == '<' ) {
632
+			$m = $observed_value < $hide_opt;
633
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
634
+			$m = stripos($observed_value, $hide_opt);
635
+			if ( $cond == 'not LIKE' ) {
636
+				$m = ( $m === false ) ? true : false;
637
+			} else {
638
+				$m = ( $m === false ) ? false : true;
639
+			}
640
+		}
641
+		return $m;
642
+	}
643 643
 
644 644
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
645
-        $m = false;
646
-        if ( $cond == '==' ) {
647
-            if ( is_array($hide_opt) ) {
648
-                $m = array_intersect($hide_opt, $observed_value);
649
-                $m = empty($m) ? false : true;
650
-            } else {
651
-                $m = in_array($hide_opt, $observed_value);
652
-            }
653
-        } else if ( $cond == '!=' ) {
654
-            $m = ! in_array($hide_opt, $observed_value);
655
-        } else if ( $cond == '>' ) {
656
-            $min = min($observed_value);
657
-            $m = $min > $hide_opt;
658
-        } else if ( $cond == '<' ) {
659
-            $max = max($observed_value);
660
-            $m = $max < $hide_opt;
661
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
662
-            foreach ( $observed_value as $ob ) {
663
-                $m = strpos($ob, $hide_opt);
664
-                if ( $m !== false ) {
665
-                    $m = true;
666
-                    break;
667
-                }
668
-            }
669
-
670
-            if ( $cond == 'not LIKE' ) {
671
-                $m = ( $m === false ) ? true : false;
672
-            }
673
-        }
674
-
675
-        return $m;
676
-    }
677
-
678
-    /**
679
-     * Replace a few basic shortcodes and field ids
680
-     * @since 2.0
681
-     * @return string
682
-     */
645
+		$m = false;
646
+		if ( $cond == '==' ) {
647
+			if ( is_array($hide_opt) ) {
648
+				$m = array_intersect($hide_opt, $observed_value);
649
+				$m = empty($m) ? false : true;
650
+			} else {
651
+				$m = in_array($hide_opt, $observed_value);
652
+			}
653
+		} else if ( $cond == '!=' ) {
654
+			$m = ! in_array($hide_opt, $observed_value);
655
+		} else if ( $cond == '>' ) {
656
+			$min = min($observed_value);
657
+			$m = $min > $hide_opt;
658
+		} else if ( $cond == '<' ) {
659
+			$max = max($observed_value);
660
+			$m = $max < $hide_opt;
661
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
662
+			foreach ( $observed_value as $ob ) {
663
+				$m = strpos($ob, $hide_opt);
664
+				if ( $m !== false ) {
665
+					$m = true;
666
+					break;
667
+				}
668
+			}
669
+
670
+			if ( $cond == 'not LIKE' ) {
671
+				$m = ( $m === false ) ? true : false;
672
+			}
673
+		}
674
+
675
+		return $m;
676
+	}
677
+
678
+	/**
679
+	 * Replace a few basic shortcodes and field ids
680
+	 * @since 2.0
681
+	 * @return string
682
+	 */
683 683
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
684
-        if ( strpos($value, '[sitename]') !== false ) {
685
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
686
-            $value = str_replace('[sitename]', $new_value, $value);
687
-        }
684
+		if ( strpos($value, '[sitename]') !== false ) {
685
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
686
+			$value = str_replace('[sitename]', $new_value, $value);
687
+		}
688 688
 
689
-        $value = apply_filters('frm_content', $value, $form, $entry);
690
-        $value = do_shortcode($value);
689
+		$value = apply_filters('frm_content', $value, $form, $entry);
690
+		$value = do_shortcode($value);
691 691
 
692
-        return $value;
693
-    }
692
+		return $value;
693
+	}
694 694
 
695 695
 	public static function get_shortcodes( $content, $form_id ) {
696
-        if ( FrmAppHelper::pro_is_installed() ) {
697
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
698
-        }
696
+		if ( FrmAppHelper::pro_is_installed() ) {
697
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
698
+		}
699 699
 
700
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
700
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
701 701
 
702
-        $tagregexp = self::allowed_shortcodes($fields);
702
+		$tagregexp = self::allowed_shortcodes($fields);
703 703
 
704
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
704
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
705 705
 
706
-        return $matches;
707
-    }
706
+		return $matches;
707
+	}
708 708
 
709 709
 	public static function allowed_shortcodes( $fields = array() ) {
710
-        $tagregexp = array(
711
-            'editlink', 'id', 'key', 'ip',
712
-            'siteurl', 'sitename', 'admin_email',
713
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
710
+		$tagregexp = array(
711
+			'editlink', 'id', 'key', 'ip',
712
+			'siteurl', 'sitename', 'admin_email',
713
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
714 714
 			'parent[-|_]id',
715
-        );
715
+		);
716 716
 
717
-        foreach ( $fields as $field ) {
718
-            $tagregexp[] = $field->id;
719
-            $tagregexp[] = $field->field_key;
720
-        }
717
+		foreach ( $fields as $field ) {
718
+			$tagregexp[] = $field->id;
719
+			$tagregexp[] = $field->field_key;
720
+		}
721 721
 
722
-        $tagregexp = implode('|', $tagregexp);
723
-        return $tagregexp;
724
-    }
722
+		$tagregexp = implode('|', $tagregexp);
723
+		return $tagregexp;
724
+	}
725 725
 
726 726
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
727
-        $shortcode_values = array(
728
-           'id'     => $entry->id,
729
-           'key'    => $entry->item_key,
730
-           'ip'     => $entry->ip,
731
-        );
727
+		$shortcode_values = array(
728
+		   'id'     => $entry->id,
729
+		   'key'    => $entry->item_key,
730
+		   'ip'     => $entry->ip,
731
+		);
732 732
 
733
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
734
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
733
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
734
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
735 735
 
736
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
736
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
737 737
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
738
-                $tags = explode(' ', $tag);
739
-                if ( is_array($tags) ) {
740
-                    $tag = $tags[0];
741
-                }
742
-            } else {
743
-                $tag = $shortcodes[2][ $short_key ];
744
-            }
745
-
746
-            switch ( $tag ) {
747
-                case 'id':
748
-                case 'key':
749
-                case 'ip':
750
-                    $replace_with = $shortcode_values[ $tag ];
751
-                break;
752
-
753
-                case 'user_agent':
754
-                case 'user-agent':
755
-                    $entry->description = maybe_unserialize($entry->description);
738
+				$tags = explode(' ', $tag);
739
+				if ( is_array($tags) ) {
740
+					$tag = $tags[0];
741
+				}
742
+			} else {
743
+				$tag = $shortcodes[2][ $short_key ];
744
+			}
745
+
746
+			switch ( $tag ) {
747
+				case 'id':
748
+				case 'key':
749
+				case 'ip':
750
+					$replace_with = $shortcode_values[ $tag ];
751
+				break;
752
+
753
+				case 'user_agent':
754
+				case 'user-agent':
755
+					$entry->description = maybe_unserialize($entry->description);
756 756
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
757
-                break;
758
-
759
-                case 'created_at':
760
-                case 'created-at':
761
-                case 'updated_at':
762
-                case 'updated-at':
763
-                    if ( isset($atts['format']) ) {
764
-                        $time_format = ' ';
765
-                    } else {
766
-                        $atts['format'] = get_option('date_format');
767
-                        $time_format = '';
768
-                    }
769
-
770
-                    $this_tag = str_replace('-', '_', $tag);
771
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
772
-                    unset($this_tag);
773
-                break;
774
-
775
-                case 'created_by':
776
-                case 'created-by':
777
-                case 'updated_by':
778
-                case 'updated-by':
779
-                    $this_tag = str_replace('-', '_', $tag);
757
+				break;
758
+
759
+				case 'created_at':
760
+				case 'created-at':
761
+				case 'updated_at':
762
+				case 'updated-at':
763
+					if ( isset($atts['format']) ) {
764
+						$time_format = ' ';
765
+					} else {
766
+						$atts['format'] = get_option('date_format');
767
+						$time_format = '';
768
+					}
769
+
770
+					$this_tag = str_replace('-', '_', $tag);
771
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
772
+					unset($this_tag);
773
+				break;
774
+
775
+				case 'created_by':
776
+				case 'created-by':
777
+				case 'updated_by':
778
+				case 'updated-by':
779
+					$this_tag = str_replace('-', '_', $tag);
780 780
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
781
-                    unset($this_tag);
782
-                break;
783
-
784
-                case 'admin_email':
785
-                case 'siteurl':
786
-                case 'frmurl':
787
-                case 'sitename':
788
-                case 'get':
789
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
790
-                break;
791
-
792
-                default:
793
-                    $field = FrmField::getOne( $tag );
794
-                    if ( ! $field ) {
795
-                        break;
796
-                    }
797
-
798
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
799
-
800
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
801
-
802
-                    $atts['entry_id'] = $entry->id;
803
-                    $atts['entry_key'] = $entry->item_key;
804
-
805
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
806
-                        $replace_with = $field->name;
807
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
808
-                        $replace_with = $field->description;
781
+					unset($this_tag);
782
+				break;
783
+
784
+				case 'admin_email':
785
+				case 'siteurl':
786
+				case 'frmurl':
787
+				case 'sitename':
788
+				case 'get':
789
+					$replace_with = self::dynamic_default_values( $tag, $atts );
790
+				break;
791
+
792
+				default:
793
+					$field = FrmField::getOne( $tag );
794
+					if ( ! $field ) {
795
+						break;
796
+					}
797
+
798
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
799
+
800
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
801
+
802
+					$atts['entry_id'] = $entry->id;
803
+					$atts['entry_key'] = $entry->item_key;
804
+
805
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
806
+						$replace_with = $field->name;
807
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
808
+						$replace_with = $field->description;
809 809
 					} else {
810 810
 						$string_value = $replace_with;
811 811
 						if ( is_array( $replace_with ) ) {
@@ -819,82 +819,82 @@  discard block
 block discarded – undo
819 819
 						}
820 820
 					}
821 821
 
822
-                    unset($field);
823
-                break;
824
-            }
822
+					unset($field);
823
+				break;
824
+			}
825 825
 
826
-            if ( isset($replace_with) ) {
827
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
828
-            }
826
+			if ( isset($replace_with) ) {
827
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
828
+			}
829 829
 
830
-            unset($atts, $conditional, $replace_with);
830
+			unset($atts, $conditional, $replace_with);
831 831
 		}
832 832
 
833 833
 		return $content;
834
-    }
835
-
836
-    /**
837
-     * Get the value to replace a few standard shortcodes
838
-     *
839
-     * @since 2.0
840
-     * @return string
841
-     */
842
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
843
-        $new_value = '';
844
-        switch ( $tag ) {
845
-            case 'admin_email':
846
-                $new_value = get_option('admin_email');
847
-                break;
848
-            case 'siteurl':
849
-                $new_value = FrmAppHelper::site_url();
850
-                break;
851
-            case 'frmurl':
852
-                $new_value = FrmAppHelper::plugin_url();
853
-                break;
854
-            case 'sitename':
855
-                $new_value = FrmAppHelper::site_name();
856
-                break;
857
-            case 'get':
858
-                $new_value = self::process_get_shortcode( $atts, $return_array );
859
-                break;
860
-        }
861
-
862
-        return $new_value;
863
-    }
864
-
865
-    /**
866
-     * Process the [get] shortcode
867
-     *
868
-     * @since 2.0
869
-     * @return string|array
870
-     */
871
-    public static function process_get_shortcode( $atts, $return_array = false ) {
872
-        if ( ! isset($atts['param']) ) {
873
-            return '';
874
-        }
875
-
876
-        if ( strpos($atts['param'], '&#91;') ) {
877
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
878
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
879
-        }
880
-
881
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
882
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
883
-
884
-        if ( $new_value == '' ) {
885
-            if ( ! isset($atts['prev_val']) ) {
886
-                $atts['prev_val'] = '';
887
-            }
888
-
889
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
890
-        }
891
-
892
-        if ( is_array($new_value) && ! $return_array ) {
893
-            $new_value = implode(', ', $new_value);
894
-        }
895
-
896
-        return $new_value;
897
-    }
834
+	}
835
+
836
+	/**
837
+	 * Get the value to replace a few standard shortcodes
838
+	 *
839
+	 * @since 2.0
840
+	 * @return string
841
+	 */
842
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
843
+		$new_value = '';
844
+		switch ( $tag ) {
845
+			case 'admin_email':
846
+				$new_value = get_option('admin_email');
847
+				break;
848
+			case 'siteurl':
849
+				$new_value = FrmAppHelper::site_url();
850
+				break;
851
+			case 'frmurl':
852
+				$new_value = FrmAppHelper::plugin_url();
853
+				break;
854
+			case 'sitename':
855
+				$new_value = FrmAppHelper::site_name();
856
+				break;
857
+			case 'get':
858
+				$new_value = self::process_get_shortcode( $atts, $return_array );
859
+				break;
860
+		}
861
+
862
+		return $new_value;
863
+	}
864
+
865
+	/**
866
+	 * Process the [get] shortcode
867
+	 *
868
+	 * @since 2.0
869
+	 * @return string|array
870
+	 */
871
+	public static function process_get_shortcode( $atts, $return_array = false ) {
872
+		if ( ! isset($atts['param']) ) {
873
+			return '';
874
+		}
875
+
876
+		if ( strpos($atts['param'], '&#91;') ) {
877
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
878
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
879
+		}
880
+
881
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
882
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
883
+
884
+		if ( $new_value == '' ) {
885
+			if ( ! isset($atts['prev_val']) ) {
886
+				$atts['prev_val'] = '';
887
+			}
888
+
889
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
890
+		}
891
+
892
+		if ( is_array($new_value) && ! $return_array ) {
893
+			$new_value = implode(', ', $new_value);
894
+		}
895
+
896
+		return $new_value;
897
+	}
898 898
 
899 899
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
900 900
 		$atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
903 903
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
904 904
 
905
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
906
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
907
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
908
-                if ( is_array($replace_with) ) {
909
-                    $replace_with = implode("\n", $replace_with);
910
-                }
911
-                $replace_with = wpautop($replace_with);
912
-            }
905
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
906
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
907
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
908
+				if ( is_array($replace_with) ) {
909
+					$replace_with = implode("\n", $replace_with);
910
+				}
911
+				$replace_with = wpautop($replace_with);
912
+			}
913 913
 			unset( $autop );
914 914
 		} else if ( is_array( $replace_with ) ) {
915 915
 			$replace_with = implode( $atts['sep'], $replace_with );
@@ -919,58 +919,58 @@  discard block
 block discarded – undo
919 919
 	}
920 920
 
921 921
 	public static function get_field_types( $type ) {
922
-        $single_input = array(
923
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
924
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
925
-            'user_id', 'tag', 'password',
926
-        );
922
+		$single_input = array(
923
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
924
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
925
+			'user_id', 'tag', 'password',
926
+		);
927 927
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
928 928
 		$other_type = array( 'divider', 'html', 'break' );
929 929
 
930 930
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
931 931
 
932
-        $field_types = array();
933
-        if ( in_array($type, $single_input) ) {
934
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
935
-        } else if ( in_array($type, $multiple_input) ) {
936
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
937
-        } else if ( in_array($type, $other_type) ) {
938
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
932
+		$field_types = array();
933
+		if ( in_array($type, $single_input) ) {
934
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
935
+		} else if ( in_array($type, $multiple_input) ) {
936
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
937
+		} else if ( in_array($type, $other_type) ) {
938
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
939 939
 		} else if ( isset( $field_selection[ $type ] ) ) {
940
-            $field_types[ $type ] = $field_selection[ $type ];
941
-        }
940
+			$field_types[ $type ] = $field_selection[ $type ];
941
+		}
942 942
 
943 943
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
944
-        return $field_types;
945
-    }
946
-
947
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
948
-        foreach ( $inputs as $input ) {
949
-            $field_types[ $input ] = $fields[ $input ];
950
-            unset($input);
951
-        }
952
-    }
953
-
954
-    /**
955
-    * Check if current field option is an "other" option
956
-    *
957
-    * @since 2.0.6
958
-    *
959
-    * @param string $opt_key
960
-    * @return boolean Returns true if current field option is an "Other" option
961
-    */
962
-    public static function is_other_opt( $opt_key ) {
963
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
964
-    }
965
-
966
-    /**
967
-    * Get value that belongs in "Other" text box
968
-    *
969
-    * @since 2.0.6
970
-    *
971
-    * @param array $args
972
-    */
973
-    public static function get_other_val( $args ) {
944
+		return $field_types;
945
+	}
946
+
947
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
948
+		foreach ( $inputs as $input ) {
949
+			$field_types[ $input ] = $fields[ $input ];
950
+			unset($input);
951
+		}
952
+	}
953
+
954
+	/**
955
+	 * Check if current field option is an "other" option
956
+	 *
957
+	 * @since 2.0.6
958
+	 *
959
+	 * @param string $opt_key
960
+	 * @return boolean Returns true if current field option is an "Other" option
961
+	 */
962
+	public static function is_other_opt( $opt_key ) {
963
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
964
+	}
965
+
966
+	/**
967
+	 * Get value that belongs in "Other" text box
968
+	 *
969
+	 * @since 2.0.6
970
+	 *
971
+	 * @param array $args
972
+	 */
973
+	public static function get_other_val( $args ) {
974 974
 		$defaults = array(
975 975
 			'opt_key' => 0, 'field' => array(),
976 976
 			'parent' => false, 'pointer' => false,
@@ -1046,20 +1046,20 @@  discard block
 block discarded – undo
1046 1046
 		}
1047 1047
 
1048 1048
 		return $other_val;
1049
-    }
1050
-
1051
-    /**
1052
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1053
-    * Intended for front-end use
1054
-    *
1055
-    * @since 2.0.6
1056
-    *
1057
-    * @param array $args should include field, opt_key and field name
1058
-    * @param boolean $other_opt
1059
-    * @param string $checked
1060
-    * @return string $other_val
1061
-    */
1062
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1049
+	}
1050
+
1051
+	/**
1052
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1053
+	 * Intended for front-end use
1054
+	 *
1055
+	 * @since 2.0.6
1056
+	 *
1057
+	 * @param array $args should include field, opt_key and field name
1058
+	 * @param boolean $other_opt
1059
+	 * @param string $checked
1060
+	 * @return string $other_val
1061
+	 */
1062
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1063 1063
 		//Check if this is an "Other" option
1064 1064
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1065 1065
 			return;
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
 			$checked = 'checked="checked" ';
1076 1076
 		}
1077 1077
 
1078
-        return $other_args;
1079
-    }
1078
+		return $other_args;
1079
+	}
1080 1080
 
1081 1081
 	/**
1082 1082
 	 * @param array $args
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @since 2.0.6
1126 1126
 	 */
1127 1127
 	public static function include_other_input( $args ) {
1128
-        if ( ! $args['other_opt'] ) {
1129
-        	return;
1128
+		if ( ! $args['other_opt'] ) {
1129
+			return;
1130 1130
 		}
1131 1131
 
1132 1132
 		$classes = array( 'frm_other_input' );
@@ -1147,15 +1147,15 @@  discard block
 block discarded – undo
1147 1147
 	}
1148 1148
 
1149 1149
 	/**
1150
-	* Get the HTML id for an "Other" text field
1151
-	* Note: This does not affect fields in repeating sections
1152
-	*
1153
-	* @since 2.0.08
1154
-	* @param string $type - field type
1155
-	* @param string $html_id
1156
-	* @param string|boolean $opt_key
1157
-	* @return string $other_id
1158
-	*/
1150
+	 * Get the HTML id for an "Other" text field
1151
+	 * Note: This does not affect fields in repeating sections
1152
+	 *
1153
+	 * @since 2.0.08
1154
+	 * @param string $type - field type
1155
+	 * @param string $html_id
1156
+	 * @param string|boolean $opt_key
1157
+	 * @return string $other_id
1158
+	 */
1159 1159
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1160 1160
 		$other_id = $html_id;
1161 1161
 
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
 	}
1214 1214
 
1215 1215
 	public static function switch_field_ids( $val ) {
1216
-        global $frm_duplicate_ids;
1217
-        $replace = array();
1218
-        $replace_with = array();
1219
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1216
+		global $frm_duplicate_ids;
1217
+		$replace = array();
1218
+		$replace_with = array();
1219
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1220 1220
 			$replace[] = '[if ' . $old . ']';
1221 1221
 			$replace_with[] = '[if ' . $new . ']';
1222 1222
 			$replace[] = '[if ' . $old . ' ';
@@ -1231,153 +1231,153 @@  discard block
 block discarded – undo
1231 1231
 			$replace_with[] = '[' . $new . ']';
1232 1232
 			$replace[] = '[' . $old . ' ';
1233 1233
 			$replace_with[] = '[' . $new . ' ';
1234
-            unset($old, $new);
1235
-        }
1234
+			unset($old, $new);
1235
+		}
1236 1236
 		if ( is_array( $val ) ) {
1237 1237
 			foreach ( $val as $k => $v ) {
1238
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1239
-                unset($k, $v);
1240
-            }
1241
-        } else {
1242
-            $val = str_replace($replace, $replace_with, $val);
1243
-        }
1244
-
1245
-        return $val;
1246
-    }
1247
-
1248
-    public static function get_us_states() {
1249
-        return apply_filters( 'frm_us_states', array(
1250
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1251
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1252
-            'DC' => 'District of Columbia',
1253
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1254
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1255
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1256
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1257
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1258
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1259
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1260
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1261
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1262
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1263
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1264
-        ) );
1265
-    }
1266
-
1267
-    public static function get_countries() {
1268
-        return apply_filters( 'frm_countries', array(
1269
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1270
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1271
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1272
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1273
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1274
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1275
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1276
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1277
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1278
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1279
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1280
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1281
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1282
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1283
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1284
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1285
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1286
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1287
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1288
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1289
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1290
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1291
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1292
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1293
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1294
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1295
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1296
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1297
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1298
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1299
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1300
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1301
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1302
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1303
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1304
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1305
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1306
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1307
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1308
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1309
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1310
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1311
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1312
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1313
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1314
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1315
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1316
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1317
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1318
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1319
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1320
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1321
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1322
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1323
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1324
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1325
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1326
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1327
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1328
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1329
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1330
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1331
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1332
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1333
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1334
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1335
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1336
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1337
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1338
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1339
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1340
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1341
-            __( 'Zimbabwe', 'formidable' ),
1342
-        ) );
1343
-    }
1238
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1239
+				unset($k, $v);
1240
+			}
1241
+		} else {
1242
+			$val = str_replace($replace, $replace_with, $val);
1243
+		}
1244
+
1245
+		return $val;
1246
+	}
1247
+
1248
+	public static function get_us_states() {
1249
+		return apply_filters( 'frm_us_states', array(
1250
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1251
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1252
+			'DC' => 'District of Columbia',
1253
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1254
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1255
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1256
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1257
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1258
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1259
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1260
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1261
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1262
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1263
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1264
+		) );
1265
+	}
1266
+
1267
+	public static function get_countries() {
1268
+		return apply_filters( 'frm_countries', array(
1269
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1270
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1271
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1272
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1273
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1274
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1275
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1276
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1277
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1278
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1279
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1280
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1281
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1282
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1283
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1284
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1285
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1286
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1287
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1288
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1289
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1290
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1291
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1292
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1293
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1294
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1295
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1296
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1297
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1298
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1299
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1300
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1301
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1302
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1303
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1304
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1305
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1306
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1307
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1308
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1309
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1310
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1311
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1312
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1313
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1314
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1315
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1316
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1317
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1318
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1319
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1320
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1321
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1322
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1323
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1324
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1325
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1326
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1327
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1328
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1329
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1330
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1331
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1332
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1333
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1334
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1335
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1336
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1337
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1338
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1339
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1340
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1341
+			__( 'Zimbabwe', 'formidable' ),
1342
+		) );
1343
+	}
1344 1344
 
1345 1345
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1346 1346
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1347 1347
 
1348
-        $states = FrmFieldsHelper::get_us_states();
1349
-        $state_abv = array_keys($states);
1350
-        sort($state_abv);
1348
+		$states = FrmFieldsHelper::get_us_states();
1349
+		$state_abv = array_keys($states);
1350
+		sort($state_abv);
1351 1351
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1352 1352
 
1353
-        $states = array_values($states);
1354
-        sort($states);
1353
+		$states = array_values($states);
1354
+		sort($states);
1355 1355
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1356
-        unset($state_abv, $states);
1356
+		unset($state_abv, $states);
1357 1357
 
1358 1358
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1359
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1360
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1361
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1362
-        );
1359
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1360
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1361
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1362
+		);
1363 1363
 
1364 1364
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1365
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1366
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1367
-        );
1365
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1366
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1367
+		);
1368 1368
 
1369 1369
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1370
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1371
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1372
-        );
1370
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1371
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1372
+		);
1373 1373
 
1374 1374
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1375
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1376
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1377
-        );
1375
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1376
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1377
+		);
1378 1378
 
1379 1379
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1380
-    }
1380
+	}
1381 1381
 
1382 1382
 	public static function field_selection() {
1383 1383
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 		return FrmField::is_required( $field );
1415 1415
 	}
1416 1416
 
1417
-    public static function maybe_get_field( &$field ) {
1417
+	public static function maybe_get_field( &$field ) {
1418 1418
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1419 1419
 		FrmField::maybe_get_field( $field );
1420
-    }
1420
+	}
1421 1421
 }
Please login to merge, or discard this patch.
Spacing   +183 added lines, -183 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,48 +268,48 @@  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
         //replace [error_class]
282
-		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
282
+		$error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
283 283
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
284 284
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
285 285
 			// there is no error_class shortcode to use for addign fields
286 286
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
287 287
 		}
288
-        $html = str_replace('[error_class]', $error_class, $html);
288
+        $html = str_replace( '[error_class]', $error_class, $html );
289 289
 
290 290
         //replace [entry_key]
291 291
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
292
-        $html = str_replace('[entry_key]', $entry_key, $html);
292
+        $html = str_replace( '[entry_key]', $entry_key, $html );
293 293
 
294 294
         //replace [input]
295
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
295
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
296 296
         global $frm_vars;
297 297
         $frm_settings = FrmAppHelper::get_settings();
298 298
 
299 299
         foreach ( $shortcodes[0] as $short_key => $tag ) {
300
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
300
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
301 301
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
302 302
 
303 303
             $replace_with = '';
304 304
 
305 305
             if ( $tag == 'input' ) {
306
-                if ( isset($atts['opt']) ) {
307
-                    $atts['opt']--;
306
+                if ( isset( $atts['opt'] ) ) {
307
+                    $atts['opt'] --;
308 308
                 }
309 309
 
310
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
311
-                if ( isset($atts['class']) ) {
312
-                    unset($atts['class']);
310
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
311
+                if ( isset( $atts['class'] ) ) {
312
+                    unset( $atts['class'] );
313 313
                 }
314 314
 
315 315
                 $field['shortcodes'] = $atts;
@@ -318,33 +318,33 @@  discard block
 block discarded – undo
318 318
                 $replace_with = ob_get_contents();
319 319
                 ob_end_clean();
320 320
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
321
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
321
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
322 322
             }
323 323
 
324
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
324
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
325 325
         }
326 326
 
327 327
 		if ( $form ) {
328 328
             $form = (array) $form;
329 329
 
330 330
             //replace [form_key]
331
-            $html = str_replace('[form_key]', $form['form_key'], $html);
331
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
332 332
 
333 333
             //replace [form_name]
334
-            $html = str_replace('[form_name]', $form['name'], $html);
334
+            $html = str_replace( '[form_name]', $form['name'], $html );
335 335
         }
336 336
         $html .= "\n";
337 337
 
338 338
         //Return html if conf_field to prevent loop
339
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
339
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
340 340
             return $html;
341 341
         }
342 342
 
343 343
         //If field is in repeating section
344 344
         if ( $args['section_id'] ) {
345
-            $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'] ));
345
+            $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'] ) );
346 346
         } else {
347
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
347
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
348 348
         }
349 349
 
350 350
 		self::remove_collapse_shortcode( $html );
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 
422 422
 		//insert custom CSS classes
423 423
 		if ( ! empty( $field['classes'] ) ) {
424
-			if ( ! strpos( $html, 'frm_form_field ') ) {
424
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
425 425
 				$error_class .= ' frm_form_field';
426 426
 			}
427 427
 			$error_class .= ' ' . $field['classes'];
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
         }
456 456
 
457 457
         $with_tags = $args['conditional_check'] ? 3 : 2;
458
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
459
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
460
-            $tag = str_replace(']', '', $tag);
461
-            $tags = explode(' ', $tag);
462
-            if ( is_array($tags) ) {
458
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
459
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
460
+            $tag = str_replace( ']', '', $tag );
461
+            $tags = explode( ' ', $tag );
462
+            if ( is_array( $tags ) ) {
463 463
                 $tag = $tags[0];
464 464
             }
465 465
         } else {
466
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
466
+            $tag = $shortcodes[$with_tags - 1][$short_key];
467 467
         }
468 468
 
469 469
         return $tag;
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 
508 508
 	public static function show_single_option( $field ) {
509 509
         $field_name = $field['name'];
510
-        $html_id = self::get_html_id($field);
510
+        $html_id = self::get_html_id( $field );
511 511
         foreach ( $field['options'] as $opt_key => $opt ) {
512
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
513
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
512
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
513
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
514 514
 
515 515
             // If this is an "Other" option, get the HTML for it
516 516
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
 	public static function dropdown_categories( $args ) {
527 527
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
528
-        $args = wp_parse_args($args, $defaults);
528
+        $args = wp_parse_args( $args, $defaults );
529 529
 
530 530
         if ( ! $args['field'] ) {
531 531
             return;
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
 			$args['name'] = 'item_meta[' . $args['field']['id'] . ']';
536 536
         }
537 537
 
538
-        $id = self::get_html_id($args['field']);
538
+        $id = self::get_html_id( $args['field'] );
539 539
         $class = $args['field']['type'];
540 540
 
541
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
542
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
541
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
542
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
543 543
 
544
-        if ( is_array($args['field']['value']) ) {
545
-            if ( ! empty($exclude) ) {
546
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
544
+        if ( is_array( $args['field']['value'] ) ) {
545
+            if ( ! empty( $exclude ) ) {
546
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
547 547
             }
548
-            $selected = reset($args['field']['value']);
548
+            $selected = reset( $args['field']['value'] );
549 549
         } else {
550 550
             $selected = $args['field']['value'];
551 551
         }
@@ -556,40 +556,40 @@  discard block
 block discarded – undo
556 556
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
557 557
         );
558 558
 
559
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
559
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
560 560
 
561 561
         if ( FrmAppHelper::pro_is_installed() ) {
562
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
563
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
562
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
563
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
564 564
             if ( ! $tax_atts['taxonomy'] ) {
565 565
                 return;
566 566
             }
567 567
 
568 568
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
569
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
569
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
570 570
                 $tax_atts['exclude_tree'] = $exclude;
571 571
             }
572 572
         }
573 573
 
574
-        $dropdown = wp_dropdown_categories($tax_atts);
574
+        $dropdown = wp_dropdown_categories( $tax_atts );
575 575
 
576
-        $add_html = FrmFieldsController::input_html($args['field'], false);
576
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
577 577
 
578 578
         if ( FrmAppHelper::pro_is_installed() ) {
579
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
579
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
580 580
         }
581 581
 
582 582
 		$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 );
583 583
 
584
-        if ( is_array($args['field']['value']) ) {
584
+        if ( is_array( $args['field']['value'] ) ) {
585 585
             $skip = true;
586 586
             foreach ( $args['field']['value'] as $v ) {
587 587
 				if ( $skip ) {
588 588
                     $skip = false;
589 589
                     continue;
590 590
                 }
591
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
592
-                unset($v);
591
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
592
+                unset( $v );
593 593
             }
594 594
         }
595 595
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
     }
598 598
 
599 599
 	public static function get_term_link( $tax_id ) {
600
-        $tax = get_taxonomy($tax_id);
600
+        $tax = get_taxonomy( $tax_id );
601 601
         if ( ! $tax ) {
602 602
             return;
603 603
         }
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
607 607
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
608 608
         );
609
-        unset($tax);
609
+        unset( $tax );
610 610
 
611 611
         return $link;
612 612
     }
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 			$hide_opt = rtrim( $hide_opt );
618 618
 		}
619 619
 
620
-        if ( is_array($observed_value) ) {
621
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
620
+        if ( is_array( $observed_value ) ) {
621
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
622 622
         }
623 623
 
624 624
         $m = false;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
         } else if ( $cond == '<' ) {
632 632
             $m = $observed_value < $hide_opt;
633 633
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
634
-            $m = stripos($observed_value, $hide_opt);
634
+            $m = stripos( $observed_value, $hide_opt );
635 635
             if ( $cond == 'not LIKE' ) {
636 636
                 $m = ( $m === false ) ? true : false;
637 637
             } else {
@@ -644,23 +644,23 @@  discard block
 block discarded – undo
644 644
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
645 645
         $m = false;
646 646
         if ( $cond == '==' ) {
647
-            if ( is_array($hide_opt) ) {
648
-                $m = array_intersect($hide_opt, $observed_value);
649
-                $m = empty($m) ? false : true;
647
+            if ( is_array( $hide_opt ) ) {
648
+                $m = array_intersect( $hide_opt, $observed_value );
649
+                $m = empty( $m ) ? false : true;
650 650
             } else {
651
-                $m = in_array($hide_opt, $observed_value);
651
+                $m = in_array( $hide_opt, $observed_value );
652 652
             }
653 653
         } else if ( $cond == '!=' ) {
654
-            $m = ! in_array($hide_opt, $observed_value);
654
+            $m = ! in_array( $hide_opt, $observed_value );
655 655
         } else if ( $cond == '>' ) {
656
-            $min = min($observed_value);
656
+            $min = min( $observed_value );
657 657
             $m = $min > $hide_opt;
658 658
         } else if ( $cond == '<' ) {
659
-            $max = max($observed_value);
659
+            $max = max( $observed_value );
660 660
             $m = $max < $hide_opt;
661 661
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
662 662
             foreach ( $observed_value as $ob ) {
663
-                $m = strpos($ob, $hide_opt);
663
+                $m = strpos( $ob, $hide_opt );
664 664
                 if ( $m !== false ) {
665 665
                     $m = true;
666 666
                     break;
@@ -681,27 +681,27 @@  discard block
 block discarded – undo
681 681
      * @return string
682 682
      */
683 683
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
684
-        if ( strpos($value, '[sitename]') !== false ) {
684
+        if ( strpos( $value, '[sitename]' ) !== false ) {
685 685
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
686
-            $value = str_replace('[sitename]', $new_value, $value);
686
+            $value = str_replace( '[sitename]', $new_value, $value );
687 687
         }
688 688
 
689
-        $value = apply_filters('frm_content', $value, $form, $entry);
690
-        $value = do_shortcode($value);
689
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
690
+        $value = do_shortcode( $value );
691 691
 
692 692
         return $value;
693 693
     }
694 694
 
695 695
 	public static function get_shortcodes( $content, $form_id ) {
696 696
         if ( FrmAppHelper::pro_is_installed() ) {
697
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
697
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
698 698
         }
699 699
 
700 700
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
701 701
 
702
-        $tagregexp = self::allowed_shortcodes($fields);
702
+        $tagregexp = self::allowed_shortcodes( $fields );
703 703
 
704
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
704
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
705 705
 
706 706
         return $matches;
707 707
     }
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             $tagregexp[] = $field->field_key;
720 720
         }
721 721
 
722
-        $tagregexp = implode('|', $tagregexp);
722
+        $tagregexp = implode( '|', $tagregexp );
723 723
         return $tagregexp;
724 724
     }
725 725
 
@@ -731,28 +731,28 @@  discard block
 block discarded – undo
731 731
         );
732 732
 
733 733
         foreach ( $shortcodes[0] as $short_key => $tag ) {
734
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
734
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
735 735
 
736
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
737
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
738
-                $tags = explode(' ', $tag);
739
-                if ( is_array($tags) ) {
736
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
737
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
738
+                $tags = explode( ' ', $tag );
739
+                if ( is_array( $tags ) ) {
740 740
                     $tag = $tags[0];
741 741
                 }
742 742
             } else {
743
-                $tag = $shortcodes[2][ $short_key ];
743
+                $tag = $shortcodes[2][$short_key];
744 744
             }
745 745
 
746 746
             switch ( $tag ) {
747 747
                 case 'id':
748 748
                 case 'key':
749 749
                 case 'ip':
750
-                    $replace_with = $shortcode_values[ $tag ];
750
+                    $replace_with = $shortcode_values[$tag];
751 751
                 break;
752 752
 
753 753
                 case 'user_agent':
754 754
                 case 'user-agent':
755
-                    $entry->description = maybe_unserialize($entry->description);
755
+                    $entry->description = maybe_unserialize( $entry->description );
756 756
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
757 757
                 break;
758 758
 
@@ -760,25 +760,25 @@  discard block
 block discarded – undo
760 760
                 case 'created-at':
761 761
                 case 'updated_at':
762 762
                 case 'updated-at':
763
-                    if ( isset($atts['format']) ) {
763
+                    if ( isset( $atts['format'] ) ) {
764 764
                         $time_format = ' ';
765 765
                     } else {
766
-                        $atts['format'] = get_option('date_format');
766
+                        $atts['format'] = get_option( 'date_format' );
767 767
                         $time_format = '';
768 768
                     }
769 769
 
770
-                    $this_tag = str_replace('-', '_', $tag);
771
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
772
-                    unset($this_tag);
770
+                    $this_tag = str_replace( '-', '_', $tag );
771
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
772
+                    unset( $this_tag );
773 773
                 break;
774 774
 
775 775
                 case 'created_by':
776 776
                 case 'created-by':
777 777
                 case 'updated_by':
778 778
                 case 'updated-by':
779
-                    $this_tag = str_replace('-', '_', $tag);
779
+                    $this_tag = str_replace( '-', '_', $tag );
780 780
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
781
-                    unset($this_tag);
781
+                    unset( $this_tag );
782 782
                 break;
783 783
 
784 784
                 case 'admin_email':
@@ -795,16 +795,16 @@  discard block
 block discarded – undo
795 795
                         break;
796 796
                     }
797 797
 
798
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
798
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
799 799
 
800 800
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
801 801
 
802 802
                     $atts['entry_id'] = $entry->id;
803 803
                     $atts['entry_key'] = $entry->item_key;
804 804
 
805
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
805
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
806 806
                         $replace_with = $field->name;
807
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
807
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
808 808
                         $replace_with = $field->description;
809 809
 					} else {
810 810
 						$string_value = $replace_with;
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 						}
820 820
 					}
821 821
 
822
-                    unset($field);
822
+                    unset( $field );
823 823
                 break;
824 824
             }
825 825
 
826
-            if ( isset($replace_with) ) {
827
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
826
+            if ( isset( $replace_with ) ) {
827
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
828 828
             }
829 829
 
830
-            unset($atts, $conditional, $replace_with);
830
+            unset( $atts, $conditional, $replace_with );
831 831
 		}
832 832
 
833 833
 		return $content;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
         $new_value = '';
844 844
         switch ( $tag ) {
845 845
             case 'admin_email':
846
-                $new_value = get_option('admin_email');
846
+                $new_value = get_option( 'admin_email' );
847 847
                 break;
848 848
             case 'siteurl':
849 849
                 $new_value = FrmAppHelper::site_url();
@@ -869,28 +869,28 @@  discard block
 block discarded – undo
869 869
      * @return string|array
870 870
      */
871 871
     public static function process_get_shortcode( $atts, $return_array = false ) {
872
-        if ( ! isset($atts['param']) ) {
872
+        if ( ! isset( $atts['param'] ) ) {
873 873
             return '';
874 874
         }
875 875
 
876
-        if ( strpos($atts['param'], '&#91;') ) {
877
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
878
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
876
+        if ( strpos( $atts['param'], '&#91;' ) ) {
877
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
878
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
879 879
         }
880 880
 
881
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
881
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
882 882
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
883 883
 
884 884
         if ( $new_value == '' ) {
885
-            if ( ! isset($atts['prev_val']) ) {
885
+            if ( ! isset( $atts['prev_val'] ) ) {
886 886
                 $atts['prev_val'] = '';
887 887
             }
888 888
 
889
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
889
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
890 890
         }
891 891
 
892
-        if ( is_array($new_value) && ! $return_array ) {
893
-            $new_value = implode(', ', $new_value);
892
+        if ( is_array( $new_value ) && ! $return_array ) {
893
+            $new_value = implode( ', ', $new_value );
894 894
         }
895 895
 
896 896
         return $new_value;
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
904 904
 
905 905
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
906
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
907
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
908
-                if ( is_array($replace_with) ) {
909
-                    $replace_with = implode("\n", $replace_with);
906
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
907
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
908
+                if ( is_array( $replace_with ) ) {
909
+                    $replace_with = implode( "\n", $replace_with );
910 910
                 }
911
-                $replace_with = wpautop($replace_with);
911
+                $replace_with = wpautop( $replace_with );
912 912
             }
913 913
 			unset( $autop );
914 914
 		} else if ( is_array( $replace_with ) ) {
@@ -930,14 +930,14 @@  discard block
 block discarded – undo
930 930
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
931 931
 
932 932
         $field_types = array();
933
-        if ( in_array($type, $single_input) ) {
933
+        if ( in_array( $type, $single_input ) ) {
934 934
             self::field_types_for_input( $single_input, $field_selection, $field_types );
935
-        } else if ( in_array($type, $multiple_input) ) {
935
+        } else if ( in_array( $type, $multiple_input ) ) {
936 936
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
937
-        } else if ( in_array($type, $other_type) ) {
937
+        } else if ( in_array( $type, $other_type ) ) {
938 938
             self::field_types_for_input( $other_type, $field_selection, $field_types );
939
-		} else if ( isset( $field_selection[ $type ] ) ) {
940
-            $field_types[ $type ] = $field_selection[ $type ];
939
+		} else if ( isset( $field_selection[$type] ) ) {
940
+            $field_types[$type] = $field_selection[$type];
941 941
         }
942 942
 
943 943
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 
947 947
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
948 948
         foreach ( $inputs as $input ) {
949
-            $field_types[ $input ] = $fields[ $input ];
950
-            unset($input);
949
+            $field_types[$input] = $fields[$input];
950
+            unset( $input );
951 951
         }
952 952
     }
953 953
 
@@ -992,21 +992,21 @@  discard block
 block discarded – undo
992 992
 		// Check posted vals before checking saved values
993 993
 
994 994
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
995
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
995
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
996 996
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
997
-				$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 ] ) : '';
997
+				$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] ) : '';
998 998
 			} else {
999
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
999
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
1000 1000
 			}
1001 1001
 			return $other_val;
1002 1002
 
1003
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
1003
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
1004 1004
 			// For normal fields
1005 1005
 
1006 1006
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
1007
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
1007
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
1008 1008
 			} else {
1009
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
1009
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
1010 1010
 			}
1011 1011
 			return $other_val;
1012 1012
 		}
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1016 1016
 			// Check if there is an "other" val in saved value and make sure the
1017 1017
 			// "other" val is not equal to the Other checkbox option
1018
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1019
-				$other_val = $field['value'][ $opt_key ];
1018
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1019
+				$other_val = $field['value'][$opt_key];
1020 1020
 			}
1021 1021
 		} else {
1022 1022
 			/**
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
 				// Multi-select dropdowns - key is not preserved
1029 1029
 				if ( is_array( $field['value'] ) ) {
1030 1030
 					$o_key = array_search( $temp_val, $field['value'] );
1031
-					if ( isset( $field['value'][ $o_key ] ) ) {
1032
-						unset( $field['value'][ $o_key ], $o_key );
1031
+					if ( isset( $field['value'][$o_key] ) ) {
1032
+						unset( $field['value'][$o_key], $o_key );
1033 1033
 					}
1034 1034
 				} else if ( $temp_val == $field['value'] ) {
1035 1035
 					// For radio and regular dropdowns
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 	private static function set_other_name( $args, &$other_args ) {
1087 1087
 		//Set up name for other field
1088 1088
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1089
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1089
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1090 1090
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1091 1091
 
1092 1092
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		// Count should only be greater than 3 if inside of a repeating section
1113 1113
 		if ( count( $temp_array ) > 3 ) {
1114 1114
 			$parent = str_replace( ']', '', $temp_array[1] );
1115
-			$pointer = str_replace( ']', '', $temp_array[2]);
1115
+			$pointer = str_replace( ']', '', $temp_array[2] );
1116 1116
 		}
1117 1117
 
1118 1118
 		// Get text for "other" text field
@@ -1231,15 +1231,15 @@  discard block
 block discarded – undo
1231 1231
 			$replace_with[] = '[' . $new . ']';
1232 1232
 			$replace[] = '[' . $old . ' ';
1233 1233
 			$replace_with[] = '[' . $new . ' ';
1234
-            unset($old, $new);
1234
+            unset( $old, $new );
1235 1235
         }
1236 1236
 		if ( is_array( $val ) ) {
1237 1237
 			foreach ( $val as $k => $v ) {
1238
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1239
-                unset($k, $v);
1238
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1239
+                unset( $k, $v );
1240 1240
             }
1241 1241
         } else {
1242
-            $val = str_replace($replace, $replace_with, $val);
1242
+            $val = str_replace( $replace, $replace_with, $val );
1243 1243
         }
1244 1244
 
1245 1245
         return $val;
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
             'DC' => 'District of Columbia',
1253 1253
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1254 1254
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1255
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1255
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1256 1256
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1257 1257
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1258 1258
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1343,35 +1343,35 @@  discard block
 block discarded – undo
1343 1343
     }
1344 1344
 
1345 1345
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1346
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1346
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1347 1347
 
1348 1348
         $states = FrmFieldsHelper::get_us_states();
1349
-        $state_abv = array_keys($states);
1350
-        sort($state_abv);
1351
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1349
+        $state_abv = array_keys( $states );
1350
+        sort( $state_abv );
1351
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1352 1352
 
1353
-        $states = array_values($states);
1354
-        sort($states);
1355
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1356
-        unset($state_abv, $states);
1353
+        $states = array_values( $states );
1354
+        sort( $states );
1355
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1356
+        unset( $state_abv, $states );
1357 1357
 
1358
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1358
+		$prepop[__( 'Age', 'formidable' )] = array(
1359 1359
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1360 1360
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1361 1361
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1362 1362
         );
1363 1363
 
1364
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1364
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1365 1365
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1366 1366
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1367 1367
         );
1368 1368
 
1369
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1369
+		$prepop[__( 'Importance', 'formidable' )] = array(
1370 1370
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1371 1371
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1372 1372
         );
1373 1373
 
1374
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1374
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1375 1375
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1376 1376
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1377 1377
         );
Please login to merge, or discard this patch.
classes/views/frm-forms/add_field.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $display = apply_filters('frm_display_field_options', array(
4
-    'type' => $field['type'], 'field_data' => $field,
5
-    'required' => true, 'unique' => false, 'read_only' => false,
6
-    'description' => true, 'options' => true, 'label_position' => true,
7
-    'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8
-    'default_blank' => true, 'css' => true, 'conf_field' => false,
4
+	'type' => $field['type'], 'field_data' => $field,
5
+	'required' => true, 'unique' => false, 'read_only' => false,
6
+	'description' => true, 'options' => true, 'label_position' => true,
7
+	'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8
+	'default_blank' => true, 'css' => true, 'conf_field' => false,
9 9
 	'max' => true, 'captcha_size' => false,
10 10
 ));
11 11
 
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 $frm_settings = FrmAppHelper::get_settings();
26 26
 
27 27
 if ( ! isset( $frm_all_field_selection ) ) {
28
-    if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
-        $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
30
-    } else {
28
+	if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
+		$frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
30
+	} else {
31 31
 		$pro_field_selection = FrmField::pro_field_selection();
32 32
 		$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
33
-    }
33
+	}
34 34
 }
35 35
 
36 36
 $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
37 37
 
38 38
 
39 39
 if ( ! isset( $ajax ) ) {
40
-    $li_classes .= ' ui-state-default widgets-holder-wrap'; ?>
40
+	$li_classes .= ' ui-state-default widgets-holder-wrap'; ?>
41 41
 <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?>" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo ( 'divider' == $field['type'] ) ? esc_attr( $field['form_select'] ) : esc_attr( $field['form_id'] ); ?>">
42 42
 <?php
43 43
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     </span>
60 60
     <?php }
61 61
 
62
-    ?>
62
+	?>
63 63
     <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
64 64
 
65 65
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
106 106
     <div class="frm-show-click frm_small_top_margin"><?php
107 107
 
108
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
108
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
109 109
 		echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
110 110
 	} else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
111 111
 ?>
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 				<a href="javascript:void(0);" id="other_button_<?php echo esc_attr( $field['id'] ); ?>" data-opttype="other" data-ftype="<?php echo esc_attr( $field['type'] ) ?>" class="button frm_cb_button frm_add_opt<?php echo ( in_array( $field['type'], array( 'radio', 'select' ) ) && $field['other'] == true ? ' frm_hidden' : '' ); ?>"><?php _e( 'Add "Other"', 'formidable' ) ?></a>
118 118
                 <input type="hidden" value="<?php echo esc_attr( $field['other'] ); ?>" id="other_input_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[other_<?php echo esc_attr( $field['id'] ); ?>]">
119 119
             <?php
120
-            }
120
+			}
121 121
 
122
-            if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
122
+			if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
123 123
 			<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '&quot;', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange">
124 124
 				<?php _e( 'Bulk Edit Options', 'formidable' ) ?>
125 125
 			</a>
126 126
             <?php } ?>
127 127
         </div>
128 128
 <?php
129
-    }
129
+	}
130 130
 ?>
131 131
     </div>
132 132
 <?php
@@ -158,28 +158,28 @@  discard block
 block discarded – undo
158 158
 				if ( $display['required'] ) { ?>
159 159
                     <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label>
160 160
                 <?php
161
-                }
161
+				}
162 162
 
163 163
 				if ( $display['unique'] ) {
164
-                    if ( ! isset( $field['unique'] ) ) {
165
-                        $field['unique'] = false;
166
-                    }
167
-                ?>
164
+					if ( ! isset( $field['unique'] ) ) {
165
+						$field['unique'] = false;
166
+					}
167
+				?>
168 168
                 <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ) ?>"><input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ) ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" /> <?php _e( 'Unique', 'formidable' ) ?></label>
169 169
                 <?php
170
-                }
170
+				}
171 171
 
172 172
 				if ( $display['read_only'] ) {
173
-                    if ( ! isset( $field['read_only'] ) ) {
174
-                        $field['read_only'] = false;
173
+					if ( ! isset( $field['read_only'] ) ) {
174
+						$field['read_only'] = false;
175 175
 					}
176
-                ?>
176
+				?>
177 177
                 <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label>
178 178
                 <?php }
179 179
 
180
-                do_action('frm_field_options_form_top', $field, $display, $values);
180
+				do_action('frm_field_options_form_top', $field, $display, $values);
181 181
 
182
-                ?>
182
+				?>
183 183
                 <?php
184 184
 				if ( $display['required'] ) { ?>
185 185
                 <div class="frm_required_details<?php echo esc_attr( $field['id'] . ( $field['required'] ? '' : ' frm_hidden' ) ); ?>">
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				do_action( 'frm_' . $field['type'] . '_field_options_form', $field, $display, $values );
266 266
 				do_action( 'frm_field_options_form', $field, $display, $values );
267 267
 
268
-                if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
268
+				if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
269 269
 					<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
270 270
 					<td colspan="2">
271 271
                     <div class="menu-settings">
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                             <input type="text" name="field_options[blank_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['blank'] ); ?>" />
279 279
                         </p>
280 280
                         <?php
281
-                        }
281
+						}
282 282
 
283 283
 						if ( $display['invalid'] ) { ?>
284 284
                             <p><label><?php _e( 'Invalid Format', 'formidable' ) ?></label>
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                             <input type="text" name="field_options[unique_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['unique_msg'] ); ?>" />
294 294
                         </p>
295 295
                         <?php
296
-                        }
296
+						}
297 297
 
298 298
 						if ( $display['conf_field'] ) { ?>
299 299
                         <p class="frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                             <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" />
302 302
                         </p>
303 303
                         <?php
304
-                        } ?>
304
+						} ?>
305 305
                     </div>
306 306
                     </div>
307 307
                     </td>
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$display = apply_filters('frm_display_field_options', array(
3
+$display = apply_filters( 'frm_display_field_options', array(
4 4
     'type' => $field['type'], 'field_data' => $field,
5 5
     'required' => true, 'unique' => false, 'read_only' => false,
6 6
     'description' => true, 'options' => true, 'label_position' => true,
7 7
     'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8 8
     'default_blank' => true, 'css' => true, 'conf_field' => false,
9 9
 	'max' => true, 'captcha_size' => false,
10
-));
10
+) );
11 11
 
12 12
 $li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type'];
13
-$li_classes = apply_filters('frm_build_field_class', $li_classes, $field );
13
+$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
14 14
 
15 15
 if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) {
16 16
 ?>
17 17
 <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>">
18 18
 <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" />
19
-<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span>
19
+<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span>
20 20
 </li>
21 21
 <?php
22 22
    return;
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 $frm_settings = FrmAppHelper::get_settings();
26 26
 
27 27
 if ( ! isset( $frm_all_field_selection ) ) {
28
-    if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
-        $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
28
+    if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) {
29
+        $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection );
30 30
     } else {
31 31
 		$pro_field_selection = FrmField::pro_field_selection();
32 32
 		$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a>
52 52
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a>
53 53
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a>
54
-    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" />
55
-    <?php do_action('frm_extra_field_actions', $field['id']); ?>
54
+    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" />
55
+    <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?>
56 56
     <?php if ( $display['required'] ) { ?>
57 57
     <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>">
58 58
 		<a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     <?php }
61 61
 
62 62
     ?>
63
-    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
63
+    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
64 64
 
65 65
 
66 66
 <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container">
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 </div>
79 79
 <?php
80 80
 if ( $display['description'] ) { ?>
81
-    <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
81
+    <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
82 82
     <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" />
83 83
 
84 84
 <?php } ?>
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_container" class="frm_conf_field_container frm_form_fields frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>">
89 89
     <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_conf_container">
90 90
 		<div class="frm_form_fields">
91
-			<input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action('frm_field_input_html', $field) ?> />
91
+			<input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action( 'frm_field_input_html', $field ) ?> />
92 92
 		</div>
93
-    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php
94
-			echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div>
93
+    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php
94
+			echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div>
95 95
     	<input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" />
96 96
 </div>
97 97
 	<?php if ( $display['clear_on_focus'] ) { ?>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
107 107
     <div class="frm-show-click frm_small_top_margin"><?php
108 108
 
109
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
109
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
110 110
 		echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
111 111
 	} else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
112 112
 ?>
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             <?php
121 121
             }
122 122
 
123
-            if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
123
+            if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?>
124 124
 			<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '&quot;', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange">
125 125
 				<?php _e( 'Bulk Edit Options', 'formidable' ) ?>
126 126
 			</a>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 <?php
134 134
 }
135 135
 
136
-do_action('frm_before_field_options', $field);
136
+do_action( 'frm_before_field_options', $field );
137 137
 
138 138
 if ( $display['options'] ) { ?>
139 139
     <div class="widget">
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
         </div>
144 144
     	<div class="widget-inside">
145 145
             <table class="form-table frm_clear_none">
146
-                <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?>
146
+                <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?>
147 147
 				<tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td>
148 148
                     <td>
149
-                <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
149
+                <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
150 150
                     <?php
151 151
 					foreach ( $field_types as $fkey => $ftype ) { ?>
152
-                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : '';  ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option>
152
+                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option>
153 153
                     <?php
154 154
 						unset( $fkey, $ftype );
155 155
 					} ?>
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
                 <?php
159 159
 				if ( $display['required'] ) { ?>
160
-                    <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label>
160
+                    <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"' : ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label>
161 161
                 <?php
162 162
                 }
163 163
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                 <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label>
179 179
                 <?php }
180 180
 
181
-                do_action('frm_field_options_form_top', $field, $display, $values);
181
+                do_action( 'frm_field_options_form_top', $field, $display, $values );
182 182
 
183 183
                 ?>
184 184
                 <?php
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
 				if ( $display['label_position'] ) { ?>
216 216
                     <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td>
217 217
                         <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]">
218
-                            <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option>
219
-                            <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option>
220
-                            <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option>
221
-                            <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option>
222
-                            <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
223
-                            <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option>
224
-                            <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
218
+                            <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
219
+                            <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option>
220
+                            <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option>
221
+                            <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option>
222
+                            <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
223
+                            <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option>
224
+                            <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
225 225
                         </select>
226 226
                         </td>
227 227
                     </tr>
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 					<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span>
245 245
                     </td>
246 246
                     <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]">
247
-                        <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option>
248
-                        <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
247
+                        <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
248
+                        <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
249 249
                     </select>
250 250
                     </td>
251 251
                 </tr>
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 				do_action( 'frm_field_options_form', $field, $display, $values );
268 268
 
269 269
                 if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
270
-					<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
270
+					<tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
271 271
 					<td colspan="2">
272 272
                     <div class="menu-settings">
273 273
                     <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3>
@@ -331,4 +331,4 @@  discard block
 block discarded – undo
331 331
 <?php
332 332
 }
333 333
 
334
-unset($display);
334
+unset( $display );
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        global $wpdb;
4
+	public static function validate( $values, $exclude = false ) {
5
+		global $wpdb;
6 6
 
7
-        FrmEntry::sanitize_entry_post( $values );
8
-        $errors = array();
7
+		FrmEntry::sanitize_entry_post( $values );
8
+		$errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
-            return $errors;
13
-        }
10
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
+			return $errors;
13
+		}
14 14
 
15 15
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
16
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
-        }
16
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
+		}
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+		if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21
-        }
21
+		}
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+		$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,42 +28,42 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+		$posted_fields = FrmField::getAll($where, 'field_order');
32 32
 
33
-        // Pass exclude value to validate_field function so it can be used for repeating sections
34
-        $args = array( 'exclude' => $exclude );
33
+		// Pass exclude value to validate_field function so it can be used for repeating sections
34
+		$args = array( 'exclude' => $exclude );
35 35
 
36
-        foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
39
-        }
36
+		foreach ( $posted_fields as $posted_field ) {
37
+			self::validate_field($posted_field, $errors, $values, $args);
38
+			unset($posted_field);
39
+		}
40 40
 
41
-        // check for spam
42
-        self::spam_check( $exclude, $values, $errors );
41
+		// check for spam
42
+		self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+		$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
45 45
 
46
-        return $errors;
47
-    }
46
+		return $errors;
47
+	}
48 48
 
49
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
-        $defaults = array(
51
-            'id'              => $posted_field->id,
52
-            'parent_field_id' => '', // the id of the repeat or embed form
53
-            'key_pointer'     => '', // the pointer in the posted array
54
-            'exclude'         => array(), // exclude these field types from validation
55
-        );
56
-        $args = wp_parse_args( $args, $defaults );
49
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
+		$defaults = array(
51
+			'id'              => $posted_field->id,
52
+			'parent_field_id' => '', // the id of the repeat or embed form
53
+			'key_pointer'     => '', // the pointer in the posted array
54
+			'exclude'         => array(), // exclude these field types from validation
55
+		);
56
+		$args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
58
+		if ( empty($args['parent_field_id']) ) {
59 59
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
60
-        } else {
61
-            // value is from a nested form
62
-            $value = $values;
63
-        }
60
+		} else {
61
+			// value is from a nested form
62
+			$value = $values;
63
+		}
64 64
 
65
-        // Check for values in "Other" fields
66
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
65
+		// Check for values in "Other" fields
66
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 			$value = reset($value);
74 74
 		}
75 75
 
76
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
77 77
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
78
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
79
-            $_POST['item_name'] = $value;
80
-        }
78
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
79
+			$_POST['item_name'] = $value;
80
+		}
81 81
 
82 82
 		if ( $value != '' ) {
83 83
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
87 87
 		}
88 88
 
89
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
89
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
90 90
 
91
-        self::validate_recaptcha($errors, $posted_field, $args);
91
+		self::validate_recaptcha($errors, $posted_field, $args);
92 92
 
93
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
93
+		$errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
94 94
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
95
-    }
95
+	}
96 96
 
97 97
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
98 98
 		if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) {
@@ -102,32 +102,32 @@  discard block
 block discarded – undo
102 102
 
103 103
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
104 104
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
105
-            return;
106
-        }
105
+			return;
106
+		}
107 107
 
108
-        if ( trim($value) == 'http://' ) {
109
-            $value = '';
110
-        } else {
111
-            $value = esc_url_raw( $value );
108
+		if ( trim($value) == 'http://' ) {
109
+			$value = '';
110
+		} else {
111
+			$value = esc_url_raw( $value );
112 112
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
113
-        }
113
+		}
114 114
 
115
-        //validate the url format
116
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
115
+		//validate the url format
116
+		if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
117 117
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121 121
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
122
-        if ( $value == '' || $field->type != 'email' ) {
123
-            return;
124
-        }
122
+		if ( $value == '' || $field->type != 'email' ) {
123
+			return;
124
+		}
125 125
 
126
-        //validate the email format
127
-        if ( ! is_email($value) ) {
126
+		//validate the email format
127
+		if ( ! is_email($value) ) {
128 128
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
129
-        }
130
-    }
129
+		}
130
+	}
131 131
 
132 132
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
133 133
 		//validate the number format
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	public static function validate_recaptcha( &$errors, $field, $args ) {
207
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
208
-            return;
209
-        }
207
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
208
+			return;
209
+		}
210 210
 
211 211
 		$frm_settings = FrmAppHelper::get_settings();
212 212
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -214,57 +214,57 @@  discard block
 block discarded – undo
214 214
 			return;
215 215
 		}
216 216
 
217
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
218
-            // If captcha is missing, check if it was already verified
217
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
218
+			// If captcha is missing, check if it was already verified
219 219
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
220
-                // There was no captcha submitted
220
+				// There was no captcha submitted
221 221
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
222
-            }
223
-            return;
224
-        }
222
+			}
223
+			return;
224
+		}
225 225
 
226
-        $arg_array = array(
227
-            'body'      => array(
226
+		$arg_array = array(
227
+			'body'      => array(
228 228
 				'secret'   => $frm_settings->privkey,
229 229
 				'response' => $_POST['g-recaptcha-response'],
230 230
 				'remoteip' => FrmAppHelper::get_ip_address(),
231 231
 			),
232 232
 		);
233
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
234
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
233
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
234
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
235 235
 
236
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
237
-            // What happens when the CAPTCHA was entered incorrectly
236
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
237
+			// What happens when the CAPTCHA was entered incorrectly
238 238
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
239
-        } else if ( is_wp_error( $resp ) ) {
239
+		} else if ( is_wp_error( $resp ) ) {
240 240
 			$error_string = $resp->get_error_message();
241 241
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
242 242
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
243
-        }
244
-    }
245
-
246
-    /**
247
-     * check for spam
248
-     * @param boolean $exclude
249
-     * @param array $values
250
-     * @param array $errors by reference
251
-     */
252
-    public static function spam_check( $exclude, $values, &$errors ) {
253
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
254
-            // only check spam if there are no other errors
255
-            return;
256
-        }
257
-
258
-        if ( self::is_akismet_spam( $values ) ) {
243
+		}
244
+	}
245
+
246
+	/**
247
+	 * check for spam
248
+	 * @param boolean $exclude
249
+	 * @param array $values
250
+	 * @param array $errors by reference
251
+	 */
252
+	public static function spam_check( $exclude, $values, &$errors ) {
253
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
254
+			// only check spam if there are no other errors
255
+			return;
256
+		}
257
+
258
+		if ( self::is_akismet_spam( $values ) ) {
259 259
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
260 260
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
261 261
 			}
262
-	    }
262
+		}
263 263
 
264
-    	if ( self::blacklist_check( $values ) ) {
265
-            $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
266
-    	}
267
-    }
264
+		if ( self::blacklist_check( $values ) ) {
265
+			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
266
+		}
267
+	}
268 268
 
269 269
 	private static function is_akismet_spam( $values ) {
270 270
 		global $wpcom_api_key;
@@ -276,54 +276,54 @@  discard block
 block discarded – undo
276 276
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
277 277
 	}
278 278
 
279
-    public static function blacklist_check( $values ) {
280
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
281
-            return false;
282
-        }
279
+	public static function blacklist_check( $values ) {
280
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
281
+			return false;
282
+		}
283 283
 
284
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
284
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
285 285
 
286
-    	if ( empty( $mod_keys ) ) {
287
-    		return false;
288
-    	}
286
+		if ( empty( $mod_keys ) ) {
287
+			return false;
288
+		}
289 289
 
290
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
290
+		$content = FrmEntriesHelper::entry_array_to_string($values);
291 291
 
292 292
 		if ( empty($content) ) {
293
-		    return false;
293
+			return false;
294 294
 		}
295 295
 
296
-    	$words = explode( "\n", $mod_keys );
296
+		$words = explode( "\n", $mod_keys );
297 297
 
298
-    	foreach ( (array) $words as $word ) {
299
-    		$word = trim( $word );
298
+		foreach ( (array) $words as $word ) {
299
+			$word = trim( $word );
300 300
 
301
-    		if ( empty($word) ) {
302
-    			continue;
303
-    		}
301
+			if ( empty($word) ) {
302
+				continue;
303
+			}
304 304
 
305
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
306
-    			return true;
307
-    		}
308
-    	}
305
+			if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
306
+				return true;
307
+			}
308
+		}
309 309
 
310
-    	return false;
311
-    }
310
+		return false;
311
+	}
312 312
 
313
-    /**
314
-     * Check entries for spam
315
-     *
316
-     * @return boolean true if is spam
317
-     */
318
-    public static function akismet( $values ) {
319
-	    $content = FrmEntriesHelper::entry_array_to_string( $values );
313
+	/**
314
+	 * Check entries for spam
315
+	 *
316
+	 * @return boolean true if is spam
317
+	 */
318
+	public static function akismet( $values ) {
319
+		$content = FrmEntriesHelper::entry_array_to_string( $values );
320 320
 
321 321
 		if ( empty( $content ) ) {
322
-		    return false;
322
+			return false;
323 323
 		}
324 324
 
325
-        $datas = array();
326
-        self::parse_akismet_array( $datas, $content );
325
+		$datas = array();
326
+		self::parse_akismet_array( $datas, $content );
327 327
 
328 328
 		$query_string = '';
329 329
 		foreach ( $datas as $key => $data ) {
@@ -331,35 +331,35 @@  discard block
 block discarded – undo
331 331
 			unset( $key, $data );
332 332
 		}
333 333
 
334
-        $response = Akismet::http_post($query_string, 'comment-check');
334
+		$response = Akismet::http_post($query_string, 'comment-check');
335 335
 
336 336
 		return ( is_array( $response ) && $response[1] == 'true' );
337
-    }
338
-
339
-    /**
340
-     * @since 2.0
341
-     * @param string $content
342
-     */
343
-    private  static function parse_akismet_array( &$datas, $content ) {
344
-        $datas['blog'] = FrmAppHelper::site_url();
345
-        $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
337
+	}
338
+
339
+	/**
340
+	 * @since 2.0
341
+	 * @param string $content
342
+	 */
343
+	private  static function parse_akismet_array( &$datas, $content ) {
344
+		$datas['blog'] = FrmAppHelper::site_url();
345
+		$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
346 346
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
347 347
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
348
-        $datas['comment_type'] = 'formidable';
349
-        $datas['comment_content'] = $content;
348
+		$datas['comment_type'] = 'formidable';
349
+		$datas['comment_content'] = $content;
350 350
 
351
-        if ( $permalink = get_permalink() ) {
352
-            $datas['permalink'] = $permalink;
353
-        }
351
+		if ( $permalink = get_permalink() ) {
352
+			$datas['permalink'] = $permalink;
353
+		}
354 354
 
355
-        foreach ( $_SERVER as $key => $value ) {
355
+		foreach ( $_SERVER as $key => $value ) {
356 356
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
357 357
 				$datas[ $key ] = wp_strip_all_tags( $value );
358
-            } else {
358
+			} else {
359 359
 				$datas[ $key ] = '';
360
-            }
360
+			}
361 361
 
362
-            unset($key, $value);
363
-        }
364
-    }
362
+			unset($key, $value);
363
+		}
364
+	}
365 365
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
         FrmEntry::sanitize_entry_post( $values );
8 8
         $errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
10
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
11 11
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12 12
             return $errors;
13 13
         }
14 14
 
15
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
15
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
16 16
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17 17
         }
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+        if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21 21
         }
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+        $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+        $posted_fields = FrmField::getAll( $where, 'field_order' );
32 32
 
33 33
         // Pass exclude value to validate_field function so it can be used for repeating sections
34 34
         $args = array( 'exclude' => $exclude );
35 35
 
36 36
         foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
37
+            self::validate_field( $posted_field, $errors, $values, $args );
38
+            unset( $posted_field );
39 39
         }
40 40
 
41 41
         // check for spam
42 42
         self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
45 45
 
46 46
         return $errors;
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         );
56 56
         $args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
59
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
58
+        if ( empty( $args['parent_field_id'] ) ) {
59
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
60 60
         } else {
61 61
             // value is from a nested form
62 62
             $value = $values;
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
70 70
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
71
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
72
-			$value = reset($value);
71
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
72
+			$value = reset( $value );
73 73
 		}
74 74
 
75 75
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
76
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77 77
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78 78
             $_POST['item_name'] = $value;
79 79
         }
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
86 86
 		}
87 87
 
88
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
88
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
89 89
 
90
-        self::validate_recaptcha($errors, $posted_field, $args);
90
+        self::validate_recaptcha( $errors, $posted_field, $args );
91 91
 
92
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
92
+        $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
93 93
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
94 94
     }
95 95
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             return;
105 105
         }
106 106
 
107
-        if ( trim($value) == 'http://' ) {
107
+        if ( trim( $value ) == 'http://' ) {
108 108
             $value = '';
109 109
         } else {
110 110
             $value = esc_url_raw( $value );
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         //validate the url format
115
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
116
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
115
+        if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) {
116
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
117 117
         }
118 118
     }
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         //validate the email format
126
-        if ( ! is_email($value) ) {
127
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
126
+        if ( ! is_email( $value ) ) {
127
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
128 128
         }
129 129
     }
130 130
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 			return;
135 135
 		}
136 136
 
137
-		if ( ! is_numeric( $value) ) {
138
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
137
+		if ( ! is_numeric( $value ) ) {
138
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
139 139
 		}
140 140
 
141 141
 		// validate number settings
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
146 146
 				//minnum maxnum
147 147
 				if ( (float) $value < $field->field_options['minnum'] ) {
148
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
148
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
149 149
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
150
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
150
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
151 151
 				}
152 152
 			}
153 153
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		$pattern = self::phone_format( $field );
162 162
 
163 163
 		if ( ! preg_match( $pattern, $value ) ) {
164
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
164
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
165 165
 		}
166 166
 	}
167 167
 
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 			return;
214 214
 		}
215 215
 
216
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
216
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
217 217
             // If captcha is missing, check if it was already verified
218 218
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
219 219
                 // There was no captcha submitted
220
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
220
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
221 221
             }
222 222
             return;
223 223
         }
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
 			),
231 231
 		);
232 232
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
233
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
233
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
234 234
 
235 235
         if ( isset( $response['success'] ) && ! $response['success'] ) {
236 236
             // What happens when the CAPTCHA was entered incorrectly
237
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
237
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
238 238
         } else if ( is_wp_error( $resp ) ) {
239 239
 			$error_string = $resp->get_error_message();
240
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
241
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
240
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
241
+			$errors['field' . $args['id']] .= ' ' . $error_string;
242 242
         }
243 243
     }
244 244
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 	private static function is_akismet_spam( $values ) {
269 269
 		global $wpcom_api_key;
270
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
270
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
271 271
 	}
272 272
 
273 273
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
     public static function blacklist_check( $values ) {
279
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
279
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
280 280
             return false;
281 281
         }
282 282
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
     		return false;
287 287
     	}
288 288
 
289
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
289
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
290 290
 
291
-		if ( empty($content) ) {
291
+		if ( empty( $content ) ) {
292 292
 		    return false;
293 293
 		}
294 294
 
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
     	foreach ( (array) $words as $word ) {
298 298
     		$word = trim( $word );
299 299
 
300
-    		if ( empty($word) ) {
300
+    		if ( empty( $word ) ) {
301 301
     			continue;
302 302
     		}
303 303
 
304
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
304
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
305 305
     			return true;
306 306
     		}
307 307
     	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			unset( $key, $data );
331 331
 		}
332 332
 
333
-        $response = Akismet::http_post($query_string, 'comment-check');
333
+        $response = Akismet::http_post( $query_string, 'comment-check' );
334 334
 
335 335
 		return ( is_array( $response ) && $response[1] == 'true' );
336 336
     }
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 
354 354
         foreach ( $_SERVER as $key => $value ) {
355 355
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
356
-				$datas[ $key ] = wp_strip_all_tags( $value );
356
+				$datas[$key] = wp_strip_all_tags( $value );
357 357
             } else {
358
-				$datas[ $key ] = '';
358
+				$datas[$key] = '';
359 359
             }
360 360
 
361
-            unset($key, $value);
361
+            unset( $key, $value );
362 362
         }
363 363
     }
364 364
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Spacing   +74 added lines, -74 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,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 'default_value' => $field->default_value,
26 26
                 'name' => $field->name,
27 27
                 'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
28
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
29 29
                 'options' => $field->options,
30 30
                 'required' => $field->required,
31 31
                 'field_key' => $field->field_key,
@@ -36,43 +36,43 @@  discard block
 block discarded – undo
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37 37
             );
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
40 40
             $opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
44
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
45
+                unset( $opt, $default_opt );
46 46
             }
47 47
 
48
-            unset($opt_defaults);
48
+            unset( $opt_defaults );
49 49
 
50 50
             if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
52 52
             }
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
54
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
55 55
             $field_array = array_merge( $field->field_options, $field_array );
56 56
 
57 57
             $values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
59
+            if ( ! $form || ! isset( $form->id ) ) {
60
+                $form = FrmForm::getOne( $field->form_id );
61 61
             }
62 62
         }
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
64
+        $form->options = maybe_unserialize( $form->options );
65
+        if ( is_array( $form->options ) ) {
66 66
             foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
67
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
68
+                unset( $opt, $value );
69 69
             }
70 70
         }
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
74 74
 		$frm_settings = FrmAppHelper::get_settings();
75
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
75
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
76 76
 
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
96 96
 
97 97
 		// Do any shortcodes in default value and allow customization of default value
98
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
98
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
99 99
 		// Calls FrmProFieldsHelper::get_default_value
100 100
 
101 101
 		$new_value = $field->default_value;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		if ( ! is_array( $new_value ) ) {
111
-			$new_value = str_replace('"', '&quot;', $new_value);
111
+			$new_value = str_replace( '"', '&quot;', $new_value );
112 112
 		}
113 113
 
114 114
 		return $new_value;
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		if ( $_POST ) {
128 128
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
129 129
 			if ( $repeating ) {
130
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
130
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
131 131
 					$value_is_posted = true;
132 132
 				}
133
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
133
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
134 134
 				$value_is_posted = true;
135 135
 			}
136 136
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142 142
         $values['form_id'] = $record->form_id;
143 143
         $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
144
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
145 145
     }
146 146
 
147 147
     public static function get_admin_params( $form = null ) {
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
     }
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
173
+        if ( strpos( $message, '[default-message' ) === false &&
174
+            strpos( $message, '[default_message' ) === false &&
175 175
             ! empty( $message ) ) {
176 176
             return $message;
177 177
         }
178 178
 
179
-        if ( empty($message) ) {
179
+        if ( empty( $message ) ) {
180 180
             $message = '[default-message]';
181 181
         }
182 182
 
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
183
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
184 184
 
185 185
         foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
186
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
187 187
             if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
188
+                $this_atts = array_merge( $atts, $add_atts );
189 189
             } else {
190 190
                 $this_atts = $atts;
191 191
             }
@@ -193,32 +193,32 @@  discard block
 block discarded – undo
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195 195
             // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
196
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
197 197
         }
198 198
 
199 199
         return $message;
200 200
     }
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
203
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
204 204
 
205 205
         if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207 207
         }
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
209
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210
+            return self::display_value( $field_value, $field, $atts );
211 211
         }
212 212
 
213 213
         // this is an embeded form
214 214
         $val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
216
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
217 217
             //this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219 219
         } else {
220 220
             // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
221
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
222 222
 
223 223
             if ( $child_values ) {
224 224
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 	    $field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
230
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231 231
             return $val;
232 232
         }
233 233
 
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
             $atts['post_id'] = $child_entry->post_id;
237 237
 
238 238
             // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
239
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
240 240
 
241 241
             if ( $entry_val ) {
242 242
                 // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
243
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
244 244
             }
245 245
 
246
-            unset($child_entry);
246
+            unset( $child_entry );
247 247
         }
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+        $val = implode( ', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252 252
         return $val;
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
         );
267 267
 
268 268
         $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
269
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
271
+        if ( ! isset( $field->field_options['post_field'] ) ) {
272 272
             $field->field_options['post_field'] = '';
273 273
         }
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
275
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
276 276
             $field->field_options['custom_field'] = '';
277 277
         }
278 278
 
279 279
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280 280
             $atts['pre_truncate'] = $atts['truncate'];
281 281
             $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
282
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
284
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
285 285
             $atts['truncate'] = $atts['pre_truncate'];
286 286
         }
287 287
 
@@ -289,39 +289,39 @@  discard block
 block discarded – undo
289 289
             return $value;
290 290
         }
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295 295
         $new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
297
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
298 298
             foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
299
+                if ( is_array( $val ) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
301
+                    $new_value .= implode( $atts['sep'], $val );
302 302
                     if ( $atts['type'] != 'data' ) {
303 303
                         $new_value .= '<br/>';
304 304
                     }
305 305
                 }
306
-                unset($val);
306
+                unset( $val );
307 307
             }
308 308
         }
309 309
 
310
-        if ( ! empty($new_value) ) {
310
+        if ( ! empty( $new_value ) ) {
311 311
             $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
312
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+            $value = implode( $atts['sep'], $value );
314 314
         }
315 315
 
316 316
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
317
+            $value = FrmAppHelper::truncate( $value, 50 );
318 318
         }
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
324
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
325 325
     }
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
         if ( isset( $args['other'] ) && $args['other'] ) {
330 330
             $value = $args['temp_value'];
331 331
         }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
332
+        if ( empty( $args['parent_field_id'] ) ) {
333
+            $_POST['item_meta'][$field->id] = $value;
334 334
         } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
335
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
342
+        if ( empty( $args['parent_field_id'] ) ) {
343
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
344 344
         } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
345
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
346 346
         }
347 347
     }
348 348
 
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
         self::set_other_repeating_vals( $field, $value, $args );
366 366
 
367 367
         // Check if there are any posted "Other" values
368
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
368
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
369 369
 
370 370
             // Save original value
371 371
             $args['temp_value'] = $value;
372 372
             $args['other'] = true;
373
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
373
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
374 374
 
375 375
             // Set the validation value now
376 376
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
         }
393 393
 
394 394
         // Check if there are any other posted "other" values for this field
395
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
395
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
396 396
             // Save original value
397 397
             $args['temp_value'] = $value;
398 398
             $args['other'] = true;
399 399
 
400
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
400
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
401 401
 
402 402
             // Set the validation value now
403 403
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -429,27 +429,27 @@  discard block
 block discarded – undo
429 429
             }
430 430
         } else {
431 431
 			// Radio and dropdowns
432
-            $other_key = array_filter( array_keys($field->options), 'is_string');
432
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
433 433
             $other_key = reset( $other_key );
434 434
 
435 435
             // Multi-select dropdown
436 436
             if ( is_array( $value ) ) {
437
-                $o_key = array_search( $field->options[ $other_key ], $value );
437
+                $o_key = array_search( $field->options[$other_key], $value );
438 438
 
439 439
 				if ( $o_key !== false ) {
440 440
 					// Modify the original value so other key will be preserved
441
-					$value[ $other_key ] = $value[ $o_key ];
441
+					$value[$other_key] = $value[$o_key];
442 442
 
443 443
 					// By default, the array keys will be numeric for multi-select dropdowns
444 444
 					// If going backwards and forwards between pages, the array key will match the other key
445 445
 					if ( $o_key != $other_key ) {
446
-						unset( $value[ $o_key ] );
446
+						unset( $value[$o_key] );
447 447
 					}
448 448
 
449 449
 					$args['temp_value'] = $value;
450
-					$value[ $other_key ] = reset( $other_vals );
450
+					$value[$other_key] = reset( $other_vals );
451 451
 				}
452
-            } else if ( $field->options[ $other_key ] == $value ) {
452
+            } else if ( $field->options[$other_key] == $value ) {
453 453
                 $value = $other_vals;
454 454
             }
455 455
         }
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 				$content .= "\n\n";
469 469
 			}
470 470
 
471
-			if ( is_array($val) ) {
471
+			if ( is_array( $val ) ) {
472 472
 				$val = FrmAppHelper::array_flatten( $val );
473
-			    $val = implode(',', $val);
473
+			    $val = implode( ',', $val );
474 474
 			}
475 475
 
476 476
 			$content .= $val;
@@ -515,6 +515,6 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	public static function entries_dropdown() {
518
-		_deprecated_function( __FUNCTION__, '1.07.09');
518
+		_deprecated_function( __FUNCTION__, '1.07.09' );
519 519
 	}
520 520
 }
Please login to merge, or discard this patch.
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
13
-
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
18
-
19
-        foreach ( (array) $fields as $field ) {
20
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
-
22
-            $field_array = array(
23
-                'id' => $field->id,
24
-                'value' => $new_value,
25
-                'default_value' => $field->default_value,
26
-                'name' => $field->name,
27
-                'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
-                'options' => $field->options,
30
-                'required' => $field->required,
31
-                'field_key' => $field->field_key,
32
-                'field_order' => $field->field_order,
33
-                'form_id' => $field->form_id,
12
+		}
13
+
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18
+
19
+		foreach ( (array) $fields as $field ) {
20
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
+
22
+			$field_array = array(
23
+				'id' => $field->id,
24
+				'value' => $new_value,
25
+				'default_value' => $field->default_value,
26
+				'name' => $field->name,
27
+				'description' => $field->description,
28
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+				'options' => $field->options,
30
+				'required' => $field->required,
31
+				'field_key' => $field->field_key,
32
+				'field_order' => $field->field_order,
33
+				'form_id' => $field->form_id,
34 34
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
35
-	            'reset_value' => $reset,
35
+				'reset_value' => $reset,
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37
-            );
37
+			);
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
-            $opt_defaults['required_indicator'] = '';
39
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+			$opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
46
-            }
44
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
+				unset($opt, $default_opt);
46
+			}
47 47
 
48
-            unset($opt_defaults);
48
+			unset($opt_defaults);
49 49
 
50
-            if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
-            }
50
+			if ( $field_array['custom_html'] == '' ) {
51
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+			}
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
-            $field_array = array_merge( $field->field_options, $field_array );
54
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+			$field_array = array_merge( $field->field_options, $field_array );
56 56
 
57
-            $values['fields'][] = $field_array;
57
+			$values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
61
-            }
62
-        }
59
+			if ( ! $form || ! isset($form->id) ) {
60
+				$form = FrmForm::getOne($field->form_id);
61
+			}
62
+		}
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
66
-            foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
69
-            }
70
-        }
64
+		$form->options = maybe_unserialize($form->options);
65
+		if ( is_array($form->options) ) {
66
+			foreach ( $form->options as $opt => $value ) {
67
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
+				unset($opt, $value);
69
+			}
70
+		}
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
79 79
 		return apply_filters( 'frm_setup_new_entry', $values );
80
-    }
80
+	}
81 81
 
82 82
 	/**
83
-	* Set the value for each field
84
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
85
-	*
86
-	* @since 2.0.13
87
-	*
88
-	* @param object $field - this is passed by reference since it is an object
89
-	* @param boolean $reset
90
-	* @param array $args
91
-	* @return string|array $new_value
92
-	*/
83
+	 * Set the value for each field
84
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
85
+	 *
86
+	 * @since 2.0.13
87
+	 *
88
+	 * @param object $field - this is passed by reference since it is an object
89
+	 * @param boolean $reset
90
+	 * @param array $args
91
+	 * @return string|array $new_value
92
+	 */
93 93
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
94 94
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Check if a field has a posted value
119
-	*
120
-	* @since 2.01.0
121
-	* @param object $field
122
-	* @param array $args
123
-	* @return boolean $value_is_posted
124
-	*/
118
+	 * Check if a field has a posted value
119
+	 *
120
+	 * @since 2.01.0
121
+	 * @param object $field
122
+	 * @param array $args
123
+	 * @return boolean $value_is_posted
124
+	 */
125 125
 	public static function value_is_posted( $field, $args ) {
126 126
 		$value_is_posted = false;
127 127
 		if ( $_POST ) {
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 
140 140
 	public static function setup_edit_vars( $values, $record ) {
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142
-        $values['form_id'] = $record->form_id;
143
-        $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
-    }
142
+		$values['form_id'] = $record->form_id;
143
+		$values['is_draft'] = $record->is_draft;
144
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
+	}
146 146
 
147
-    public static function get_admin_params( $form = null ) {
147
+	public static function get_admin_params( $form = null ) {
148 148
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
149 149
 		return FrmForm::set_current_form( $form );
150
-    }
150
+	}
151 151
 
152 152
 	public static function set_current_form( $form_id ) {
153 153
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -159,284 +159,284 @@  discard block
 block discarded – undo
159 159
 		return FrmForm::get_current_form( $form_id );
160 160
 	}
161 161
 
162
-    public static function get_current_form_id() {
162
+	public static function get_current_form_id() {
163 163
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
164 164
 		return FrmForm::get_current_form_id();
165
-    }
165
+	}
166 166
 
167
-    public static function maybe_get_entry( &$entry ) {
167
+	public static function maybe_get_entry( &$entry ) {
168 168
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
169 169
 		FrmEntry::maybe_get_entry( $entry );
170
-    }
170
+	}
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
175
-            ! empty( $message ) ) {
176
-            return $message;
177
-        }
178
-
179
-        if ( empty($message) ) {
180
-            $message = '[default-message]';
181
-        }
182
-
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
-
185
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
-            if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
189
-            } else {
190
-                $this_atts = $atts;
191
-            }
173
+		if ( strpos($message, '[default-message') === false &&
174
+			strpos($message, '[default_message') === false &&
175
+			! empty( $message ) ) {
176
+			return $message;
177
+		}
178
+
179
+		if ( empty($message) ) {
180
+			$message = '[default-message]';
181
+		}
182
+
183
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
+
185
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
186
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
+			if ( $add_atts ) {
188
+				$this_atts = array_merge($atts, $add_atts);
189
+			} else {
190
+				$this_atts = $atts;
191
+			}
192 192
 
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195
-            // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
-        }
195
+			// Add the default message
196
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
+		}
198 198
 
199
-        return $message;
200
-    }
199
+		return $message;
200
+	}
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203 203
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
204 204
 
205
-        if ( FrmAppHelper::pro_is_installed() ) {
205
+		if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207
-        }
207
+		}
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
211
-        }
209
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
+			return self::display_value($field_value, $field, $atts);
211
+		}
212 212
 
213
-        // this is an embeded form
214
-        $val = '';
213
+		// this is an embeded form
214
+		$val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
-            //this is a repeating section
216
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
+			//this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219
-        } else {
220
-            // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
219
+		} else {
220
+			// get all values for this field
221
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
222 222
 
223
-            if ( $child_values ) {
224
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
-	        }
226
-	    }
223
+			if ( $child_values ) {
224
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
+			}
226
+		}
227 227
 
228
-	    $field_value = array();
228
+		$field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
-            return $val;
232
-        }
230
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
+			return $val;
232
+		}
233 233
 
234
-        foreach ( $child_entries as $child_entry ) {
235
-            $atts['item_id'] = $child_entry->id;
236
-            $atts['post_id'] = $child_entry->post_id;
234
+		foreach ( $child_entries as $child_entry ) {
235
+			$atts['item_id'] = $child_entry->id;
236
+			$atts['post_id'] = $child_entry->post_id;
237 237
 
238
-            // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
238
+			// get the value for this field -- check for post values as well
239
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
240 240
 
241
-            if ( $entry_val ) {
242
-                // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
244
-            }
241
+			if ( $entry_val ) {
242
+				// foreach entry get display_value
243
+				$field_value[] = self::display_value($entry_val, $field, $atts);
244
+			}
245 245
 
246
-            unset($child_entry);
247
-        }
246
+			unset($child_entry);
247
+		}
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+		$val = implode(', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252
-        return $val;
253
-    }
252
+		return $val;
253
+	}
254 254
 
255
-    /**
256
-     * Prepare the saved value for display
257
-     * @return string
258
-     */
255
+	/**
256
+	 * Prepare the saved value for display
257
+	 * @return string
258
+	 */
259 259
 	public static function display_value( $value, $field, $atts = array() ) {
260 260
 
261
-        $defaults = array(
262
-            'type' => '', 'html' => false, 'show_filename' => true,
263
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
261
+		$defaults = array(
262
+			'type' => '', 'html' => false, 'show_filename' => true,
263
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
265 265
 			'return_array' => false,
266
-        );
266
+		);
267 267
 
268
-        $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
268
+		$atts = wp_parse_args( $atts, $defaults );
269
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
272
-            $field->field_options['post_field'] = '';
273
-        }
271
+		if ( ! isset($field->field_options['post_field']) ) {
272
+			$field->field_options['post_field'] = '';
273
+		}
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
276
-            $field->field_options['custom_field'] = '';
277
-        }
275
+		if ( ! isset($field->field_options['custom_field']) ) {
276
+			$field->field_options['custom_field'] = '';
277
+		}
278 278
 
279
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
-            $atts['pre_truncate'] = $atts['truncate'];
281
-            $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
279
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
+			$atts['pre_truncate'] = $atts['truncate'];
281
+			$atts['truncate'] = true;
282
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
-            $atts['truncate'] = $atts['pre_truncate'];
286
-        }
284
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
+			$atts['truncate'] = $atts['pre_truncate'];
286
+		}
287 287
 
288
-        if ( $value == '' ) {
289
-            return $value;
290
-        }
288
+		if ( $value == '' ) {
289
+			return $value;
290
+		}
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295
-        $new_value = '';
295
+		$new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
298
-            foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
297
+		if ( is_array($value) && $atts['type'] != 'file' ) {
298
+			foreach ( $value as $val ) {
299
+				if ( is_array($val) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
302
-                    if ( $atts['type'] != 'data' ) {
303
-                        $new_value .= '<br/>';
304
-                    }
305
-                }
306
-                unset($val);
307
-            }
308
-        }
309
-
310
-        if ( ! empty($new_value) ) {
311
-            $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
314
-        }
315
-
316
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
318
-        }
301
+					$new_value .= implode($atts['sep'], $val);
302
+					if ( $atts['type'] != 'data' ) {
303
+						$new_value .= '<br/>';
304
+					}
305
+				}
306
+				unset($val);
307
+			}
308
+		}
309
+
310
+		if ( ! empty($new_value) ) {
311
+			$value = $new_value;
312
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+			$value = implode($atts['sep'], $value);
314
+		}
315
+
316
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
+			$value = FrmAppHelper::truncate($value, 50);
318
+		}
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
325
-    }
324
+		return apply_filters('frm_display_value', $value, $field, $atts);
325
+	}
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
328
-        // If validating a field with "other" opt, set back to prev value now
329
-        if ( isset( $args['other'] ) && $args['other'] ) {
330
-            $value = $args['temp_value'];
331
-        }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
334
-        } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
-        }
337
-    }
328
+		// If validating a field with "other" opt, set back to prev value now
329
+		if ( isset( $args['other'] ) && $args['other'] ) {
330
+			$value = $args['temp_value'];
331
+		}
332
+		if ( empty($args['parent_field_id']) ) {
333
+			$_POST['item_meta'][ $field->id ] = $value;
334
+		} else {
335
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
+		}
337
+	}
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
-        } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
-        }
342
+		if ( empty($args['parent_field_id']) ) {
343
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
+		} else {
345
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
+		}
347 347
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
348 348
 		$value = stripslashes_deep( $value );
349
-    }
350
-
351
-    /**
352
-    * Check if field has an "Other" option and if any other values are posted
353
-    *
354
-    * @since 2.0
355
-    *
356
-    * @param object $field
357
-    * @param string|array $value
358
-    * @param array $args
359
-    */
360
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
361
-        $args['other'] = false;
362
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
363
-            return;
364
-        }
365
-
366
-        // Get other value for fields in repeating section
367
-        self::set_other_repeating_vals( $field, $value, $args );
368
-
369
-        // Check if there are any posted "Other" values
349
+	}
350
+
351
+	/**
352
+	 * Check if field has an "Other" option and if any other values are posted
353
+	 *
354
+	 * @since 2.0
355
+	 *
356
+	 * @param object $field
357
+	 * @param string|array $value
358
+	 * @param array $args
359
+	 */
360
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
361
+		$args['other'] = false;
362
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
363
+			return;
364
+		}
365
+
366
+		// Get other value for fields in repeating section
367
+		self::set_other_repeating_vals( $field, $value, $args );
368
+
369
+		// Check if there are any posted "Other" values
370 370
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
371 371
 
372
-            // Save original value
373
-            $args['temp_value'] = $value;
374
-            $args['other'] = true;
375
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
376
-
377
-            // Set the validation value now
378
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
379
-        }
380
-    }
381
-
382
-    /**
383
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
384
-    *
385
-    * @since 2.0
386
-    *
387
-    * @param object $field
388
-    * @param string|array $value
389
-    * @param array $args
390
-    */
391
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
392
-        if ( ! $args['parent_field_id'] ) {
393
-            return;
394
-        }
395
-
396
-        // Check if there are any other posted "other" values for this field
372
+			// Save original value
373
+			$args['temp_value'] = $value;
374
+			$args['other'] = true;
375
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
376
+
377
+			// Set the validation value now
378
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
379
+		}
380
+	}
381
+
382
+	/**
383
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
384
+	 *
385
+	 * @since 2.0
386
+	 *
387
+	 * @param object $field
388
+	 * @param string|array $value
389
+	 * @param array $args
390
+	 */
391
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
392
+		if ( ! $args['parent_field_id'] ) {
393
+			return;
394
+		}
395
+
396
+		// Check if there are any other posted "other" values for this field
397 397
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
398
-            // Save original value
399
-            $args['temp_value'] = $value;
400
-            $args['other'] = true;
401
-
402
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
403
-
404
-            // Set the validation value now
405
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
406
-        }
407
-    }
408
-
409
-    /**
410
-    * Modify value used for validation
411
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
412
-    * It also adds any text from the free text fields to the value
413
-    *
414
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
415
-    *
416
-    * @since 2.0
417
-    *
418
-    * @param string|array $value
419
-    * @param string|array $other_vals (usually of posted values)
420
-    * @param object $field
421
-    * @param array $args
422
-    */
423
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
424
-        // Checkboxes and multi-select dropdowns
425
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
426
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
427
-            $value = array_merge( $value, $other_vals );
428
-            $value = array_filter( $value );
429
-            if ( count( $value ) == 0 ) {
430
-                $value = '';
431
-            }
432
-        } else {
398
+			// Save original value
399
+			$args['temp_value'] = $value;
400
+			$args['other'] = true;
401
+
402
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
403
+
404
+			// Set the validation value now
405
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
406
+		}
407
+	}
408
+
409
+	/**
410
+	 * Modify value used for validation
411
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
412
+	 * It also adds any text from the free text fields to the value
413
+	 *
414
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
415
+	 *
416
+	 * @since 2.0
417
+	 *
418
+	 * @param string|array $value
419
+	 * @param string|array $other_vals (usually of posted values)
420
+	 * @param object $field
421
+	 * @param array $args
422
+	 */
423
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
424
+		// Checkboxes and multi-select dropdowns
425
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
426
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
427
+			$value = array_merge( $value, $other_vals );
428
+			$value = array_filter( $value );
429
+			if ( count( $value ) == 0 ) {
430
+				$value = '';
431
+			}
432
+		} else {
433 433
 			// Radio and dropdowns
434
-            $other_key = array_filter( array_keys($field->options), 'is_string');
435
-            $other_key = reset( $other_key );
434
+			$other_key = array_filter( array_keys($field->options), 'is_string');
435
+			$other_key = reset( $other_key );
436 436
 
437
-            // Multi-select dropdown
438
-            if ( is_array( $value ) ) {
439
-                $o_key = array_search( $field->options[ $other_key ], $value );
437
+			// Multi-select dropdown
438
+			if ( is_array( $value ) ) {
439
+				$o_key = array_search( $field->options[ $other_key ], $value );
440 440
 
441 441
 				if ( $o_key !== false ) {
442 442
 					// Modify the original value so other key will be preserved
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 					$args['temp_value'] = $value;
452 452
 					$value[ $other_key ] = reset( $other_vals );
453 453
 				}
454
-            } else if ( $field->options[ $other_key ] == $value ) {
455
-                $value = $other_vals;
456
-            }
457
-        }
458
-    }
454
+			} else if ( $field->options[ $other_key ] == $value ) {
455
+				$value = $other_vals;
456
+			}
457
+		}
458
+	}
459 459
 
460 460
 	public static function enqueue_scripts( $params ) {
461 461
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
462 462
 		FrmFormsController::enqueue_scripts( $params );
463 463
 	}
464 464
 
465
-    // Add submitted values to a string for spam checking
465
+	// Add submitted values to a string for spam checking
466 466
 	public static function entry_array_to_string( $values ) {
467
-        $content = '';
467
+		$content = '';
468 468
 		foreach ( $values['item_meta'] as $val ) {
469 469
 			if ( $content != '' ) {
470 470
 				$content .= "\n\n";
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 
473 473
 			if ( is_array($val) ) {
474 474
 				$val = FrmAppHelper::array_flatten( $val );
475
-			    $val = implode(',', $val);
475
+				$val = implode(',', $val);
476 476
 			}
477 477
 
478 478
 			$content .= $val;
479 479
 		}
480 480
 
481 481
 		return $content;
482
-    }
482
+	}
483 483
 
484 484
 	public static function fill_entry_values( $atts, $f, array &$values ) {
485 485
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
classes/models/FrmEntry.php 2 patches
Indentation   +377 added lines, -377 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 class FrmEntry {
7 7
 
8 8
 	/**
9
-	* Create a new entry
10
-	*
11
-	* @param array $values
12
-	* @return int | boolean $entry_id
13
-	*/
9
+	 * Create a new entry
10
+	 *
11
+	 * @param array $values
12
+	 * @return int | boolean $entry_id
13
+	 */
14 14
 	public static function create( $values ) {
15 15
 		$entry_id = self::create_entry( $values, 'standard' );
16 16
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	/**
21
-	* Create a new entry with some differences depending on type
22
-	*
23
-	* @param array $values
24
-	* @param string $type
25
-	* @return int | boolean $entry_id
26
-	*/
21
+	 * Create a new entry with some differences depending on type
22
+	 *
23
+	 * @param array $values
24
+	 * @param string $type
25
+	 * @return int | boolean $entry_id
26
+	 */
27 27
 	private static function create_entry( $values, $type ) {
28 28
 		$new_values = self::before_insert_entry_in_database( $values, $type );
29 29
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 		return $entry_id;
38 38
 	}
39 39
 
40
-    /**
41
-     * check for duplicate entries created in the last minute
42
-     * @return boolean
43
-     */
40
+	/**
41
+	 * check for duplicate entries created in the last minute
42
+	 * @return boolean
43
+	 */
44 44
 	public static function is_duplicate( $new_values, $values ) {
45 45
 		$duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values );
46 46
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
 			return false;
49 49
 		}
50 50
 
51
-        $check_val = $new_values;
51
+		$check_val = $new_values;
52 52
 		$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) );
53 53
 
54 54
 		unset( $check_val['created_at'], $check_val['updated_at'] );
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57
-        if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
59
-        }
57
+		if ( $new_values['item_key'] == $new_values['name'] ) {
58
+			unset($check_val['name']);
59
+		}
60 60
 
61
-        global $wpdb;
61
+		global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
-            return false;
66
-        }
64
+		if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
65
+			return false;
66
+		}
67 67
 
68
-        $is_duplicate = false;
69
-        foreach ( $entry_exists as $entry_exist ) {
70
-            $is_duplicate = true;
68
+		$is_duplicate = false;
69
+		foreach ( $entry_exists as $entry_exist ) {
70
+			$is_duplicate = true;
71 71
 
72
-            //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
-            $field_metas = array();
75
-            foreach ( $metas as $meta ) {
72
+			//add more checks here to make sure it's a duplicate
73
+			$metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
74
+			$field_metas = array();
75
+			foreach ( $metas as $meta ) {
76 76
 				$field_metas[ $meta->field_id ] = $meta->meta_value;
77
-            }
78
-
79
-            // If prev entry is empty and current entry is not, they are not duplicates
80
-            $filtered_vals = array_filter( $values['item_meta'] );
81
-            if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
-                return false;
83
-            }
84
-
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
-            foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
88
-                    $is_duplicate = false;
89
-                    continue;
90
-                }
91
-            }
92
-
93
-            if ( $is_duplicate ) {
77
+			}
78
+
79
+			// If prev entry is empty and current entry is not, they are not duplicates
80
+			$filtered_vals = array_filter( $values['item_meta'] );
81
+			if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) {
82
+				return false;
83
+			}
84
+
85
+			$diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
86
+			foreach ( $diff as $field_id => $meta_value ) {
87
+				if ( ! empty($meta_value) ) {
88
+					$is_duplicate = false;
89
+					continue;
90
+				}
91
+			}
92
+
93
+			if ( $is_duplicate ) {
94 94
 				break;
95
-            }
96
-        }
95
+			}
96
+		}
97 97
 
98
-        return $is_duplicate;
99
-    }
98
+		return $is_duplicate;
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Determine if an entry needs to be checked as a possible duplicate
@@ -125,46 +125,46 @@  discard block
 block discarded – undo
125 125
 		return true;
126 126
 	}
127 127
 
128
-    public static function duplicate( $id ) {
129
-        global $wpdb;
128
+	public static function duplicate( $id ) {
129
+		global $wpdb;
130 130
 
131
-        $values = self::getOne( $id );
131
+		$values = self::getOne( $id );
132 132
 
133
-        $new_values = array();
133
+		$new_values = array();
134 134
 		$new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
135
-        $new_values['name'] = $values->name;
136
-        $new_values['is_draft'] = $values->is_draft;
137
-        $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
138
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
135
+		$new_values['name'] = $values->name;
136
+		$new_values['is_draft'] = $values->is_draft;
137
+		$new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
138
+		$new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
+		$new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
140 140
 
141 141
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
142
-        if ( ! $query_results ) {
143
-            return false;
144
-        }
142
+		if ( ! $query_results ) {
143
+			return false;
144
+		}
145 145
 
146
-        $entry_id = $wpdb->insert_id;
146
+		$entry_id = $wpdb->insert_id;
147 147
 
148
-        global $frm_vars;
149
-        if ( ! isset($frm_vars['saved_entries']) ) {
150
-            $frm_vars['saved_entries'] = array();
151
-        }
152
-        $frm_vars['saved_entries'][] = (int) $entry_id;
148
+		global $frm_vars;
149
+		if ( ! isset($frm_vars['saved_entries']) ) {
150
+			$frm_vars['saved_entries'] = array();
151
+		}
152
+		$frm_vars['saved_entries'][] = (int) $entry_id;
153 153
 
154
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
154
+		FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
155 155
 		self::clear_cache();
156 156
 
157 157
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
158
-        return $entry_id;
159
-    }
158
+		return $entry_id;
159
+	}
160 160
 
161 161
 	/**
162
-	* Update an entry (not via XML)
163
-	*
164
-	* @param int $id
165
-	* @param array $values
166
-	* @return boolean|int $update_results
167
-	*/
162
+	 * Update an entry (not via XML)
163
+	 *
164
+	 * @param int $id
165
+	 * @param array $values
166
+	 * @return boolean|int $update_results
167
+	 */
168 168
 	public static function update( $id, $values ) {
169 169
 		$update_results = self::update_entry( $id, $values, 'standard' );
170 170
 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	}
173 173
 
174 174
 	/**
175
-	* Update an entry with some differences depending on the update type
176
-	*
177
-	* @since 2.0.16
178
-	*
179
-	* @param int $id
180
-	* @param array $values
181
-	* @return boolean|int $query_results
182
-	*/
175
+	 * Update an entry with some differences depending on the update type
176
+	 *
177
+	 * @since 2.0.16
178
+	 *
179
+	 * @param int $id
180
+	 * @param array $values
181
+	 * @return boolean|int $query_results
182
+	 */
183 183
 	private static function update_entry( $id, $values, $update_type ) {
184 184
 		global $wpdb;
185 185
 
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
 	}
199 199
 
200 200
 	public static function &destroy( $id ) {
201
-        global $wpdb;
202
-        $id = (int) $id;
201
+		global $wpdb;
202
+		$id = (int) $id;
203 203
 
204 204
 		$entry = self::getOne( $id );
205
-        if ( ! $entry ) {
206
-            $result = false;
207
-            return $result;
208
-        }
205
+		if ( ! $entry ) {
206
+			$result = false;
207
+			return $result;
208
+		}
209 209
 
210
-        do_action('frm_before_destroy_entry', $id, $entry);
210
+		do_action('frm_before_destroy_entry', $id, $entry);
211 211
 
212 212
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
213 213
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
214 214
 
215 215
 		self::clear_cache();
216 216
 
217
-        return $result;
218
-    }
217
+		return $result;
218
+	}
219 219
 
220 220
 	public static function &update_form( $id, $value, $form_id ) {
221
-        global $wpdb;
222
-        $form_id = isset($value) ? $form_id : null;
221
+		global $wpdb;
222
+		$form_id = isset($value) ? $form_id : null;
223 223
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
224 224
 		if ( $result ) {
225 225
 			self::clear_cache();
226 226
 		}
227
-        return $result;
228
-    }
227
+		return $result;
228
+	}
229 229
 
230 230
 	/**
231 231
 	 * Clear entry caching
@@ -261,161 +261,161 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	public static function getOne( $id, $meta = false ) {
264
-        global $wpdb;
264
+		global $wpdb;
265 265
 
266
-        $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
266
+		$query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
267 267
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
268 268
 
269
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
270
-        $query_args = array( $id );
271
-        $query = $wpdb->prepare( $query, $query_args );
269
+		$query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
270
+		$query_args = array( $id );
271
+		$query = $wpdb->prepare( $query, $query_args );
272 272
 
273
-        if ( ! $meta ) {
273
+		if ( ! $meta ) {
274 274
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
275
-            return stripslashes_deep($entry);
276
-        }
275
+			return stripslashes_deep($entry);
276
+		}
277 277
 
278
-        $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
279
-        if ( $entry !== false ) {
280
-            return stripslashes_deep($entry);
281
-        }
278
+		$entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
279
+		if ( $entry !== false ) {
280
+			return stripslashes_deep($entry);
281
+		}
282 282
 
283
-        $entry = $wpdb->get_row( $query );
284
-        $entry = self::get_meta($entry);
283
+		$entry = $wpdb->get_row( $query );
284
+		$entry = self::get_meta($entry);
285 285
 
286
-        return stripslashes_deep($entry);
287
-    }
286
+		return stripslashes_deep($entry);
287
+	}
288 288
 
289 289
 	public static function get_meta( $entry ) {
290
-        if ( ! $entry ) {
291
-            return $entry;
292
-        }
290
+		if ( ! $entry ) {
291
+			return $entry;
292
+		}
293 293
 
294
-        global $wpdb;
294
+		global $wpdb;
295 295
 		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' );
296 296
 
297
-        $entry->metas = array();
297
+		$entry->metas = array();
298 298
 
299 299
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
300
-        foreach ( $metas as $meta_val ) {
301
-            if ( $meta_val->item_id == $entry->id ) {
300
+		foreach ( $metas as $meta_val ) {
301
+			if ( $meta_val->item_id == $entry->id ) {
302 302
 				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
303 303
 				if ( $include_key ) {
304 304
 					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
305 305
 				}
306
-                 continue;
307
-            }
306
+				 continue;
307
+			}
308 308
 
309
-            // include sub entries in an array
309
+			// include sub entries in an array
310 310
 			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
311 311
 				$entry->metas[ $meta_val->field_id ] = array();
312
-            }
312
+			}
313 313
 
314 314
 			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
315 315
 
316
-            unset($meta_val);
317
-        }
318
-        unset($metas);
316
+			unset($meta_val);
317
+		}
318
+		unset($metas);
319 319
 
320
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
320
+		wp_cache_set( $entry->id, $entry, 'frm_entry');
321 321
 
322
-        return $entry;
323
-    }
322
+		return $entry;
323
+	}
324 324
 
325
-    /**
326
-     * @param string $id
327
-     */
325
+	/**
326
+	 * @param string $id
327
+	 */
328 328
 	public static function &exists( $id ) {
329
-        global $wpdb;
330
-
331
-        if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
332
-            $exists = true;
333
-            return $exists;
334
-        }
335
-
336
-        if ( is_numeric($id) ) {
337
-            $where = array( 'id' => $id );
338
-        } else {
339
-            $where = array( 'item_key' => $id );
340
-        }
329
+		global $wpdb;
330
+
331
+		if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) {
332
+			$exists = true;
333
+			return $exists;
334
+		}
335
+
336
+		if ( is_numeric($id) ) {
337
+			$where = array( 'id' => $id );
338
+		} else {
339
+			$where = array( 'item_key' => $id );
340
+		}
341 341
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
342 342
 
343
-        $exists = ($id && $id > 0) ? true : false;
344
-        return $exists;
345
-    }
343
+		$exists = ($id && $id > 0) ? true : false;
344
+		return $exists;
345
+	}
346 346
 
347
-    public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
347
+	public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
348 348
 		global $wpdb;
349 349
 
350
-        $limit = FrmAppHelper::esc_limit($limit);
350
+		$limit = FrmAppHelper::esc_limit($limit);
351 351
 
352
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
353
-        $entries = wp_cache_get($cache_key, 'frm_entry');
352
+		$cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
353
+		$entries = wp_cache_get($cache_key, 'frm_entry');
354 354
 
355
-        if ( false === $entries ) {
356
-            $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
355
+		if ( false === $entries ) {
356
+			$fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
357 357
 			$table = $wpdb->prefix . 'frm_items it ';
358 358
 
359
-            if ( $inc_form ) {
360
-                $fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
361
-                $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
362
-            }
359
+			if ( $inc_form ) {
360
+				$fields = 'it.*, fr.name as form_name,fr.form_key as form_key';
361
+				$table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id ';
362
+			}
363 363
 
364
-            if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
365
-    		    // sort by a requested field
366
-                $field_id = (int) $order_matches[1];
364
+			if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) {
365
+				// sort by a requested field
366
+				$field_id = (int) $order_matches[1];
367 367
 				$fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id;
368 368
 				unset( $order_matches, $field_id );
369
-		    }
369
+			}
370 370
 
371 371
 			// prepare the query
372 372
 			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
373 373
 
374
-            $entries = $wpdb->get_results($query, OBJECT_K);
375
-            unset($query);
374
+			$entries = $wpdb->get_results($query, OBJECT_K);
375
+			unset($query);
376 376
 
377 377
 			if ( ! FrmAppHelper::prevent_caching() ) {
378 378
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
379 379
 			}
380
-        }
380
+		}
381 381
 
382
-        if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
384
-        }
385
-        unset($meta);
382
+		if ( ! $meta || ! $entries ) {
383
+			return stripslashes_deep($entries);
384
+		}
385
+		unset($meta);
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+		if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389
-        }
389
+		}
390 390
 
391
-        $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
-            $meta_where['fi.form_id'] = $where['it.form_id'];
394
-        } else {
395
-            $meta_where['item_id'] = array_keys( $entries );
396
-        }
391
+		$meta_where = array( 'field_id !' => 0 );
392
+		if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
393
+			$meta_where['fi.form_id'] = $where['it.form_id'];
394
+		} else {
395
+			$meta_where['item_id'] = array_keys( $entries );
396
+		}
397 397
 
398
-        $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
398
+		$metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' );
399 399
 
400
-        unset( $meta_where );
400
+		unset( $meta_where );
401 401
 
402
-        if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
404
-        }
402
+		if ( ! $metas ) {
403
+			return stripslashes_deep($entries);
404
+		}
405 405
 
406
-        foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
-                continue;
409
-            }
406
+		foreach ( $metas as $m_key => $meta_val ) {
407
+			if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
408
+				continue;
409
+			}
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
411
+			if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412 412
 				$entries[ $meta_val->item_id ]->metas = array();
413
-            }
413
+			}
414 414
 
415 415
 			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
418
-        }
417
+			unset($m_key, $meta_val);
418
+		}
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
421 421
 			foreach ( $entries as $entry ) {
@@ -424,31 +424,31 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
428
-    }
427
+		return stripslashes_deep($entries);
428
+	}
429 429
 
430
-    // Pagination Methods
431
-    public static function getRecordCount( $where = '' ) {
432
-        global $wpdb;
430
+	// Pagination Methods
431
+	public static function getRecordCount( $where = '' ) {
432
+		global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
436
-            $table_join = 'frm_items';
437
-            $where = array( 'form_id' => $where );
438
-        }
435
+		if ( is_numeric($where) ) {
436
+			$table_join = 'frm_items';
437
+			$where = array( 'form_id' => $where );
438
+		}
439 439
 
440
-        if ( is_array( $where ) ) {
441
-            $count = FrmDb::get_count( $table_join, $where );
442
-        } else {
440
+		if ( is_array( $where ) ) {
441
+			$count = FrmDb::get_count( $table_join, $where );
442
+		} else {
443 443
 			$cache_key = 'count_' . maybe_serialize( $where );
444 444
 			$query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
445 445
 			$count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' );
446
-        }
446
+		}
447 447
 
448
-        return $count;
449
-    }
448
+		return $count;
449
+	}
450 450
 
451
-    public static function getPageCount( $p_size, $where = '' ) {
451
+	public static function getPageCount( $p_size, $where = '' ) {
452 452
 		$p_size = (int) $p_size;
453 453
 		$count = 1;
454 454
 		if ( $p_size ) {
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 		}
460 460
 
461 461
 		return $count;
462
-    }
462
+	}
463 463
 
464 464
 	/**
465
-	* Prepare the data before inserting it into the database
466
-	*
467
-	* @since 2.0.16
468
-	* @param array $values
469
-	* @param string $type
470
-	* @return array $new_values
471
-	*/
465
+	 * Prepare the data before inserting it into the database
466
+	 *
467
+	 * @since 2.0.16
468
+	 * @param array $values
469
+	 * @param string $type
470
+	 * @return array $new_values
471
+	 */
472 472
 	private static function before_insert_entry_in_database( &$values, $type ) {
473 473
 
474 474
 		self::sanitize_entry_post( $values );
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Create an entry and perform after create actions
487
-	*
488
-	* @since 2.0.16
489
-	* @param array $values
490
-	* @param array $new_values
491
-	* @return boolean|int $entry_id
492
-	*/
486
+	 * Create an entry and perform after create actions
487
+	 *
488
+	 * @since 2.0.16
489
+	 * @param array $values
490
+	 * @param array $new_values
491
+	 * @return boolean|int $entry_id
492
+	 */
493 493
 	private static function continue_to_create_entry( $values, $new_values ) {
494 494
 		$entry_id = self::insert_entry_into_database( $new_values );
495 495
 		if ( ! $entry_id ) {
@@ -501,37 +501,37 @@  discard block
 block discarded – undo
501 501
 		return $entry_id;
502 502
 	}
503 503
 
504
-    /**
505
-     * Sanitize the POST values before we use them
506
-     *
507
-     * @since 2.0
508
-     * @param array $values The POST values by reference
509
-     */
510
-    public static function sanitize_entry_post( &$values ) {
511
-        $sanitize_method = array(
512
-            'form_id'       => 'absint',
513
-            'frm_action'    => 'sanitize_title',
514
-            'form_key'      => 'sanitize_title',
515
-            'item_key'      => 'sanitize_title',
516
-            'item_name'     => 'sanitize_text_field',
517
-            'frm_saving_draft' => 'absint',
518
-            'is_draft'      => 'absint',
519
-            'post_id'       => 'absint',
520
-            'parent_item_id' => 'absint',
521
-            'created_at'    => 'sanitize_text_field',
522
-            'updated_at'    => 'sanitize_text_field',
523
-        );
524
-
525
-        FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
-    }
527
-
528
-	/**
529
-	* Prepare the new values for inserting into the database
530
-	*
531
-	* @since 2.0.16
532
-	* @param array $values
533
-	* @return array $new_values
534
-	*/
504
+	/**
505
+	 * Sanitize the POST values before we use them
506
+	 *
507
+	 * @since 2.0
508
+	 * @param array $values The POST values by reference
509
+	 */
510
+	public static function sanitize_entry_post( &$values ) {
511
+		$sanitize_method = array(
512
+			'form_id'       => 'absint',
513
+			'frm_action'    => 'sanitize_title',
514
+			'form_key'      => 'sanitize_title',
515
+			'item_key'      => 'sanitize_title',
516
+			'item_name'     => 'sanitize_text_field',
517
+			'frm_saving_draft' => 'absint',
518
+			'is_draft'      => 'absint',
519
+			'post_id'       => 'absint',
520
+			'parent_item_id' => 'absint',
521
+			'created_at'    => 'sanitize_text_field',
522
+			'updated_at'    => 'sanitize_text_field',
523
+		);
524
+
525
+		FrmAppHelper::sanitize_request( $sanitize_method, $values );
526
+	}
527
+
528
+	/**
529
+	 * Prepare the new values for inserting into the database
530
+	 *
531
+	 * @since 2.0.16
532
+	 * @param array $values
533
+	 * @return array $new_values
534
+	 */
535 535
 	private static function package_entry_data( &$values ) {
536 536
 		global $wpdb;
537 537
 
@@ -564,67 +564,67 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Get the is_draft value for a new entry
568
-	*
569
-	* @since 2.0.16
570
-	* @param array $values
571
-	* @return int
572
-	*/
567
+	 * Get the is_draft value for a new entry
568
+	 *
569
+	 * @since 2.0.16
570
+	 * @param array $values
571
+	 * @return int
572
+	 */
573 573
 	private static function get_is_draft_value( $values ) {
574 574
 		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
575 575
 	}
576 576
 
577 577
 	/**
578
-	* Get the form_id value for a new entry
579
-	*
580
-	* @since 2.0.16
581
-	* @param array $values
582
-	* @return int|null
583
-	*/
578
+	 * Get the form_id value for a new entry
579
+	 *
580
+	 * @since 2.0.16
581
+	 * @param array $values
582
+	 * @return int|null
583
+	 */
584 584
 	private static function get_form_id( $values ) {
585 585
 		return isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
586 586
 	}
587 587
 
588 588
 	/**
589
-	* Get the post_id value for a new entry
590
-	*
591
-	* @since 2.0.16
592
-	* @param array $values
593
-	* @return int
594
-	*/
589
+	 * Get the post_id value for a new entry
590
+	 *
591
+	 * @since 2.0.16
592
+	 * @param array $values
593
+	 * @return int
594
+	 */
595 595
 	private static function get_post_id( $values ) {
596 596
 		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
597 597
 	}
598 598
 
599 599
 	/**
600
-	* Get the parent_item_id value for a new entry
601
-	*
602
-	* @since 2.0.16
603
-	* @param array $values
604
-	* @return int
605
-	*/
600
+	 * Get the parent_item_id value for a new entry
601
+	 *
602
+	 * @since 2.0.16
603
+	 * @param array $values
604
+	 * @return int
605
+	 */
606 606
 	private static function get_parent_item_id( $values ) {
607 607
 		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
608 608
 	}
609 609
 
610 610
 	/**
611
-	* Get the created_at value for a new entry
612
-	*
613
-	* @since 2.0.16
614
-	* @param array $values
615
-	* @return string
616
-	*/
611
+	 * Get the created_at value for a new entry
612
+	 *
613
+	 * @since 2.0.16
614
+	 * @param array $values
615
+	 * @return string
616
+	 */
617 617
 	private static function get_created_at( $values ) {
618 618
 		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
619 619
 	}
620 620
 
621 621
 	/**
622
-	* Get the updated_at value for a new entry
623
-	*
624
-	* @since 2.0.16
625
-	* @param array $values
626
-	* @return string
627
-	*/
622
+	 * Get the updated_at value for a new entry
623
+	 *
624
+	 * @since 2.0.16
625
+	 * @param array $values
626
+	 * @return string
627
+	 */
628 628
 	private static function get_updated_at( $values ) {
629 629
 		if ( isset( $values['updated_at'] ) ) {
630 630
 			$updated_at = $values['updated_at'];
@@ -636,12 +636,12 @@  discard block
 block discarded – undo
636 636
 	}
637 637
 
638 638
 	/**
639
-	* Get the description value for a new entry
640
-	*
641
-	* @since 2.0.16
642
-	* @param array $values
643
-	* @return string
644
-	*/
639
+	 * Get the description value for a new entry
640
+	 *
641
+	 * @since 2.0.16
642
+	 * @param array $values
643
+	 * @return string
644
+	 */
645 645
 	private static function get_entry_description( $values ) {
646 646
 		if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) {
647 647
 			$description = maybe_serialize( $values['description'] );
@@ -656,12 +656,12 @@  discard block
 block discarded – undo
656 656
 	}
657 657
 
658 658
 	/**
659
-	* Get the user_id value for a new entry
660
-	*
661
-	* @since 2.0.16
662
-	* @param array $values
663
-	* @return int
664
-	*/
659
+	 * Get the user_id value for a new entry
660
+	 *
661
+	 * @since 2.0.16
662
+	 * @param array $values
663
+	 * @return int
664
+	 */
665 665
 	private static function get_entry_user_id( $values ) {
666 666
 		if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) {
667 667
 			$user_id = $values['frm_user_id'];
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
 	}
675 675
 
676 676
 	/**
677
-	* Insert new entry into the database
678
-	*
679
-	* @since 2.0.16
680
-	* @param array $new_values
681
-	* @return int | boolean $entry_id
682
-	*/
677
+	 * Insert new entry into the database
678
+	 *
679
+	 * @since 2.0.16
680
+	 * @param array $new_values
681
+	 * @return int | boolean $entry_id
682
+	 */
683 683
 	private static function insert_entry_into_database( $new_values ) {
684 684
 		global $wpdb;
685 685
 
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 	}
696 696
 
697 697
 	/**
698
-	* Add the new entry to global $frm_vars
699
-	*
700
-	* @since 2.0.16
701
-	* @param int $entry_id
702
-	*/
698
+	 * Add the new entry to global $frm_vars
699
+	 *
700
+	 * @since 2.0.16
701
+	 * @param int $entry_id
702
+	 */
703 703
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
704 704
 		global $frm_vars;
705 705
 
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
 	}
712 712
 
713 713
 	/**
714
-	* Add entry metas, if there are any
715
-	*
716
-	* @since 2.0.16
717
-	* @param array $values
718
-	* @param int $entry_id
719
-	*/
714
+	 * Add entry metas, if there are any
715
+	 *
716
+	 * @since 2.0.16
717
+	 * @param array $values
718
+	 * @param int $entry_id
719
+	 */
720 720
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
721 721
 		if ( isset($values['item_meta']) ) {
722 722
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
@@ -724,12 +724,12 @@  discard block
 block discarded – undo
724 724
 	}
725 725
 
726 726
 	/**
727
-	* Trigger frm_after_create_entry hooks
728
-	*
729
-	* @since 2.0.16
730
-	* @param int $entry_id
731
-	* @param array $new_values
732
-	*/
727
+	 * Trigger frm_after_create_entry hooks
728
+	 *
729
+	 * @since 2.0.16
730
+	 * @param int $entry_id
731
+	 * @param array $new_values
732
+	 */
733 733
 	private static function after_entry_created_actions( $entry_id, $values, $new_values ) {
734 734
 		// this is a child entry
735 735
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 	}
740 740
 
741 741
 	/**
742
-	* Actions to perform immediately after an entry is inserted in the frm_items database
743
-	*
744
-	* @since 2.0.16
745
-	* @param array $values
746
-	* @param array $new_values
747
-	* @param int $entry_id
748
-	*/
742
+	 * Actions to perform immediately after an entry is inserted in the frm_items database
743
+	 *
744
+	 * @since 2.0.16
745
+	 * @param array $values
746
+	 * @param array $new_values
747
+	 * @param int $entry_id
748
+	 */
749 749
 	private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) {
750 750
 
751 751
 		self::add_new_entry_to_frm_vars( $entry_id );
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 	}
759 759
 
760 760
 	/**
761
-	* Perform some actions right before updating an entry
762
-	*
763
-	* @since 2.0.16
764
-	* @param int $id
765
-	* @param array $values
766
-	* @param string $update_type
767
-	* @return boolean $update
768
-	*/
761
+	 * Perform some actions right before updating an entry
762
+	 *
763
+	 * @since 2.0.16
764
+	 * @param int $id
765
+	 * @param array $values
766
+	 * @param string $update_type
767
+	 * @return boolean $update
768
+	 */
769 769
 	private static function before_update_entry( $id, &$values, $update_type ) {
770 770
 		$update = true;
771 771
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	}
784 784
 
785 785
 	/**
786
-	* Package the entry data for updating
787
-	*
788
-	* @since 2.0.16
789
-	* @param int $id
790
-	* @param array $values
791
-	* @return array $new_values
792
-	*/
786
+	 * Package the entry data for updating
787
+	 *
788
+	 * @since 2.0.16
789
+	 * @param int $id
790
+	 * @param array $values
791
+	 * @return array $new_values
792
+	 */
793 793
 	private static function package_entry_to_update( $id, $values ) {
794 794
 		global $wpdb;
795 795
 
@@ -823,14 +823,14 @@  discard block
 block discarded – undo
823 823
 	}
824 824
 
825 825
 	/**
826
-	* Perform some actions right after updating an entry
827
-	*
828
-	* @since 2.0.16
829
-	* @param boolean|int $query_results
830
-	* @param int $id
831
-	* @param array $values
832
-	* @param array $new_values
833
-	*/
826
+	 * Perform some actions right after updating an entry
827
+	 *
828
+	 * @since 2.0.16
829
+	 * @param boolean|int $query_results
830
+	 * @param int $id
831
+	 * @param array $values
832
+	 * @param array $new_values
833
+	 */
834 834
 	private static function after_update_entry( $query_results, $id, $values, $new_values ) {
835 835
 		if ( $query_results ) {
836 836
 			self::clear_cache();
@@ -852,13 +852,13 @@  discard block
 block discarded – undo
852 852
 	}
853 853
 
854 854
 	/**
855
-	* Create entry from an XML import
856
-	* Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
857
-	*
858
-	* @since 2.0.16
859
-	* @param array $values
860
-	* @return int | boolean $entry_id
861
-	*/
855
+	 * Create entry from an XML import
856
+	 * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.)
857
+	 *
858
+	 * @since 2.0.16
859
+	 * @param array $values
860
+	 * @return int | boolean $entry_id
861
+	 */
862 862
 	public static function create_entry_from_xml( $values ) {
863 863
 		$entry_id = self::create_entry( $values, 'xml' );
864 864
 
@@ -866,28 +866,28 @@  discard block
 block discarded – undo
866 866
 	}
867 867
 
868 868
 	/**
869
-	* Update entry from an XML import
870
-	* Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
871
-	*
872
-	* @since 2.0.16
873
-	* @param int $id
874
-	* @param array $values
875
-	* @return int | boolean $updated
876
-	*/
869
+	 * Update entry from an XML import
870
+	 * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals)
871
+	 *
872
+	 * @since 2.0.16
873
+	 * @param int $id
874
+	 * @param array $values
875
+	 * @return int | boolean $updated
876
+	 */
877 877
 	public static function update_entry_from_xml( $id, $values ) {
878 878
 		$updated = self::update_entry( $id, $values, 'xml' );
879 879
 
880 880
 		return $updated;
881 881
 	}
882 882
 
883
-    /**
884
-     * @param string $key
885
-     * @return int entry_id
886
-     */
883
+	/**
884
+	 * @param string $key
885
+	 * @return int entry_id
886
+	 */
887 887
 	public static function get_id_by_key( $key ) {
888
-        $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
889
-        return $entry_id;
890
-    }
888
+		$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
889
+		return $entry_id;
890
+	}
891 891
 
892 892
 	public static function validate( $values, $exclude = false ) {
893 893
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' );
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 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
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
56 56
 
57 57
         if ( $new_values['item_key'] == $new_values['name'] ) {
58
-            unset($check_val['name']);
58
+            unset( $check_val['name'] );
59 59
         }
60 60
 
61 61
         global $wpdb;
62 62
 		$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
63 63
 
64
-        if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
64
+        if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) {
65 65
             return false;
66 66
         }
67 67
 
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
             $is_duplicate = true;
71 71
 
72 72
             //add more checks here to make sure it's a duplicate
73
-            $metas = FrmEntryMeta::get_entry_meta_info($entry_exist);
73
+            $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist );
74 74
             $field_metas = array();
75 75
             foreach ( $metas as $meta ) {
76
-				$field_metas[ $meta->field_id ] = $meta->meta_value;
76
+				$field_metas[$meta->field_id] = $meta->meta_value;
77 77
             }
78 78
 
79 79
             // If prev entry is empty and current entry is not, they are not duplicates
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 return false;
83 83
             }
84 84
 
85
-            $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta']));
85
+            $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) );
86 86
             foreach ( $diff as $field_id => $meta_value ) {
87
-                if ( ! empty($meta_value) ) {
87
+                if ( ! empty( $meta_value ) ) {
88 88
                     $is_duplicate = false;
89 89
                     continue;
90 90
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 
115 115
 		// If CSV is importing, don't check for duplicates
116
-		if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
116
+		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
         $new_values['name'] = $values->name;
136 136
         $new_values['is_draft'] = $values->is_draft;
137 137
         $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id;
138
-        $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null;
139
-        $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1);
138
+        $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null;
139
+        $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 );
140 140
 
141 141
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values );
142 142
         if ( ! $query_results ) {
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
         $entry_id = $wpdb->insert_id;
147 147
 
148 148
         global $frm_vars;
149
-        if ( ! isset($frm_vars['saved_entries']) ) {
149
+        if ( ! isset( $frm_vars['saved_entries'] ) ) {
150 150
             $frm_vars['saved_entries'] = array();
151 151
         }
152 152
         $frm_vars['saved_entries'][] = (int) $entry_id;
153 153
 
154
-        FrmEntryMeta::duplicate_entry_metas($id, $entry_id);
154
+        FrmEntryMeta::duplicate_entry_metas( $id, $entry_id );
155 155
 		self::clear_cache();
156 156
 
157 157
 		do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) );
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
 		$new_values = self::package_entry_to_update( $id, $values );
192 192
 
193
-		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') );
193
+		$query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) );
194 194
 
195 195
 		self::after_update_entry( $query_results, $id, $values, $new_values );
196 196
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             return $result;
208 208
         }
209 209
 
210
-        do_action('frm_before_destroy_entry', $id, $entry);
210
+        do_action( 'frm_before_destroy_entry', $id, $entry );
211 211
 
212 212
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
213 213
 		$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 	public static function &update_form( $id, $value, $form_id ) {
221 221
         global $wpdb;
222
-        $form_id = isset($value) ? $form_id : null;
222
+        $form_id = isset( $value ) ? $form_id : null;
223 223
 		$result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) );
224 224
 		if ( $result ) {
225 225
 			self::clear_cache();
@@ -266,24 +266,24 @@  discard block
 block discarded – undo
266 266
         $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it
267 267
                   LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE ";
268 268
 
269
-        $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s';
269
+        $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s';
270 270
         $query_args = array( $id );
271 271
         $query = $wpdb->prepare( $query, $query_args );
272 272
 
273 273
         if ( ! $meta ) {
274 274
 			$entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' );
275
-            return stripslashes_deep($entry);
275
+            return stripslashes_deep( $entry );
276 276
         }
277 277
 
278 278
         $entry = FrmAppHelper::check_cache( $id, 'frm_entry' );
279 279
         if ( $entry !== false ) {
280
-            return stripslashes_deep($entry);
280
+            return stripslashes_deep( $entry );
281 281
         }
282 282
 
283 283
         $entry = $wpdb->get_row( $query );
284
-        $entry = self::get_meta($entry);
284
+        $entry = self::get_meta( $entry );
285 285
 
286
-        return stripslashes_deep($entry);
286
+        return stripslashes_deep( $entry );
287 287
     }
288 288
 
289 289
 	public static function get_meta( $entry ) {
@@ -299,25 +299,25 @@  discard block
 block discarded – undo
299 299
 		$include_key = apply_filters( 'frm_include_meta_keys', false );
300 300
         foreach ( $metas as $meta_val ) {
301 301
             if ( $meta_val->item_id == $entry->id ) {
302
-				$entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
302
+				$entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
303 303
 				if ( $include_key ) {
304
-					$entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ];
304
+					$entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id];
305 305
 				}
306 306
                  continue;
307 307
             }
308 308
 
309 309
             // include sub entries in an array
310
-			if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) {
311
-				$entry->metas[ $meta_val->field_id ] = array();
310
+			if ( ! isset( $entry_metas[$meta_val->field_id] ) ) {
311
+				$entry->metas[$meta_val->field_id] = array();
312 312
             }
313 313
 
314
-			$entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value );
314
+			$entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value );
315 315
 
316
-            unset($meta_val);
316
+            unset( $meta_val );
317 317
         }
318
-        unset($metas);
318
+        unset( $metas );
319 319
 
320
-        wp_cache_set( $entry->id, $entry, 'frm_entry');
320
+        wp_cache_set( $entry->id, $entry, 'frm_entry' );
321 321
 
322 322
         return $entry;
323 323
     }
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
             return $exists;
334 334
         }
335 335
 
336
-        if ( is_numeric($id) ) {
336
+        if ( is_numeric( $id ) ) {
337 337
             $where = array( 'id' => $id );
338 338
         } else {
339 339
             $where = array( 'item_key' => $id );
340 340
         }
341 341
 		$id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where );
342 342
 
343
-        $exists = ($id && $id > 0) ? true : false;
343
+        $exists = ( $id && $id > 0 ) ? true : false;
344 344
         return $exists;
345 345
     }
346 346
 
347 347
     public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) {
348 348
 		global $wpdb;
349 349
 
350
-        $limit = FrmAppHelper::esc_limit($limit);
350
+        $limit = FrmAppHelper::esc_limit( $limit );
351 351
 
352
-        $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form;
353
-        $entries = wp_cache_get($cache_key, 'frm_entry');
352
+        $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form;
353
+        $entries = wp_cache_get( $cache_key, 'frm_entry' );
354 354
 
355 355
         if ( false === $entries ) {
356 356
             $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft';
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 		    }
370 370
 
371 371
 			// prepare the query
372
-			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
372
+			$query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
373 373
 
374
-            $entries = $wpdb->get_results($query, OBJECT_K);
375
-            unset($query);
374
+            $entries = $wpdb->get_results( $query, OBJECT_K );
375
+            unset( $query );
376 376
 
377 377
 			if ( ! FrmAppHelper::prevent_caching() ) {
378 378
 				wp_cache_set( $cache_key, $entries, 'frm_entry', 300 );
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
         }
381 381
 
382 382
         if ( ! $meta || ! $entries ) {
383
-            return stripslashes_deep($entries);
383
+            return stripslashes_deep( $entries );
384 384
         }
385
-        unset($meta);
385
+        unset( $meta );
386 386
 
387
-        if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) {
387
+        if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) {
388 388
 			$where = array( 'it.form_id' => substr( $where, 11 ) );
389 389
         }
390 390
 
391 391
         $meta_where = array( 'field_id !' => 0 );
392
-        if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) {
392
+        if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) {
393 393
             $meta_where['fi.form_id'] = $where['it.form_id'];
394 394
         } else {
395 395
             $meta_where['item_id'] = array_keys( $entries );
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
         unset( $meta_where );
401 401
 
402 402
         if ( ! $metas ) {
403
-            return stripslashes_deep($entries);
403
+            return stripslashes_deep( $entries );
404 404
         }
405 405
 
406 406
         foreach ( $metas as $m_key => $meta_val ) {
407
-            if ( ! isset( $entries[ $meta_val->item_id ] ) ) {
407
+            if ( ! isset( $entries[$meta_val->item_id] ) ) {
408 408
                 continue;
409 409
             }
410 410
 
411
-            if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) {
412
-				$entries[ $meta_val->item_id ]->metas = array();
411
+            if ( ! isset( $entries[$meta_val->item_id]->metas ) ) {
412
+				$entries[$meta_val->item_id]->metas = array();
413 413
             }
414 414
 
415
-			$entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value );
415
+			$entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value );
416 416
 
417
-            unset($m_key, $meta_val);
417
+            unset( $m_key, $meta_val );
418 418
         }
419 419
 
420 420
 		if ( ! FrmAppHelper::prevent_caching() ) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 		}
426 426
 
427
-        return stripslashes_deep($entries);
427
+        return stripslashes_deep( $entries );
428 428
     }
429 429
 
430 430
     // Pagination Methods
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         global $wpdb;
433 433
 		$table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id';
434 434
 
435
-        if ( is_numeric($where) ) {
435
+        if ( is_numeric( $where ) ) {
436 436
             $table_join = 'frm_items';
437 437
             $where = array( 'form_id' => $where );
438 438
         }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		self::sanitize_entry_post( $values );
475 475
 
476 476
 		if ( $type != 'xml' ) {
477
-			$values = apply_filters('frm_pre_create_entry', $values);
477
+			$values = apply_filters( 'frm_pre_create_entry', $values );
478 478
 		}
479 479
 
480 480
 		$new_values = self::package_entry_data( $values );
@@ -554,11 +554,11 @@  discard block
 block discarded – undo
554 554
 			'user_id' => self::get_entry_user_id( $values ),
555 555
 		);
556 556
 
557
-		if ( is_array($new_values['name']) ) {
558
-			$new_values['name'] = reset($new_values['name']);
557
+		if ( is_array( $new_values['name'] ) ) {
558
+			$new_values['name'] = reset( $new_values['name'] );
559 559
 		}
560 560
 
561
-		$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
561
+		$new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id'];
562 562
 
563 563
 		return $new_values;
564 564
 	}
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	* @return int
572 572
 	*/
573 573
 	private static function get_is_draft_value( $values ) {
574
-		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) ||  ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
574
+		return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0;
575 575
 	}
576 576
 
577 577
 	/**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	* @return int
594 594
 	*/
595 595
 	private static function get_post_id( $values ) {
596
-		return isset( $values['post_id'] ) ? (int) $values['post_id']: 0;
596
+		return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0;
597 597
 	}
598 598
 
599 599
 	/**
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	* @return int
605 605
 	*/
606 606
 	private static function get_parent_item_id( $values ) {
607
-		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0;
607
+		return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0;
608 608
 	}
609 609
 
610 610
 	/**
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	* @return string
616 616
 	*/
617 617
 	private static function get_created_at( $values ) {
618
-		return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1);
618
+		return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 );
619 619
 	}
620 620
 
621 621
 	/**
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	private static function add_new_entry_to_frm_vars( $entry_id ) {
704 704
 		global $frm_vars;
705 705
 
706
-		if ( ! isset($frm_vars['saved_entries']) ) {
706
+		if ( ! isset( $frm_vars['saved_entries'] ) ) {
707 707
 			$frm_vars['saved_entries'] = array();
708 708
 		}
709 709
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	* @param int $entry_id
719 719
 	*/
720 720
 	private static function maybe_add_entry_metas( $values, $entry_id ) {
721
-		if ( isset($values['item_meta']) ) {
721
+		if ( isset( $values['item_meta'] ) ) {
722 722
 			FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] );
723 723
 		}
724 724
 	}
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 		$is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' );
736 736
 
737 737
 		do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) );
738
-		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) );
738
+		do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) );
739 739
 	}
740 740
 
741 741
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		}
777 777
 
778 778
 		if ( $update && $update_type != 'xml' ) {
779
-			$values = apply_filters('frm_pre_update_entry', $values, $id);
779
+			$values = apply_filters( 'frm_pre_update_entry', $values, $id );
780 780
 		}
781 781
 
782 782
 		return $update;
@@ -797,27 +797,27 @@  discard block
 block discarded – undo
797 797
 			'name'      => self::get_new_entry_name( $values ),
798 798
 			'form_id'   => self::get_form_id( $values ),
799 799
 			'is_draft'  => self::get_is_draft_value( $values ),
800
-			'updated_at' => current_time('mysql', 1),
801
-			'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(),
800
+			'updated_at' => current_time( 'mysql', 1 ),
801
+			'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(),
802 802
 		);
803 803
 
804
-		if ( isset($values['post_id']) ) {
804
+		if ( isset( $values['post_id'] ) ) {
805 805
 			$new_values['post_id'] = (int) $values['post_id'];
806 806
 		}
807 807
 
808
-		if ( isset($values['item_key']) ) {
808
+		if ( isset( $values['item_key'] ) ) {
809 809
 			$new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id );
810 810
 		}
811 811
 
812
-		if ( isset($values['parent_item_id']) ) {
812
+		if ( isset( $values['parent_item_id'] ) ) {
813 813
 			$new_values['parent_item_id'] = (int) $values['parent_item_id'];
814 814
 		}
815 815
 
816
-		if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) {
816
+		if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) {
817 817
 			$new_values['user_id'] = $values['frm_user_id'];
818 818
 		}
819 819
 
820
-		$new_values = apply_filters('frm_update_entry', $new_values, $id);
820
+		$new_values = apply_filters( 'frm_update_entry', $new_values, $id );
821 821
 
822 822
 		return $new_values;
823 823
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +431 added lines, -431 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,143 +139,143 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166 166
 		$values = array();
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
173
+		$values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
176
-            wp_die();
177
-        }
175
+		if ( ! $field_id = FrmField::create($values) ) {
176
+			wp_die();
177
+		}
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+		self::include_single_field($field_id, $values);
180 180
 
181
-        wp_die();
182
-    }
181
+		wp_die();
182
+	}
183 183
 
184
-    /**
185
-     * Load a single field in the form builder along with all needed variables
186
-     */
187
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
184
+	/**
185
+	 * Load a single field in the form builder along with all needed variables
186
+	 */
187
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
-        $id = $form_id ? $form_id : $field['form_id'];
192
-        if ( $field['type'] == 'html' ) {
193
-            $field['stop_filter'] = true;
194
-        }
190
+		$html_id = FrmFieldsHelper::get_html_id($field);
191
+		$id = $form_id ? $form_id : $field['form_id'];
192
+		if ( $field['type'] == 'html' ) {
193
+			$field['stop_filter'] = true;
194
+		}
195 195
 
196 196
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
197 197
 
198
-        return $field;
199
-    }
198
+		return $field;
199
+	}
200 200
 
201
-    public static function destroy() {
201
+	public static function destroy() {
202 202
 		FrmAppHelper::permission_check('frm_edit_forms');
203
-        check_ajax_referer( 'frm_ajax', 'nonce' );
203
+		check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
206 206
 		FrmField::destroy( $field_id );
207
-        wp_die();
208
-    }
207
+		wp_die();
208
+	}
209 209
 
210
-    /* Field Options */
210
+	/* Field Options */
211 211
 
212
-    //Add Single Option or Other Option
213
-    public static function add_option() {
212
+	//Add Single Option or Other Option
213
+	public static function add_option() {
214 214
 		FrmAppHelper::permission_check('frm_edit_forms');
215
-        check_ajax_referer( 'frm_ajax', 'nonce' );
215
+		check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220
-        //Get the field
221
-        $field = FrmField::getOne($id);
220
+		//Get the field
221
+		$field = FrmField::getOne($id);
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
225
-            $last = str_replace( 'other_', '', end( $keys ) );
226
-        } else {
227
-            $last = 0;
228
-        }
229
-        $opt_key = $last + 1;
225
+			$last = str_replace( 'other_', '', end( $keys ) );
226
+		} else {
227
+			$last = 0;
228
+		}
229
+		$opt_key = $last + 1;
230 230
 
231
-        if ( 'other' == $opt_type ) {
231
+		if ( 'other' == $opt_type ) {
232 232
 			$opt = esc_html__( 'Other', 'formidable' );
233
-            $other_val = '';
234
-            $opt_key = 'other_' . $opt_key;
235
-
236
-            //Update value of "other" in DB
237
-            $field_options = maybe_unserialize( $field->field_options );
238
-            $field_options['other'] = 1;
239
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
-        } else {
233
+			$other_val = '';
234
+			$opt_key = 'other_' . $opt_key;
235
+
236
+			//Update value of "other" in DB
237
+			$field_options = maybe_unserialize( $field->field_options );
238
+			$field_options['other'] = 1;
239
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
+		} else {
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243
-            if ( $first_opt != '' ) {
244
-                $next_opt++;
245
-            }
243
+			if ( $first_opt != '' ) {
244
+				$next_opt++;
245
+			}
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
248
-        }
249
-        $field_val = $opt;
247
+			unset($next_opt);
248
+		}
249
+		$field_val = $opt;
250 250
 		$field->options[ $opt_key ] = $opt;
251 251
 
252
-        //Update options in DB
252
+		//Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
254 254
 
255
-        $field_data = $field;
256
-        $field = array(
257
-            'type'  => $field_data->type,
258
-            'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
-            'form_id' => $field_data->form_id,
261
-            'field_key' => $field_data->field_key,
262
-        );
255
+		$field_data = $field;
256
+		$field = array(
257
+			'type'  => $field_data->type,
258
+			'id'    => $id,
259
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+			'form_id' => $field_data->form_id,
261
+			'field_key' => $field_data->field_key,
262
+		);
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
-        $checked = '';
265
+		$html_id = FrmFieldsHelper::get_html_id($field);
266
+		$checked = '';
267 267
 
268
-        if ( 'other' == $opt_type ) {
268
+		if ( 'other' == $opt_type ) {
269 269
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
270
-        } else {
270
+		} else {
271 271
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
272
-        }
273
-        wp_die();
274
-    }
272
+		}
273
+		wp_die();
274
+	}
275 275
 
276
-    public static function edit_option() {
276
+	public static function edit_option() {
277 277
 		FrmAppHelper::permission_check('frm_edit_forms');
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
281 281
 		$ids = explode( '-', $element_id );
@@ -283,43 +283,43 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
285 285
 		if ( strpos( $element_id, 'key_' ) ) {
286
-            $new_value = $update_value;
287
-        } else {
288
-            $new_label = $update_value;
289
-        }
286
+			$new_value = $update_value;
287
+		} else {
288
+			$new_label = $update_value;
289
+		}
290 290
 
291
-        $field = FrmField::getOne($id);
292
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
291
+		$field = FrmField::getOne($id);
292
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
294
+		$this_opt_id = end($ids);
295 295
 		$this_opt = (array) $field->options[ $this_opt_id ];
296 296
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
300 300
 
301
-        if ( ! isset( $new_label ) ) {
302
-            $new_label = $label;
303
-        }
301
+		if ( ! isset( $new_label ) ) {
302
+			$new_label = $label;
303
+		}
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
307
-        }
305
+		if ( isset($new_value) || isset($value) ) {
306
+			$update_value = isset($new_value) ? $new_value : $value;
307
+		}
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310 310
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
-        } else {
311
+		} else {
312 312
 			$field->options[ $this_opt_id ] = $orig_update_value;
313
-        }
313
+		}
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
316 316
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
317
-        wp_die();
318
-    }
317
+		wp_die();
318
+	}
319 319
 
320
-    public static function delete_option() {
320
+	public static function delete_option() {
321 321
 		FrmAppHelper::permission_check('frm_edit_forms');
322
-        check_ajax_referer( 'frm_ajax', 'nonce' );
322
+		check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
325 325
 		$field = FrmField::getOne( $field_id );
@@ -327,313 +327,313 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
331
-        $response = array( 'other' => true );
330
+		unset( $options[ $opt_key ] );
331
+		$response = array( 'other' => true );
332 332
 
333
-        //If the deleted option is an "other" option
333
+		//If the deleted option is an "other" option
334 334
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
335
-            //Assume all other options are gone, unless proven otherwise
336
-            $other = false;
335
+			//Assume all other options are gone, unless proven otherwise
336
+			$other = false;
337 337
 
338
-            //Check if all other options are really gone
339
-            foreach ( $options as $o_key => $o_val ) {
340
-                //If there is still an other option in the field, set other to true
338
+			//Check if all other options are really gone
339
+			foreach ( $options as $o_key => $o_val ) {
340
+				//If there is still an other option in the field, set other to true
341 341
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
342
-                    $other = true;
343
-                    break;
344
-                }
345
-                unset( $o_key, $o_val );
346
-            }
347
-
348
-            //If all other options are gone
349
-            if ( false === $other ) {
350
-                $field_options = maybe_unserialize( $field->field_options );
351
-                $field_options['other'] = 0;
342
+					$other = true;
343
+					break;
344
+				}
345
+				unset( $o_key, $o_val );
346
+			}
347
+
348
+			//If all other options are gone
349
+			if ( false === $other ) {
350
+				$field_options = maybe_unserialize( $field->field_options );
351
+				$field_options['other'] = 0;
352 352
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
353
-                $response = array( 'other' => false );
354
-            }
355
-        }
356
-        echo json_encode( $response );
353
+				$response = array( 'other' => false );
354
+			}
355
+		}
356
+		echo json_encode( $response );
357 357
 
358 358
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
359 359
 
360
-        wp_die();
361
-    }
360
+		wp_die();
361
+	}
362 362
 
363
-    public static function import_choices() {
364
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
363
+	public static function import_choices() {
364
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
365 365
 
366 366
 		$field_id = absint( $_REQUEST['field_id'] );
367 367
 
368
-        global $current_screen, $hook_suffix;
368
+		global $current_screen, $hook_suffix;
369 369
 
370
-        // Catch plugins that include admin-header.php before admin.php completes.
371
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
-            $hook_suffix = '';
373
-        	set_current_screen();
374
-        }
370
+		// Catch plugins that include admin-header.php before admin.php completes.
371
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
+			$hook_suffix = '';
373
+			set_current_screen();
374
+		}
375 375
 
376
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
377
-            register_admin_color_schemes();
378
-        }
376
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
377
+			register_admin_color_schemes();
378
+		}
379 379
 
380
-        $hook_suffix = $admin_body_class = '';
380
+		$hook_suffix = $admin_body_class = '';
381 381
 
382
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
383
-        	$admin_body_class .= ' folded';
384
-        }
382
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
383
+			$admin_body_class .= ' folded';
384
+		}
385 385
 
386
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
-        	$admin_body_class .= ' admin-bar';
388
-        }
386
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
+			$admin_body_class .= ' admin-bar';
388
+		}
389 389
 
390
-        if ( is_rtl() ) {
391
-        	$admin_body_class .= ' rtl';
392
-        }
390
+		if ( is_rtl() ) {
391
+			$admin_body_class .= ' rtl';
392
+		}
393 393
 
394
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
-        $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
394
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
+		$prepop = array();
396
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+		$field = FrmField::getOne($field_id);
399 399
 
400
-        wp_enqueue_script( 'utils' );
400
+		wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
402
-        FrmAppHelper::load_admin_wide_js();
402
+		FrmAppHelper::load_admin_wide_js();
403 403
 
404 404
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
405
-        wp_die();
406
-    }
405
+		wp_die();
406
+	}
407 407
 
408
-    public static function import_options() {
408
+	public static function import_options() {
409 409
 		FrmAppHelper::permission_check('frm_edit_forms');
410
-        check_ajax_referer( 'frm_ajax', 'nonce' );
410
+		check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
-            return;
414
-        }
412
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+			return;
414
+		}
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+		$field = FrmField::getOne($field_id);
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420
-            return;
421
-        }
420
+			return;
421
+		}
422 422
 
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
423
+		$field = FrmFieldsHelper::setup_edit_vars($field);
424 424
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
425 425
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
426 426
 		$opts = array_map( 'trim', $opts );
427 427
 
428
-        if ( $field['separate_value'] ) {
429
-            foreach ( $opts as $opt_key => $opt ) {
430
-                if ( strpos($opt, '|') !== false ) {
431
-                    $vals = explode('|', $opt);
432
-                    if ( $vals[0] != $vals[1] ) {
433
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
-                    }
435
-                    unset($vals);
436
-                }
437
-                unset($opt_key, $opt);
438
-            }
439
-        }
440
-
441
-        //Keep other options after bulk update
442
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
-            $other_array = array();
444
-            foreach ( $field['options'] as $opt_key => $opt ) {
445
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
-                    $other_array[ $opt_key ] = $opt;
447
-                }
448
-                unset($opt_key, $opt);
449
-            }
450
-            if ( ! empty($other_array) ) {
451
-                $opts = array_merge( $opts, $other_array);
452
-            }
453
-        }
454
-
455
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
-
457
-        $field['options'] = $opts;
458
-        $field_name = $field['name'];
459
-
460
-        // Get html_id which will be used in single-option.php
461
-        $html_id = FrmFieldsHelper::get_html_id( $field );
462
-
463
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
428
+		if ( $field['separate_value'] ) {
429
+			foreach ( $opts as $opt_key => $opt ) {
430
+				if ( strpos($opt, '|') !== false ) {
431
+					$vals = explode('|', $opt);
432
+					if ( $vals[0] != $vals[1] ) {
433
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
+					}
435
+					unset($vals);
436
+				}
437
+				unset($opt_key, $opt);
438
+			}
439
+		}
440
+
441
+		//Keep other options after bulk update
442
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
+			$other_array = array();
444
+			foreach ( $field['options'] as $opt_key => $opt ) {
445
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
+					$other_array[ $opt_key ] = $opt;
447
+				}
448
+				unset($opt_key, $opt);
449
+			}
450
+			if ( ! empty($other_array) ) {
451
+				$opts = array_merge( $opts, $other_array);
452
+			}
453
+		}
454
+
455
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
+
457
+		$field['options'] = $opts;
458
+		$field_name = $field['name'];
459
+
460
+		// Get html_id which will be used in single-option.php
461
+		$html_id = FrmFieldsHelper::get_html_id( $field );
462
+
463
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
464 464
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465
-        } else {
466
-            FrmFieldsHelper::show_single_option($field);
467
-        }
465
+		} else {
466
+			FrmFieldsHelper::show_single_option($field);
467
+		}
468 468
 
469
-        wp_die();
470
-    }
469
+		wp_die();
470
+	}
471 471
 
472
-    public static function update_order() {
472
+	public static function update_order() {
473 473
 		FrmAppHelper::permission_check('frm_edit_forms');
474
-        check_ajax_referer( 'frm_ajax', 'nonce' );
474
+		check_ajax_referer( 'frm_ajax', 'nonce' );
475 475
 
476 476
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
477 477
 		foreach ( (array) $fields as $position => $item ) {
478 478
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
479 479
 		}
480
-        wp_die();
481
-    }
480
+		wp_die();
481
+	}
482 482
 
483 483
 	public static function change_type( $type ) {
484
-        $type_switch = array(
485
-            'scale'     => 'radio',
486
-            '10radio'   => 'radio',
487
-            'rte'       => 'textarea',
488
-            'website'   => 'url',
489
-        );
490
-        if ( isset( $type_switch[ $type ] ) ) {
491
-            $type = $type_switch[ $type ];
492
-        }
484
+		$type_switch = array(
485
+			'scale'     => 'radio',
486
+			'10radio'   => 'radio',
487
+			'rte'       => 'textarea',
488
+			'website'   => 'url',
489
+		);
490
+		if ( isset( $type_switch[ $type ] ) ) {
491
+			$type = $type_switch[ $type ];
492
+		}
493 493
 
494 494
 		$frm_field_selection = FrmField::field_selection();
495
-        $types = array_keys($frm_field_selection);
496
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
-            $type = 'text';
498
-        }
495
+		$types = array_keys($frm_field_selection);
496
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
+			$type = 'text';
498
+		}
499 499
 
500
-        return $type;
501
-    }
500
+		return $type;
501
+	}
502 502
 
503 503
 	public static function display_field_options( $display ) {
504 504
 		switch ( $display['type'] ) {
505
-            case 'captcha':
506
-                $display['required'] = false;
507
-                $display['invalid'] = true;
508
-                $display['default_blank'] = false;
505
+			case 'captcha':
506
+				$display['required'] = false;
507
+				$display['invalid'] = true;
508
+				$display['default_blank'] = false;
509 509
 				$display['captcha_size'] = true;
510
-            break;
511
-            case 'radio':
512
-                $display['default_blank'] = false;
513
-            break;
514
-            case 'text':
515
-            case 'textarea':
516
-                $display['size'] = true;
517
-                $display['clear_on_focus'] = true;
518
-            break;
519
-            case 'select':
520
-                $display['size'] = true;
521
-            break;
522
-            case 'url':
523
-            case 'website':
524
-            case 'email':
525
-                $display['size'] = true;
526
-                $display['clear_on_focus'] = true;
527
-                $display['invalid'] = true;
528
-        }
529
-
530
-        return $display;
531
-    }
532
-
533
-    public static function input_html( $field, $echo = true ) {
534
-        $class = array(); //$field['type'];
535
-        self::add_input_classes($field, $class);
536
-
537
-        $add_html = array();
538
-        self::add_html_size($field, $add_html);
539
-        self::add_html_length($field, $add_html);
540
-        self::add_html_placeholder($field, $add_html, $class);
510
+			break;
511
+			case 'radio':
512
+				$display['default_blank'] = false;
513
+			break;
514
+			case 'text':
515
+			case 'textarea':
516
+				$display['size'] = true;
517
+				$display['clear_on_focus'] = true;
518
+			break;
519
+			case 'select':
520
+				$display['size'] = true;
521
+			break;
522
+			case 'url':
523
+			case 'website':
524
+			case 'email':
525
+				$display['size'] = true;
526
+				$display['clear_on_focus'] = true;
527
+				$display['invalid'] = true;
528
+		}
529
+
530
+		return $display;
531
+	}
532
+
533
+	public static function input_html( $field, $echo = true ) {
534
+		$class = array(); //$field['type'];
535
+		self::add_input_classes($field, $class);
536
+
537
+		$add_html = array();
538
+		self::add_html_size($field, $add_html);
539
+		self::add_html_length($field, $add_html);
540
+		self::add_html_placeholder($field, $add_html, $class);
541 541
 		self::add_validation_messages( $field, $add_html );
542 542
 
543
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
544 544
 
545 545
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
546 546
 
547
-        self::add_shortcodes_to_html($field, $add_html);
547
+		self::add_shortcodes_to_html($field, $add_html);
548 548
 
549 549
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
550 550
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
551 551
 
552
-        if ( $echo ) {
553
-            echo $add_html;
554
-        }
552
+		if ( $echo ) {
553
+			echo $add_html;
554
+		}
555 555
 
556
-        return $add_html;
557
-    }
556
+		return $add_html;
557
+	}
558 558
 
559 559
 	private static function add_input_classes( $field, array &$class ) {
560
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
-            $class[] = $field['input_class'];
562
-        }
560
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
+			$class[] = $field['input_class'];
562
+		}
563 563
 
564
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
-            return;
566
-        }
564
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
+			return;
566
+		}
567 567
 
568
-        global $frm_vars;
568
+		global $frm_vars;
569 569
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data', 'lookup' ) ) ) {
570 570
 			// Add the dyn_default_value class to some field inputs on form builder page
571
-            $class[] = 'dyn_default_value';
572
-        }
571
+			$class[] = 'dyn_default_value';
572
+		}
573 573
 
574
-        if ( isset($field['size']) && $field['size'] > 0 ) {
575
-            $class[] = 'auto_width';
576
-        }
577
-    }
574
+		if ( isset($field['size']) && $field['size'] > 0 ) {
575
+			$class[] = 'auto_width';
576
+		}
577
+	}
578 578
 
579 579
 	private static function add_html_size( $field, array &$add_html ) {
580 580
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'lookup' ) ) ) {
581
-            return;
582
-        }
581
+			return;
582
+		}
583 583
 
584
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
585
-            return;
586
-        }
584
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
585
+			return;
586
+		}
587 587
 
588
-        if ( is_numeric($field['size']) ) {
589
-            $field['size'] .= 'px';
590
-        }
588
+		if ( is_numeric($field['size']) ) {
589
+			$field['size'] .= 'px';
590
+		}
591 591
 
592
-        $important = apply_filters('frm_use_important_width', 1, $field);
593
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
592
+		$important = apply_filters('frm_use_important_width', 1, $field);
593
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
594 594
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
595 595
 
596
-        self::add_html_cols($field, $add_html);
597
-    }
596
+		self::add_html_cols($field, $add_html);
597
+	}
598 598
 
599 599
 	private static function add_html_cols( $field, array &$add_html ) {
600 600
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
601
-            return;
602
-        }
601
+			return;
602
+		}
603 603
 
604
-        // convert to cols for textareas
605
-        $calc = array(
606
-            ''      => 9,
607
-            'px'    => 9,
608
-            'rem'   => 0.444,
609
-            'em'    => 0.544,
610
-        );
604
+		// convert to cols for textareas
605
+		$calc = array(
606
+			''      => 9,
607
+			'px'    => 9,
608
+			'rem'   => 0.444,
609
+			'em'    => 0.544,
610
+		);
611 611
 
612
-        // include "col" for valid html
613
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
612
+		// include "col" for valid html
613
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
614 614
 
615
-        if ( ! isset( $calc[ $unit ] ) ) {
616
-            return;
617
-        }
615
+		if ( ! isset( $calc[ $unit ] ) ) {
616
+			return;
617
+		}
618 618
 
619
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
619
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
620 620
 
621 621
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
622
-    }
622
+	}
623 623
 
624 624
 	private static function add_html_length( $field, array &$add_html ) {
625
-        // check for max setting and if this field accepts maxlength
625
+		// check for max setting and if this field accepts maxlength
626 626
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
627
-            return;
628
-        }
627
+			return;
628
+		}
629 629
 
630
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
631
-            // don't load on form builder page
632
-            return;
633
-        }
630
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
631
+			// don't load on form builder page
632
+			return;
633
+		}
634 634
 
635 635
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
636
-    }
636
+	}
637 637
 
638 638
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
639 639
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -641,35 +641,35 @@  discard block
 block discarded – undo
641 641
 		}
642 642
 
643 643
 		$default_value_array = is_array( $field['default_value'] );
644
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
644
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
645 645
 			if ( $default_value_array ) {
646 646
 				$field['default_value'] = json_encode( $field['default_value'] );
647 647
 			}
648 648
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
649
-            return;
650
-        }
649
+			return;
650
+		}
651 651
 
652 652
 		if ( $default_value_array ) {
653 653
 			// don't include a json placeholder
654 654
 			return;
655 655
 		}
656 656
 
657
-        $frm_settings = FrmAppHelper::get_settings();
657
+		$frm_settings = FrmAppHelper::get_settings();
658 658
 
659 659
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
660
-            // use HMTL5 placeholder with js fallback
660
+			// use HMTL5 placeholder with js fallback
661 661
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
662
-            wp_enqueue_script('jquery-placeholder');
663
-        } else if ( ! $frm_settings->use_html ) {
662
+			wp_enqueue_script('jquery-placeholder');
663
+		} else if ( ! $frm_settings->use_html ) {
664 664
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
665 665
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
666
-            $class[] = 'frm_toggle_default';
666
+			$class[] = 'frm_toggle_default';
667 667
 
668
-            if ( $field['value'] == $field['default_value'] ) {
669
-                $class[] = 'frm_default';
670
-            }
671
-        }
672
-    }
668
+			if ( $field['value'] == $field['default_value'] ) {
669
+				$class[] = 'frm_default';
670
+			}
671
+		}
672
+	}
673 673
 
674 674
 	private static function add_validation_messages( $field, array &$add_html ) {
675 675
 		if ( FrmField::is_required( $field ) ) {
@@ -690,44 +690,44 @@  discard block
 block discarded – undo
690 690
 		}
691 691
 	}
692 692
 
693
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
694
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
695
-            return;
696
-        }
693
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
694
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
695
+			return;
696
+		}
697 697
 
698
-        foreach ( $field['shortcodes'] as $k => $v ) {
699
-            if ( 'opt' === $k ) {
700
-                continue;
701
-            }
698
+		foreach ( $field['shortcodes'] as $k => $v ) {
699
+			if ( 'opt' === $k ) {
700
+				continue;
701
+			}
702 702
 
703
-            if ( is_numeric($k) && strpos($v, '=') ) {
704
-                $add_html[] = $v;
705
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
703
+			if ( is_numeric($k) && strpos($v, '=') ) {
704
+				$add_html[] = $v;
705
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
706 706
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
707
-            } else {
707
+			} else {
708 708
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
709
-            }
710
-
711
-            unset($k, $v);
712
-        }
713
-    }
714
-
715
-    public static function check_value( $opt, $opt_key, $field ) {
716
-        if ( is_array( $opt ) ) {
717
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
718
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
719
-            } else {
720
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
721
-            }
722
-        }
723
-        return $opt;
724
-    }
709
+			}
710
+
711
+			unset($k, $v);
712
+		}
713
+	}
714
+
715
+	public static function check_value( $opt, $opt_key, $field ) {
716
+		if ( is_array( $opt ) ) {
717
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
718
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
719
+			} else {
720
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
721
+			}
722
+		}
723
+		return $opt;
724
+	}
725 725
 
726 726
 	public static function check_label( $opt ) {
727
-        if ( is_array($opt) ) {
728
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
729
-        }
727
+		if ( is_array($opt) ) {
728
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
729
+		}
730 730
 
731
-        return $opt;
732
-    }
731
+		return $opt;
732
+	}
733 733
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64 64
         // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
65
+        do_action( 'frm_after_field_created', $field, $form_id );
66 66
 
67 67
         wp_die();
68 68
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78 78
         $values = array();
79 79
         if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
80
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
81 81
         }
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -89,27 +89,27 @@  discard block
 block discarded – undo
89 89
             return false;
90 90
         }
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+        $field = self::include_single_field( $field_id, $values, $form_id );
93 93
 
94 94
         return $field;
95 95
     }
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98
-		FrmAppHelper::permission_check('frm_edit_forms');
98
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
99 99
         check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
101
+        if ( empty( $field ) ) {
102 102
             $field = 'name';
103 103
         }
104 104
 
105
-        if ( empty($id) ) {
105
+        if ( empty( $id ) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108 108
         }
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
112
+        if ( trim( strip_tags( $value ) ) == '' ) {
113 113
             // set blank value if there is no content
114 114
             $value = '';
115 115
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     public static function update_ajax_option() {
126
-		FrmAppHelper::permission_check('frm_edit_forms');
126
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
127 127
         check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		if ( isset( $_POST['separate_value'] ) ) {
137 137
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
138 138
 			$field->field_options['separate_value'] = $new_val;
139
-			unset($new_val);
139
+			unset( $new_val );
140 140
 		}
141 141
 
142 142
         FrmField::update( $field_id, array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     }
148 148
 
149 149
     public static function duplicate() {
150
-		FrmAppHelper::permission_check('frm_edit_forms');
150
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
151 151
         check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153 153
         global $wpdb;
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 
173 173
 	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
175
+        if ( ! $field_id = FrmField::create( $values ) ) {
176 176
             wp_die();
177 177
         }
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+        self::include_single_field( $field_id, $values );
180 180
 
181 181
         wp_die();
182 182
     }
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
      * Load a single field in the form builder along with all needed variables
186 186
      */
187 187
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
188
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
190
+        $html_id = FrmFieldsHelper::get_html_id( $field );
191 191
         $id = $form_id ? $form_id : $field['form_id'];
192 192
         if ( $field['type'] == 'html' ) {
193 193
             $field['stop_filter'] = true;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     }
200 200
 
201 201
     public static function destroy() {
202
-		FrmAppHelper::permission_check('frm_edit_forms');
202
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
203 203
         check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 
212 212
     //Add Single Option or Other Option
213 213
     public static function add_option() {
214
-		FrmAppHelper::permission_check('frm_edit_forms');
214
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
215 215
         check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220 220
         //Get the field
221
-        $field = FrmField::getOne($id);
221
+        $field = FrmField::getOne( $id );
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243 243
             if ( $first_opt != '' ) {
244
-                $next_opt++;
244
+                $next_opt ++;
245 245
             }
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
247
+            unset( $next_opt );
248 248
         }
249 249
         $field_val = $opt;
250
-		$field->options[ $opt_key ] = $opt;
250
+		$field->options[$opt_key] = $opt;
251 251
 
252 252
         //Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
         $field = array(
257 257
             'type'  => $field_data->type,
258 258
             'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
259
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
260 260
             'form_id' => $field_data->form_id,
261 261
             'field_key' => $field_data->field_key,
262 262
         );
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
265
+        $html_id = FrmFieldsHelper::get_html_id( $field );
266 266
         $checked = '';
267 267
 
268 268
         if ( 'other' == $opt_type ) {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     }
275 275
 
276 276
     public static function edit_option() {
277
-		FrmAppHelper::permission_check('frm_edit_forms');
277
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
278 278
         check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -288,28 +288,28 @@  discard block
 block discarded – undo
288 288
             $new_label = $update_value;
289 289
         }
290 290
 
291
-        $field = FrmField::getOne($id);
291
+        $field = FrmField::getOne( $id );
292 292
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
295
-		$this_opt = (array) $field->options[ $this_opt_id ];
296
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
294
+        $this_opt_id = end( $ids );
295
+		$this_opt = (array) $field->options[$this_opt_id];
296
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
299
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
300 300
 
301 301
         if ( ! isset( $new_label ) ) {
302 302
             $new_label = $label;
303 303
         }
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
305
+        if ( isset( $new_value ) || isset( $value ) ) {
306
+            $update_value = isset( $new_value ) ? $new_value : $value;
307 307
         }
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
310
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
311 311
         } else {
312
-			$field->options[ $this_opt_id ] = $orig_update_value;
312
+			$field->options[$this_opt_id] = $orig_update_value;
313 313
         }
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     public static function delete_option() {
321
-		FrmAppHelper::permission_check('frm_edit_forms');
321
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
322 322
         check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
330
+        unset( $options[$opt_key] );
331 331
         $response = array( 'other' => true );
332 332
 
333 333
         //If the deleted option is an "other" option
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 
394 394
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395 395
         $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
396
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+        $field = FrmField::getOne( $field_id );
399 399
 
400 400
         wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -406,35 +406,35 @@  discard block
 block discarded – undo
406 406
     }
407 407
 
408 408
     public static function import_options() {
409
-		FrmAppHelper::permission_check('frm_edit_forms');
409
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
410 410
         check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
412
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
413 413
             return;
414 414
         }
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+        $field = FrmField::getOne( $field_id );
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420 420
             return;
421 421
         }
422 422
 
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
423
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
424 424
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
425 425
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
426 426
 		$opts = array_map( 'trim', $opts );
427 427
 
428 428
         if ( $field['separate_value'] ) {
429 429
             foreach ( $opts as $opt_key => $opt ) {
430
-                if ( strpos($opt, '|') !== false ) {
431
-                    $vals = explode('|', $opt);
430
+                if ( strpos( $opt, '|' ) !== false ) {
431
+                    $vals = explode( '|', $opt );
432 432
                     if ( $vals[0] != $vals[1] ) {
433
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434 434
                     }
435
-                    unset($vals);
435
+                    unset( $vals );
436 436
                 }
437
-                unset($opt_key, $opt);
437
+                unset( $opt_key, $opt );
438 438
             }
439 439
         }
440 440
 
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
             $other_array = array();
444 444
             foreach ( $field['options'] as $opt_key => $opt ) {
445 445
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
-                    $other_array[ $opt_key ] = $opt;
446
+                    $other_array[$opt_key] = $opt;
447 447
                 }
448
-                unset($opt_key, $opt);
448
+                unset( $opt_key, $opt );
449 449
             }
450
-            if ( ! empty($other_array) ) {
451
-                $opts = array_merge( $opts, $other_array);
450
+            if ( ! empty( $other_array ) ) {
451
+                $opts = array_merge( $opts, $other_array );
452 452
             }
453 453
         }
454 454
 
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
464 464
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465 465
         } else {
466
-            FrmFieldsHelper::show_single_option($field);
466
+            FrmFieldsHelper::show_single_option( $field );
467 467
         }
468 468
 
469 469
         wp_die();
470 470
     }
471 471
 
472 472
     public static function update_order() {
473
-		FrmAppHelper::permission_check('frm_edit_forms');
473
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
474 474
         check_ajax_referer( 'frm_ajax', 'nonce' );
475 475
 
476 476
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
             'rte'       => 'textarea',
488 488
             'website'   => 'url',
489 489
         );
490
-        if ( isset( $type_switch[ $type ] ) ) {
491
-            $type = $type_switch[ $type ];
490
+        if ( isset( $type_switch[$type] ) ) {
491
+            $type = $type_switch[$type];
492 492
         }
493 493
 
494 494
 		$frm_field_selection = FrmField::field_selection();
495
-        $types = array_keys($frm_field_selection);
496
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
495
+        $types = array_keys( $frm_field_selection );
496
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
497 497
             $type = 'text';
498 498
         }
499 499
 
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 
533 533
     public static function input_html( $field, $echo = true ) {
534 534
         $class = array(); //$field['type'];
535
-        self::add_input_classes($field, $class);
535
+        self::add_input_classes( $field, $class );
536 536
 
537 537
         $add_html = array();
538
-        self::add_html_size($field, $add_html);
539
-        self::add_html_length($field, $add_html);
540
-        self::add_html_placeholder($field, $add_html, $class);
538
+        self::add_html_size( $field, $add_html );
539
+        self::add_html_length( $field, $add_html );
540
+        self::add_html_placeholder( $field, $add_html, $class );
541 541
 		self::add_validation_messages( $field, $add_html );
542 542
 
543
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
544 544
 
545 545
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
546 546
 
547
-        self::add_shortcodes_to_html($field, $add_html);
547
+        self::add_shortcodes_to_html( $field, $add_html );
548 548
 
549 549
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
550 550
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
 	private static function add_input_classes( $field, array &$class ) {
560
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
561 561
             $class[] = $field['input_class'];
562 562
         }
563 563
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
             $class[] = 'dyn_default_value';
572 572
         }
573 573
 
574
-        if ( isset($field['size']) && $field['size'] > 0 ) {
574
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
575 575
             $class[] = 'auto_width';
576 576
         }
577 577
     }
@@ -581,19 +581,19 @@  discard block
 block discarded – undo
581 581
             return;
582 582
         }
583 583
 
584
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
584
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
585 585
             return;
586 586
         }
587 587
 
588
-        if ( is_numeric($field['size']) ) {
588
+        if ( is_numeric( $field['size'] ) ) {
589 589
             $field['size'] .= 'px';
590 590
         }
591 591
 
592
-        $important = apply_filters('frm_use_important_width', 1, $field);
592
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
593 593
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
594 594
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
595 595
 
596
-        self::add_html_cols($field, $add_html);
596
+        self::add_html_cols( $field, $add_html );
597 597
     }
598 598
 
599 599
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
         );
611 611
 
612 612
         // include "col" for valid html
613
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
613
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
614 614
 
615
-        if ( ! isset( $calc[ $unit ] ) ) {
615
+        if ( ! isset( $calc[$unit] ) ) {
616 616
             return;
617 617
         }
618 618
 
619
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
619
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
620 620
 
621 621
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
622 622
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             return;
628 628
         }
629 629
 
630
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
630
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
631 631
             // don't load on form builder page
632 632
             return;
633 633
         }
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
660 660
             // use HMTL5 placeholder with js fallback
661 661
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
662
-            wp_enqueue_script('jquery-placeholder');
662
+            wp_enqueue_script( 'jquery-placeholder' );
663 663
         } else if ( ! $frm_settings->use_html ) {
664 664
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
665 665
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 			$format = FrmEntryValidate::phone_format( $field );
687 687
 			$format = substr( $format, 2, -2 );
688 688
 			$key = 'pattern';
689
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
689
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
690 690
 		}
691 691
 	}
692 692
 
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
                 continue;
701 701
             }
702 702
 
703
-            if ( is_numeric($k) && strpos($v, '=') ) {
703
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
704 704
                 $add_html[] = $v;
705
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
706
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
705
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
706
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
707 707
             } else {
708
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
708
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
709 709
             }
710 710
 
711
-            unset($k, $v);
711
+            unset( $k, $v );
712 712
         }
713 713
     }
714 714
 
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
     }
725 725
 
726 726
 	public static function check_label( $opt ) {
727
-        if ( is_array($opt) ) {
728
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
727
+        if ( is_array( $opt ) ) {
728
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
729 729
         }
730 730
 
731 731
         return $opt;
Please login to merge, or discard this patch.