Completed
Branch uploads (22f1aa)
by Stephanie
03:44
created
classes/views/frm-forms/new.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
     <div id="post-body" class="metabox-holder columns-2">
9 9
     <div id="post-body-content">
10 10
         <?php
11
-        if ( ! $values['is_template'] ) {
12
-            FrmAppController::get_form_nav($id, true, 'hide');
13
-        }
11
+		if ( ! $values['is_template'] ) {
12
+			FrmAppController::get_form_nav($id, true, 'hide');
13
+		}
14 14
 		require( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' );
15 15
 
16
-        ?>
16
+		?>
17 17
 
18 18
         <div class="frm_form_builder with_frm_style">
19 19
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     <div id="post-body-content">
10 10
         <?php
11 11
         if ( ! $values['is_template'] ) {
12
-            FrmAppController::get_form_nav($id, true, 'hide');
12
+            FrmAppController::get_form_nav( $id, true, 'hide' );
13 13
         }
14 14
 		require( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' );
15 15
 
Please login to merge, or discard this patch.
classes/views/frm-forms/settings.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                             <option value="message" <?php selected($values['success_action'], 'message') ?>><?php _e( 'Show Message', 'formidable' )?></option>
62 62
                             <?php if ( FrmAppHelper::pro_is_installed() ) { ?>
63 63
                                 <option value="redirect" <?php selected($values['success_action'], 'redirect');
64
-                                ?>><?php _e( 'Redirect to URL', 'formidable' ) ?></option>
64
+								?>><?php _e( 'Redirect to URL', 'formidable' ) ?></option>
65 65
                                 <option value="page" <?php selected($values['success_action'], 'page');
66 66
 								?>><?php _e( 'Show Page Content', 'formidable' ) ?></option>
67 67
                             <?php } else { ?>
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 								<?php _e( '(Premium feature)', 'formidable' ); ?>
72 72
 							</option>
73 73
 							<option value="page" disabled="disabled" <?php selected($values['success_action'], 'page');
74
-                            ?>>
74
+							?>>
75 75
 								<?php _e( 'Show Page Content', 'formidable' ); ?>
76 76
 								<?php _e( '(Premium feature)', 'formidable' ); ?>
77 77
 							</option>
@@ -193,17 +193,17 @@  discard block
 block discarded – undo
193 193
                 <ul class="frm_actions_list">
194 194
                 <?php
195 195
 
196
-                //For each add-on, add an li, class, and javascript function. If active, add an additional class.
197
-                foreach ( $action_controls as $action_control ) {
198
-                    ?>
196
+				//For each add-on, add an li, class, and javascript function. If active, add an additional class.
197
+				foreach ( $action_controls as $action_control ) {
198
+					?>
199 199
                     <li><a href="javascript:void(0)" class="frm_<?php echo esc_attr( $action_control->id_base ) ?>_action frm_bstooltip <?php
200
-                    echo ( isset($action_control->action_options['active']) && $action_control->action_options['active']) ? 'frm_active_action ' : 'frm_inactive_action ';
201
-                    echo esc_attr( $action_control->action_options['classes'] );
202
-                    ?>" title="<?php echo esc_attr($action_control->action_options['tooltip']) ?>" data-limit="<?php echo isset($action_control->action_options['limit']) ? esc_attr( $action_control->action_options['limit'] ) : '99' ?>" data-actiontype="<?php echo esc_attr($action_control->id_base) ?>"></a></li>
200
+					echo ( isset($action_control->action_options['active']) && $action_control->action_options['active']) ? 'frm_active_action ' : 'frm_inactive_action ';
201
+					echo esc_attr( $action_control->action_options['classes'] );
202
+					?>" title="<?php echo esc_attr($action_control->action_options['tooltip']) ?>" data-limit="<?php echo isset($action_control->action_options['limit']) ? esc_attr( $action_control->action_options['limit'] ) : '99' ?>" data-actiontype="<?php echo esc_attr($action_control->id_base) ?>"></a></li>
203 203
 <?php
204
-                    unset($actions_icon);
205
-                }
206
-                ?>
204
+					unset($actions_icon);
205
+				}
206
+				?>
207 207
                 </ul>
208 208
             </div>
209 209
             <div class="frm_no_actions">
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
                                 <p><label><?php echo esc_html( $field['name'] ) ?></label>
236 236
                                 <textarea name="field_options[custom_html_<?php echo esc_attr( $field['id'] ) ?>]" rows="7" id="custom_html_<?php echo esc_attr( $field['id'] ) ?>" class="field_custom_html frm_long_input"><?php echo FrmAppHelper::esc_textarea($field['custom_html']) ?></textarea></p>
237 237
                             <?php }
238
-                            unset($field);
239
-                        }
240
-                    } ?>
238
+							unset($field);
239
+						}
240
+					} ?>
241 241
                 </div>
242 242
 
243 243
                 <p><label><?php _e( 'After Fields', 'formidable' ) ?></label>
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				call_user_func( array( $section['class'], $section['function'] ), $values );
260 260
 			} else {
261 261
 				call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ), $values );
262
-            } ?>
262
+			} ?>
263 263
             </div>
264 264
         <?php } ?>
265 265
 
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
         <div class="contextual-help-tabs">
28 28
         <ul class="frm-category-tabs frm-form-setting-tabs">
29 29
 			<?php $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' ); ?>
30
-        	<li <?php echo ($a == 'advanced_settings') ? 'class="tabs active"' : '' ?>><a href="#advanced_settings"><?php _e( 'General', 'formidable' ) ?></a></li>
31
-        	<li <?php echo ($a == 'email_settings') ? 'class="tabs active"' : '' ?>><a href="#email_settings"><?php _e( 'Form Actions', 'formidable' ); ?></a></li>
32
-            <li <?php echo ($a == 'html_settings') ? 'class="tabs active"' : '' ?>><a href="#html_settings"><?php _e( 'Customize HTML', 'formidable' ) ?></a></li>
30
+        	<li <?php echo ( $a == 'advanced_settings' ) ? 'class="tabs active"' : '' ?>><a href="#advanced_settings"><?php _e( 'General', 'formidable' ) ?></a></li>
31
+        	<li <?php echo ( $a == 'email_settings' ) ? 'class="tabs active"' : '' ?>><a href="#email_settings"><?php _e( 'Form Actions', 'formidable' ); ?></a></li>
32
+            <li <?php echo ( $a == 'html_settings' ) ? 'class="tabs active"' : '' ?>><a href="#html_settings"><?php _e( 'Customize HTML', 'formidable' ) ?></a></li>
33 33
             <?php foreach ( $sections as $key => $section ) {
34 34
 				if ( isset( $section['name'] ) ) {
35 35
 					$sec_name = $section['name'];
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             <?php } ?>
44 44
         </ul>
45 45
         </div>
46
-        <div class="advanced_settings tabs-panel <?php echo ($a == 'advanced_settings') ? 'frm_block' : 'frm_hidden' ?>">
46
+        <div class="advanced_settings tabs-panel <?php echo ( $a == 'advanced_settings' ) ? 'frm_block' : 'frm_hidden' ?>">
47 47
 			<?php FrmTipsHelper::pro_tip( 'get_form_settings_tip', 'p' ); ?>
48 48
 
49 49
 			<h3 class="frm_first_h3"><?php _e( 'On Submit', 'formidable' ); ?>
@@ -58,19 +58,19 @@  discard block
 block discarded – undo
58 58
                 <tr>
59 59
                     <td class="frm_175_width">
60 60
                         <select name="options[success_action]" id="success_action">
61
-                            <option value="message" <?php selected($values['success_action'], 'message') ?>><?php _e( 'Show Message', 'formidable' )?></option>
61
+                            <option value="message" <?php selected( $values['success_action'], 'message' ) ?>><?php _e( 'Show Message', 'formidable' )?></option>
62 62
                             <?php if ( FrmAppHelper::pro_is_installed() ) { ?>
63
-                                <option value="redirect" <?php selected($values['success_action'], 'redirect');
63
+                                <option value="redirect" <?php selected( $values['success_action'], 'redirect' );
64 64
                                 ?>><?php _e( 'Redirect to URL', 'formidable' ) ?></option>
65
-                                <option value="page" <?php selected($values['success_action'], 'page');
65
+                                <option value="page" <?php selected( $values['success_action'], 'page' );
66 66
 								?>><?php _e( 'Show Page Content', 'formidable' ) ?></option>
67 67
                             <?php } else { ?>
68
-                            <option value="redirect" disabled="disabled" <?php selected($values['success_action'], 'redirect');
68
+                            <option value="redirect" disabled="disabled" <?php selected( $values['success_action'], 'redirect' );
69 69
 							?>>
70 70
 								<?php _e( 'Redirect to URL', 'formidable' ); ?>
71 71
 								<?php _e( '(Premium feature)', 'formidable' ); ?>
72 72
 							</option>
73
-							<option value="page" disabled="disabled" <?php selected($values['success_action'], 'page');
73
+							<option value="page" disabled="disabled" <?php selected( $values['success_action'], 'page' );
74 74
                             ?>>
75 75
 								<?php _e( 'Show Page Content', 'formidable' ); ?>
76 76
 								<?php _e( '(Premium feature)', 'formidable' ); ?>
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                         </select>
80 80
                     </td>
81 81
                     <td>
82
-                        <span class="success_action_redirect_box success_action_box<?php echo ($values['success_action'] == 'redirect') ? '' : ' frm_hidden'; ?>">
82
+                        <span class="success_action_redirect_box success_action_box<?php echo ( $values['success_action'] == 'redirect' ) ? '' : ' frm_hidden'; ?>">
83 83
                             <input type="text" name="options[success_url]" id="success_url" value="<?php
84 84
 							if ( isset( $values['success_url'] ) ) {
85 85
 								echo esc_attr( $values['success_url'] );
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
                         </span>
88 88
 
89 89
 						<?php if ( FrmAppHelper::pro_is_installed() ) { ?>
90
-                        <span class="success_action_page_box success_action_box<?php echo ($values['success_action'] == 'page') ? '' : ' frm_hidden'; ?>">
90
+                        <span class="success_action_page_box success_action_box<?php echo ( $values['success_action'] == 'page' ) ? '' : ' frm_hidden'; ?>">
91 91
                             <label><?php _e( 'Use Content from Page', 'formidable' ) ?></label>
92 92
                             <?php FrmAppHelper::wp_pages_dropdown( 'options[success_page_id]', $values['success_page_id'] ) ?>
93 93
                         </span>
94 94
                         <?php } ?>
95 95
                     </td>
96 96
                 </tr>
97
-                <tr class="frm_show_form_opt success_action_message_box success_action_box<?php echo ($values['success_action'] == 'message') ? '' : ' frm_hidden'; ?>">
97
+                <tr class="frm_show_form_opt success_action_message_box success_action_box<?php echo ( $values['success_action'] == 'message' ) ? '' : ' frm_hidden'; ?>">
98 98
                     <td colspan="2">
99 99
 						<label for="show_form"><input type="checkbox" name="options[show_form]" id="show_form" value="1" <?php checked( $values['show_form'], 1 ) ?> /> <?php _e( 'Show the form with the confirmation message', 'formidable' ) ?></label>
100 100
                     </td>
101 101
                 </tr>
102 102
                 <tr>
103
-                    <td colspan="2"><label for="no_save"><input type="checkbox" name="options[no_save]" id="no_save" value="1" <?php checked($values['no_save'], 1); ?> /> <?php _e( 'Do not store entries submitted from this form', 'formidable' ) ?></label>
103
+                    <td colspan="2"><label for="no_save"><input type="checkbox" name="options[no_save]" id="no_save" value="1" <?php checked( $values['no_save'], 1 ); ?> /> <?php _e( 'Do not store entries submitted from this form', 'formidable' ) ?></label>
104 104
                     </td>
105 105
                 </tr>
106
-                <?php if ( function_exists( 'akismet_http_post') ) { ?>
106
+                <?php if ( function_exists( 'akismet_http_post' ) ) { ?>
107 107
                 <tr>
108 108
                     <td colspan="2"><?php _e( 'Use Akismet to check entries for spam for', 'formidable' ) ?>
109 109
                         <select name="options[akismet]">
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 						<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Recommended for long forms.', 'formidable' ) ?>" ></span>
130 130
                     </td>
131 131
                 </tr>
132
-                <?php do_action('frm_add_form_ajax_options', $values); ?>
132
+                <?php do_action( 'frm_add_form_ajax_options', $values ); ?>
133 133
             </table>
134 134
 
135 135
             <!--Permissions Section-->
136 136
             <table class="form-table">
137
-                <?php do_action('frm_add_form_perm_options', $values); ?>
137
+                <?php do_action( 'frm_add_form_perm_options', $values ); ?>
138 138
             </table>
139 139
 
140 140
             <!--Styling & Buttons Section-->
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 </tr>
157 157
                 <tr>
158 158
                     <td><label><?php _e( 'Submit Button Text', 'formidable' ) ?></label></td>
159
-                    <td><input type="text" name="options[submit_value]" value="<?php echo esc_attr($values['submit_value']); ?>" /></td>
159
+                    <td><input type="text" name="options[submit_value]" value="<?php echo esc_attr( $values['submit_value'] ); ?>" /></td>
160 160
                 </tr>
161 161
 				<?php do_action( 'frm_add_form_button_options', $values ); ?>
162 162
             </table>
@@ -166,27 +166,27 @@  discard block
 block discarded – undo
166 166
 				<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set up your confirmation messages.', 'formidable' ) ?>" ></span>
167 167
 			</h3>
168 168
             <table class="form-table">
169
-                <tr class="success_action_message_box success_action_box<?php echo ($values['success_action'] == 'message') ? '' : ' frm_hidden'; ?>">
169
+                <tr class="success_action_message_box success_action_box<?php echo ( $values['success_action'] == 'message' ) ? '' : ' frm_hidden'; ?>">
170 170
                     <td>
171 171
                         <div><?php _e( 'On Submit', 'formidable' ) ?></div>
172
-                        <textarea id="success_msg" name="options[success_msg]" cols="50" rows="2" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['success_msg']); ?></textarea>
172
+                        <textarea id="success_msg" name="options[success_msg]" cols="50" rows="2" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['success_msg'] ); ?></textarea>
173 173
                     </td>
174 174
                 </tr>
175
-                <?php do_action('frm_add_form_msg_options', $values); ?>
175
+                <?php do_action( 'frm_add_form_msg_options', $values ); ?>
176 176
             </table>
177 177
 
178 178
 			<!--Misc Section-->
179 179
 			<?php if ( has_action( 'frm_additional_form_options' ) ) { ?>
180 180
 				<h3><?php _e( 'Miscellaneous', 'formidable' ); ?></h3>
181 181
 				<table class="form-table">
182
-					<?php do_action('frm_additional_form_options', $values); ?>
182
+					<?php do_action( 'frm_additional_form_options', $values ); ?>
183 183
 				</table>
184 184
 				<?php } ?>
185 185
 
186 186
 		</div>
187 187
 
188 188
 
189
-        <div id="frm_notification_settings" class="frm_email_settings email_settings tabs-panel widgets-holder-wrap <?php echo ($a == 'email_settings') ? ' frm_block' : ' frm_hidden'; ?>">
189
+        <div id="frm_notification_settings" class="frm_email_settings email_settings tabs-panel widgets-holder-wrap <?php echo ( $a == 'email_settings' ) ? ' frm_block' : ' frm_hidden'; ?>">
190 190
 			<?php FrmTipsHelper::pro_tip( 'get_form_action_tip', 'p' ); ?>
191 191
             <div id="frm_email_addon_menu" class="manage-menus">
192 192
                 <h3><?php _e( 'Add New Action', 'formidable' ) ?></h3>
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
                 foreach ( $action_controls as $action_control ) {
198 198
                     ?>
199 199
                     <li><a href="javascript:void(0)" class="frm_<?php echo esc_attr( $action_control->id_base ) ?>_action frm_bstooltip <?php
200
-                    echo ( isset($action_control->action_options['active']) && $action_control->action_options['active']) ? 'frm_active_action ' : 'frm_inactive_action ';
200
+                    echo ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) ? 'frm_active_action ' : 'frm_inactive_action ';
201 201
                     echo esc_attr( $action_control->action_options['classes'] );
202
-                    ?>" title="<?php echo esc_attr($action_control->action_options['tooltip']) ?>" data-limit="<?php echo isset($action_control->action_options['limit']) ? esc_attr( $action_control->action_options['limit'] ) : '99' ?>" data-actiontype="<?php echo esc_attr($action_control->id_base) ?>"></a></li>
202
+                    ?>" title="<?php echo esc_attr( $action_control->action_options['tooltip'] ) ?>" data-limit="<?php echo isset( $action_control->action_options['limit'] ) ? esc_attr( $action_control->action_options['limit'] ) : '99' ?>" data-actiontype="<?php echo esc_attr( $action_control->id_base ) ?>"></a></li>
203 203
 <?php
204
-                    unset($actions_icon);
204
+                    unset( $actions_icon );
205 205
                 }
206 206
                 ?>
207 207
                 </ul>
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
                     <?php _e( 'Click an action to add it to this form', 'formidable' ) ?>
214 214
                 </div>
215 215
             </div>
216
-            <?php FrmFormActionsController::list_actions($form, $values); ?>
216
+            <?php FrmFormActionsController::list_actions( $form, $values ); ?>
217 217
         </div>
218 218
 
219
-        <div id="html_settings" class="tabs-panel <?php echo ($a == 'html_settings') ? ' frm_block' : ' frm_hidden'; ?>">
219
+        <div id="html_settings" class="tabs-panel <?php echo ( $a == 'html_settings' ) ? ' frm_block' : ' frm_hidden'; ?>">
220 220
 
221 221
             <div class="frm_field_html_box frm_top_container">
222 222
                 <p><label><?php _e( 'Form Classes', 'formidable' ) ?></label>
223
-                    <input type="text" name="options[form_class]" value="<?php echo esc_attr($values['form_class']) ?>" />
223
+                    <input type="text" name="options[form_class]" value="<?php echo esc_attr( $values['form_class'] ) ?>" />
224 224
                 </p>
225 225
                 <div class="clear"></div>
226 226
 
227 227
                 <p><label><?php _e( 'Before Fields', 'formidable' ) ?></label>
228
-                <textarea name="options[before_html]" rows="4" id="before_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['before_html']) ?></textarea></p>
228
+                <textarea name="options[before_html]" rows="4" id="before_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['before_html'] ) ?></textarea></p>
229 229
 
230 230
                 <div id="add_html_fields">
231 231
                     <?php
@@ -233,18 +233,18 @@  discard block
 block discarded – undo
233 233
 						foreach ( $values['fields'] as $field ) {
234 234
 							if ( apply_filters( 'frm_show_custom_html', true, $field['type'] ) ) { ?>
235 235
                                 <p><label><?php echo esc_html( $field['name'] ) ?></label>
236
-                                <textarea name="field_options[custom_html_<?php echo esc_attr( $field['id'] ) ?>]" rows="7" id="custom_html_<?php echo esc_attr( $field['id'] ) ?>" class="field_custom_html frm_long_input"><?php echo FrmAppHelper::esc_textarea($field['custom_html']) ?></textarea></p>
236
+                                <textarea name="field_options[custom_html_<?php echo esc_attr( $field['id'] ) ?>]" rows="7" id="custom_html_<?php echo esc_attr( $field['id'] ) ?>" class="field_custom_html frm_long_input"><?php echo FrmAppHelper::esc_textarea( $field['custom_html'] ) ?></textarea></p>
237 237
                             <?php }
238
-                            unset($field);
238
+                            unset( $field );
239 239
                         }
240 240
                     } ?>
241 241
                 </div>
242 242
 
243 243
                 <p><label><?php _e( 'After Fields', 'formidable' ) ?></label>
244
-                <textarea name="options[after_html]" rows="3" id="after_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['after_html']) ?></textarea></p>
244
+                <textarea name="options[after_html]" rows="3" id="after_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['after_html'] ) ?></textarea></p>
245 245
 
246 246
                 <p><label><?php _e( 'Submit Button', 'formidable' ) ?></label>
247
-                <textarea name="options[submit_html]" rows="3" id="submit_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea($values['submit_html']) ?></textarea></p>
247
+                <textarea name="options[submit_html]" rows="3" id="submit_html" class="frm_long_input"><?php echo FrmAppHelper::esc_textarea( $values['submit_html'] ) ?></textarea></p>
248 248
             </div>
249 249
         </div>
250 250
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             </div>
264 264
         <?php } ?>
265 265
 
266
-        <?php do_action('frm_add_form_option_section', $values); ?>
266
+        <?php do_action( 'frm_add_form_option_section', $values ); ?>
267 267
         <div class="clear"></div>
268 268
         </div>
269 269
         </div>
Please login to merge, or discard this patch.
classes/views/frm-forms/sidebar-settings.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <div id="postbox-container-1" class="postbox-container">
2 2
     <?php
3 3
 
4
-    if ( ! isset($hide_preview) || ! $hide_preview ) {
4
+	if ( ! isset($hide_preview) || ! $hide_preview ) {
5 5
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
6
-    }
6
+	}
7 7
 
8 8
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/mb_insert_fields.php' );
9 9
 
10
-    ?>
10
+	?>
11 11
 </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <div id="postbox-container-1" class="postbox-container">
2 2
     <?php
3 3
 
4
-    if ( ! isset($hide_preview) || ! $hide_preview ) {
4
+    if ( ! isset( $hide_preview ) || ! $hide_preview ) {
5 5
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
6 6
     }
7 7
 
Please login to merge, or discard this patch.
classes/views/frm-form-actions/form_action.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@
 block discarded – undo
21 21
     </div>
22 22
     <div class="widget-inside frm_hidden">
23 23
         <?php
24
-        if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) {
25
-            // only load settings if they are just added or are open
24
+		if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) {
25
+			// only load settings if they are just added or are open
26 26
 			include( dirname( __FILE__ ) . '/_action_inside.php' );
27
-        } else {
28
-            // include hidden settings so action won't get lost on update ?>
27
+		} else {
28
+			// include hidden settings so action won't get lost on update ?>
29 29
         <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
30 30
         <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
31 31
         <?php
32
-        } ?>
32
+		} ?>
33 33
     </div>
34 34
 <style type="text/css">
35 35
 .frm_no_actions{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
     </div>
22 22
     <div class="widget-inside frm_hidden">
23 23
         <?php
24
-        if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) {
24
+        if ( defined( 'DOING_AJAX' ) || ! $action_control->action_options['ajax_load'] ) {
25 25
             // only load settings if they are just added or are open
26 26
 			include( dirname( __FILE__ ) . '/_action_inside.php' );
27 27
         } else {
28 28
             // include hidden settings so action won't get lost on update ?>
29
-        <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
30
-        <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
29
+        <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" />
30
+        <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" />
31 31
         <?php
32 32
         } ?>
33 33
     </div>
Please login to merge, or discard this patch.
classes/views/frm-form-actions/email_action.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@  discard block
 block discarded – undo
4 4
 
5 5
 	public function __construct() {
6 6
 		$action_ops = array(
7
-		    'classes'   => 'frm_email_icon frm_icon_font',
8
-            'active'    => true,
7
+			'classes'   => 'frm_email_icon frm_icon_font',
8
+			'active'    => true,
9 9
 			'event'     => array( 'create' ),
10
-            'limit'     => 99,
11
-            'priority'  => 10,
12
-            'ajax_load' => false,
10
+			'limit'     => 99,
11
+			'priority'  => 10,
12
+			'ajax_load' => false,
13 13
 		);
14 14
 		$action_ops = apply_filters('frm_email_control_settings', $action_ops);
15 15
 
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	public function form( $form_action, $args = array() ) {
20
-	    extract($args);
20
+		extract($args);
21 21
 
22 22
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' );
23 23
 	}
24 24
 
25 25
 	public function get_defaults() {
26
-	    return array(
27
-            'email_to'      => '[admin_email]',
28
-            'cc'            => '',
29
-            'bcc'           => '',
30
-            'from'          => '[sitename] <[admin_email]>',
31
-            'reply_to'      => '',
32
-            'email_subject' => '',
33
-            'email_message' => '[default-message]',
34
-            'inc_user_info' => 0,
35
-            'plain_text'    => 0,
26
+		return array(
27
+			'email_to'      => '[admin_email]',
28
+			'cc'            => '',
29
+			'bcc'           => '',
30
+			'from'          => '[sitename] <[admin_email]>',
31
+			'reply_to'      => '',
32
+			'email_subject' => '',
33
+			'email_message' => '[default-message]',
34
+			'inc_user_info' => 0,
35
+			'plain_text'    => 0,
36 36
 			'event'         => array( 'create' ),
37
-	    );
37
+		);
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
             'priority'  => 10,
12 12
             'ajax_load' => false,
13 13
 		);
14
-		$action_ops = apply_filters('frm_email_control_settings', $action_ops);
14
+		$action_ops = apply_filters( 'frm_email_control_settings', $action_ops );
15 15
 
16
-		parent::__construct('email', __( 'Email Notification', 'formidable' ), $action_ops);
16
+		parent::__construct( 'email', __( 'Email Notification', 'formidable' ), $action_ops );
17 17
 	}
18 18
 
19 19
 	public function form( $form_action, $args = array() ) {
20
-	    extract($args);
20
+	    extract( $args );
21 21
 
22 22
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' );
23 23
 	}
Please login to merge, or discard this patch.
classes/models/FrmField.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmField {
7
-    static $use_cache = true;
7
+	static $use_cache = true;
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
@@ -50,39 +50,39 @@  discard block
 block discarded – undo
50 50
 		));
51 51
 	}
52 52
 
53
-    public static function create( $values, $return = true ) {
54
-        global $wpdb, $frm_duplicate_ids;
53
+	public static function create( $values, $return = true ) {
54
+		global $wpdb, $frm_duplicate_ids;
55 55
 
56
-        $new_values = array();
57
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
56
+		$new_values = array();
57
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58 58
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
59 59
 
60 60
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
61 61
 			$new_values[ $col ] = $values[ $col ];
62
-        }
62
+		}
63 63
 
64
-        $new_values['options'] = $values['options'];
64
+		$new_values['options'] = $values['options'];
65 65
 
66
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
67
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
68
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
69
-        $new_values['field_options'] = $values['field_options'];
70
-        $new_values['created_at'] = current_time('mysql', 1);
66
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
67
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
68
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
69
+		$new_values['field_options'] = $values['field_options'];
70
+		$new_values['created_at'] = current_time('mysql', 1);
71 71
 
72 72
 		if ( isset( $values['id'] ) ) {
73 73
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
74
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
75
-        }
74
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
75
+		}
76 76
 
77 77
 		foreach ( $new_values as $k => $v ) {
78
-            if ( is_array( $v ) ) {
78
+			if ( is_array( $v ) ) {
79 79
 				$new_values[ $k ] = serialize( $v );
80 80
 			}
81
-            unset( $k, $v );
82
-        }
81
+			unset( $k, $v );
82
+		}
83 83
 
84
-        //if(isset($values['id']) and is_numeric($values['id']))
85
-        //    $new_values['id'] = $values['id'];
84
+		//if(isset($values['id']) and is_numeric($values['id']))
85
+		//    $new_values['id'] = $values['id'];
86 86
 
87 87
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
88 88
 		$new_id = 0;
@@ -103,22 +103,22 @@  discard block
 block discarded – undo
103 103
 		} else {
104 104
 			return false;
105 105
 		}
106
-    }
106
+	}
107 107
 
108
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
109
-        global $frm_duplicate_ids;
108
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
109
+		global $frm_duplicate_ids;
110 110
 
111 111
 		$where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) );
112 112
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
113 113
 
114
-        foreach ( (array) $fields as $field ) {
115
-            $new_key = ($copy_keys) ? $field->field_key : '';
116
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
117
-                $new_key = rtrim($new_key, 2);
118
-            }
114
+		foreach ( (array) $fields as $field ) {
115
+			$new_key = ($copy_keys) ? $field->field_key : '';
116
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
117
+				$new_key = rtrim($new_key, 2);
118
+			}
119 119
 
120
-            $values = array();
121
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
120
+			$values = array();
121
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
122 122
 
123 123
 			// If this is a repeating section, create new form
124 124
 			if ( self::is_repeating_field( $field ) ) {
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 				$values['form_id'] = $new_repeat_form_id;
138 138
 			}
139 139
 
140
-            $values = apply_filters('frm_duplicated_field', $values);
141
-            $new_id = self::create($values);
142
-            $frm_duplicate_ids[ $field->id ] = $new_id;
143
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
144
-            unset($field);
145
-        }
146
-    }
140
+			$values = apply_filters('frm_duplicated_field', $values);
141
+			$new_id = self::create($values);
142
+			$frm_duplicate_ids[ $field->id ] = $new_id;
143
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
144
+			unset($field);
145
+		}
146
+	}
147 147
 
148 148
 	public static function update( $id, $values ) {
149
-        global $wpdb;
149
+		global $wpdb;
150 150
 
151 151
 		$id = absint( $id );
152 152
 
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
155 155
 		}
156 156
 
157
-        if ( isset($values['required']) ) {
158
-            $values['required'] = (int) $values['required'];
159
-        }
157
+		if ( isset($values['required']) ) {
158
+			$values['required'] = (int) $values['required'];
159
+		}
160 160
 
161 161
 		self::preserve_phone_format_backslashes( $values );
162 162
 
@@ -169,41 +169,41 @@  discard block
 block discarded – undo
169 169
 
170 170
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
171 171
 
172
-        $form_id = 0;
172
+		$form_id = 0;
173 173
 		if ( isset( $values['form_id'] ) ) {
174
-            $form_id = absint( $values['form_id'] );
174
+			$form_id = absint( $values['form_id'] );
175 175
 		} else {
176
-            $field = self::getOne($id);
177
-            if ( $field ) {
178
-                $form_id = $field->form_id;
179
-            }
180
-            unset($field);
181
-        }
182
-        unset($values);
176
+			$field = self::getOne($id);
177
+			if ( $field ) {
178
+				$form_id = $field->form_id;
179
+			}
180
+			unset($field);
181
+		}
182
+		unset($values);
183 183
 
184 184
 		if ( $query_results ) {
185
-            wp_cache_delete( $id, 'frm_field' );
186
-            if ( $form_id ) {
187
-                self::delete_form_transient($form_id);
188
-            }
189
-        }
185
+			wp_cache_delete( $id, 'frm_field' );
186
+			if ( $form_id ) {
187
+				self::delete_form_transient($form_id);
188
+			}
189
+		}
190 190
 
191
-        return $query_results;
192
-    }
191
+		return $query_results;
192
+	}
193 193
 
194 194
 	/**
195
-	* Keep backslashes in the phone format option
196
-	*
197
-	* @since 2.0.8
198
-	* @param $values array - pass by reference
199
-	*/
195
+	 * Keep backslashes in the phone format option
196
+	 *
197
+	 * @since 2.0.8
198
+	 * @param $values array - pass by reference
199
+	 */
200 200
 	private static function preserve_phone_format_backslashes( &$values ) {
201 201
 		if ( isset( $values['field_options']['format'] ) ) {
202 202
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
203 203
 		}
204 204
 	}
205 205
 
206
-    public static function destroy( $id ) {
206
+	public static function destroy( $id ) {
207 207
 		global $wpdb;
208 208
 
209 209
 		do_action( 'frm_before_destroy_field', $id );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
220 220
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
221
-    }
221
+	}
222 222
 
223 223
 	public static function delete_form_transient( $form_id ) {
224 224
 		$form_id = absint( $form_id );
@@ -231,16 +231,16 @@  discard block
 block discarded – undo
231 231
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
232 232
 
233 233
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
234
-        wp_cache_delete($cache_key, 'frm_field');
234
+		wp_cache_delete($cache_key, 'frm_field');
235 235
 
236 236
 		// this cache key is autogenerated in FrmDb::get_var
237 237
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
238 238
 
239
-        $form = FrmForm::getOne($form_id);
240
-        if ( $form && $form->parent_form_id ) {
241
-            self::delete_form_transient( $form->parent_form_id );
242
-        }
243
-    }
239
+		$form = FrmForm::getOne($form_id);
240
+		if ( $form && $form->parent_form_id ) {
241
+			self::delete_form_transient( $form->parent_form_id );
242
+		}
243
+	}
244 244
 
245 245
 	/**
246 246
 	 * If $field is numeric, get the field object
@@ -256,131 +256,131 @@  discard block
 block discarded – undo
256 256
 			return;
257 257
 		}
258 258
 
259
-        global $wpdb;
259
+		global $wpdb;
260 260
 
261
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
261
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262 262
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
263 263
 
264
-        $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
264
+		$results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
265 265
 
266
-        if ( empty($results) ) {
267
-            return $results;
268
-        }
266
+		if ( empty($results) ) {
267
+			return $results;
268
+		}
269 269
 
270
-        if ( is_numeric($id) ) {
271
-            wp_cache_set( $results->field_key, $results, 'frm_field' );
272
-        } else if ( $results ) {
273
-            wp_cache_set( $results->id, $results, 'frm_field' );
274
-        }
270
+		if ( is_numeric($id) ) {
271
+			wp_cache_set( $results->field_key, $results, 'frm_field' );
272
+		} else if ( $results ) {
273
+			wp_cache_set( $results->id, $results, 'frm_field' );
274
+		}
275 275
 
276 276
 		self::prepare_options( $results );
277 277
 
278
-        return stripslashes_deep($results);
279
-    }
278
+		return stripslashes_deep($results);
279
+	}
280 280
 
281
-    /**
282
-     * Get the field type by key or id
283
-     * @param int|string The field id or key
281
+	/**
282
+	 * Get the field type by key or id
283
+	 * @param int|string The field id or key
284 284
 	 * @param mixed $col The name of the column in the fields database table
285
-     */
286
-    public static function &get_type( $id, $col = 'type' ) {
287
-        $field = FrmAppHelper::check_cache( $id, 'frm_field' );
288
-        if ( $field ) {
289
-            $type = $field->{$col};
290
-        } else {
291
-            $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
292
-        }
293
-
294
-        return $type;
295
-    }
285
+	 */
286
+	public static function &get_type( $id, $col = 'type' ) {
287
+		$field = FrmAppHelper::check_cache( $id, 'frm_field' );
288
+		if ( $field ) {
289
+			$type = $field->{$col};
290
+		} else {
291
+			$type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
292
+		}
293
+
294
+		return $type;
295
+	}
296 296
 
297 297
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
298
-        if ( ! $form_id ) {
299
-            return array();
300
-        }
298
+		if ( ! $form_id ) {
299
+			return array();
300
+		}
301 301
 
302 302
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) );
303 303
 		if ( ! empty( $results ) ) {
304
-            $fields = array();
305
-            $count = 0;
306
-            foreach ( $results as $result ) {
307
-                if ( $type != $result->type ) {
308
-                    continue;
309
-                }
304
+			$fields = array();
305
+			$count = 0;
306
+			foreach ( $results as $result ) {
307
+				if ( $type != $result->type ) {
308
+					continue;
309
+				}
310 310
 
311 311
 				$fields[ $result->id ] = $result;
312
-                $count++;
313
-                if ( $limit == 1 ) {
314
-                    $fields = $result;
315
-                    break;
316
-                }
312
+				$count++;
313
+				if ( $limit == 1 ) {
314
+					$fields = $result;
315
+					break;
316
+				}
317 317
 
318
-                if ( ! empty($limit) && $count >= $limit ) {
319
-                    break;
320
-                }
318
+				if ( ! empty($limit) && $count >= $limit ) {
319
+					break;
320
+				}
321 321
 
322
-                unset($result);
323
-            }
324
-            return stripslashes_deep($fields);
325
-        }
322
+				unset($result);
323
+			}
324
+			return stripslashes_deep($fields);
325
+		}
326 326
 
327
-        self::$use_cache = false;
327
+		self::$use_cache = false;
328 328
 
329 329
 		$where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type );
330 330
 		self::maybe_include_repeating_fields( $inc_sub, $where );
331 331
 		$results = self::getAll( $where, 'field_order', $limit );
332
-        self::$use_cache = true;
333
-        self::include_sub_fields($results, $inc_sub, $type);
332
+		self::$use_cache = true;
333
+		self::include_sub_fields($results, $inc_sub, $type);
334 334
 
335
-        return $results;
336
-    }
335
+		return $results;
336
+	}
337 337
 
338 338
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
339
-        if ( ! (int) $form_id ) {
340
-            return array();
341
-        }
339
+		if ( ! (int) $form_id ) {
340
+			return array();
341
+		}
342 342
 
343 343
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
344 344
 		if ( ! empty( $results ) ) {
345
-            if ( empty($limit) ) {
345
+			if ( empty($limit) ) {
346 346
 				return $results;
347
-            }
347
+			}
348 348
 
349
-            $fields = array();
350
-            $count = 0;
351
-            foreach ( $results as $result ) {
349
+			$fields = array();
350
+			$count = 0;
351
+			foreach ( $results as $result ) {
352 352
 				$fields[ $result->id ] = $result;
353
-                if ( ! empty($limit) && $count >= $limit ) {
354
-                    break;
355
-                }
356
-            }
353
+				if ( ! empty($limit) && $count >= $limit ) {
354
+					break;
355
+				}
356
+			}
357 357
 
358 358
 			return $fields;
359
-        }
359
+		}
360 360
 
361
-        self::$use_cache = false;
361
+		self::$use_cache = false;
362 362
 
363 363
 		$where = array( 'fi.form_id' => absint( $form_id ) );
364 364
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
365 365
 		$results = self::getAll( $where, 'field_order', $limit );
366 366
 
367
-        self::$use_cache = true;
367
+		self::$use_cache = true;
368 368
 
369 369
 		self::include_sub_fields( $results, $inc_embed, 'all' );
370 370
 
371
-        if ( empty($limit) ) {
371
+		if ( empty($limit) ) {
372 372
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
373
-        }
373
+		}
374 374
 
375 375
 		return $results;
376
-    }
376
+	}
377 377
 
378 378
 	/**
379
-	* If repeating fields should be included, adjust $where accordingly
380
-	*
381
-	* @param string $inc_repeat
382
-	* @param array $where - pass by reference
383
-	*/
379
+	 * If repeating fields should be included, adjust $where accordingly
380
+	 *
381
+	 * @param string $inc_repeat
382
+	 * @param array $where - pass by reference
383
+	 */
384 384
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
385 385
 		if ( $inc_repeat == 'include' ) {
386 386
 			$form_id = $where['fi.form_id'];
@@ -391,77 +391,77 @@  discard block
 block discarded – undo
391 391
 
392 392
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
393 393
 		if ( 'include' != $inc_embed ) {
394
-            return;
395
-        }
394
+			return;
395
+		}
396 396
 
397
-        $form_fields = $results;
397
+		$form_fields = $results;
398 398
 		$index_offset = 1;
399
-        foreach ( $form_fields as $k => $field ) {
400
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
-                continue;
402
-            }
403
-
404
-            if ( $type == 'all' ) {
405
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
406
-            } else {
407
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
-            }
409
-
410
-            if ( ! empty($sub_fields) ) {
399
+		foreach ( $form_fields as $k => $field ) {
400
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
+				continue;
402
+			}
403
+
404
+			if ( $type == 'all' ) {
405
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
406
+			} else {
407
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
+			}
409
+
410
+			if ( ! empty($sub_fields) ) {
411 411
 				$index = $k + $index_offset;
412 412
 				$index_offset += count( $sub_fields );
413 413
 				array_splice($results, $index, 0, $sub_fields);
414
-            }
415
-            unset($field, $sub_fields);
416
-        }
417
-    }
414
+			}
415
+			unset($field, $sub_fields);
416
+		}
417
+	}
418 418
 
419 419
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
420 420
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
421
-        if ( self::$use_cache ) {
422
-            // make sure old cache doesn't get saved as a transient
423
-            $results = wp_cache_get($cache_key, 'frm_field');
424
-            if ( false !== $results ) {
425
-                return stripslashes_deep($results);
426
-            }
427
-        }
428
-
429
-        global $wpdb;
430
-
431
-        if ( $blog_id && is_multisite() ) {
432
-            global $wpmuBaseTablePrefix;
433
-            if ( $wpmuBaseTablePrefix ) {
421
+		if ( self::$use_cache ) {
422
+			// make sure old cache doesn't get saved as a transient
423
+			$results = wp_cache_get($cache_key, 'frm_field');
424
+			if ( false !== $results ) {
425
+				return stripslashes_deep($results);
426
+			}
427
+		}
428
+
429
+		global $wpdb;
430
+
431
+		if ( $blog_id && is_multisite() ) {
432
+			global $wpmuBaseTablePrefix;
433
+			if ( $wpmuBaseTablePrefix ) {
434 434
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
435
-            } else {
436
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
437
-            }
435
+			} else {
436
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
437
+			}
438 438
 
439 439
 			$table_name = $prefix . 'frm_fields';
440 440
 			$form_table_name = $prefix . 'frm_forms';
441 441
 		} else {
442 442
 			$table_name = $wpdb->prefix . 'frm_fields';
443 443
 			$form_table_name = $wpdb->prefix . 'frm_forms';
444
-        }
444
+		}
445 445
 
446 446
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
447 447
 			$order_by = ' ORDER BY ' . $order_by;
448 448
 		}
449 449
 
450
-        $limit = FrmAppHelper::esc_limit($limit);
450
+		$limit = FrmAppHelper::esc_limit($limit);
451 451
 
452
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
453
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
452
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
453
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
454 454
 
455
-        if ( is_array($where) ) {
456
-            $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
455
+		if ( is_array($where) ) {
456
+			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
457 457
 		} else {
458 458
 			// if the query is not an array, then it has already been prepared
459
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
459
+			$query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460 460
 
461 461
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
462 462
 			$results = $wpdb->$function_name( $query );
463
-        }
464
-        unset( $where );
463
+		}
464
+		unset( $where );
465 465
 
466 466
 		self::format_field_results( $results );
467 467
 
@@ -560,21 +560,21 @@  discard block
 block discarded – undo
560 560
 
561 561
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
562 562
 		_deprecated_function( __FUNCTION__, '2.0' );
563
-        global $wpdb;
564
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
563
+		global $wpdb;
564
+		if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
565 565
 			$order_by = ' ORDER BY ' . $order_by;
566
-        }
566
+		}
567 567
 
568 568
 		$query = 'SELECT fi.id  FROM ' . $wpdb->prefix . 'frm_fields fi ' .
569 569
 			'LEFT OUTER JOIN '. $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' .
570 570
 			FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
571 571
 
572
-        $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
572
+		$method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
573 573
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
574
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
574
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575 575
 
576
-        return $results;
577
-    }
576
+		return $results;
577
+	}
578 578
 
579 579
 	public static function is_no_save_field( $type ) {
580 580
 		return in_array( $type, self::no_save_fields() );
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
 	}
702 702
 
703 703
 	/**
704
-	* @since 2.0.09
705
-	*/
704
+	 * @since 2.0.09
705
+	 */
706 706
 	public static function is_repeating_field( $field ) {
707 707
 		if ( is_array( $field ) ) {
708 708
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -712,12 +712,12 @@  discard block
 block discarded – undo
712 712
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
713 713
 	}
714 714
 
715
-    /**
716
-     * @param string $key
717
-     * @return int field id
718
-     */
715
+	/**
716
+	 * @param string $key
717
+	 * @return int field id
718
+	 */
719 719
 	public static function get_id_by_key( $key ) {
720
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
721
-        return $id;
722
-    }
720
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
721
+		return $id;
722
+	}
723 723
 }
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 
164 164
 		// serialize array values
165 165
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
166
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
167
-				$values[ $opt ] = serialize( $values[ $opt ] );
166
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
167
+				$values[$opt] = serialize( $values[$opt] );
168 168
 			}
169 169
 		}
170 170
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 		if ( isset( $values['form_id'] ) ) {
175 175
             $form_id = absint( $values['form_id'] );
176 176
 		} else {
177
-            $field = self::getOne($id);
177
+            $field = self::getOne( $id );
178 178
             if ( $field ) {
179 179
                 $form_id = $field->form_id;
180 180
             }
181
-            unset($field);
181
+            unset( $field );
182 182
         }
183
-        unset($values);
183
+        unset( $values );
184 184
 
185 185
 		if ( $query_results ) {
186 186
             wp_cache_delete( $id, 'frm_field' );
187 187
             if ( $form_id ) {
188
-                self::delete_form_transient($form_id);
188
+                self::delete_form_transient( $form_id );
189 189
             }
190 190
         }
191 191
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
233 233
 
234 234
 		$cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb';
235
-        wp_cache_delete($cache_key, 'frm_field');
235
+        wp_cache_delete( $cache_key, 'frm_field' );
236 236
 
237 237
 		// this cache key is autogenerated in FrmDb::get_var
238 238
 		wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
240
+        $form = FrmForm::getOne( $form_id );
241 241
         if ( $form && $form->parent_form_id ) {
242 242
             self::delete_form_transient( $form->parent_form_id );
243 243
         }
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 
260 260
         global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265 265
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
267
+        if ( empty( $results ) ) {
268 268
             return $results;
269 269
         }
270 270
 
271
-        if ( is_numeric($id) ) {
271
+        if ( is_numeric( $id ) ) {
272 272
             wp_cache_set( $results->field_key, $results, 'frm_field' );
273 273
         } else if ( $results ) {
274 274
             wp_cache_set( $results->id, $results, 'frm_field' );
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
279
+        return stripslashes_deep( $results );
280 280
     }
281 281
 
282 282
     /**
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
                     continue;
310 310
                 }
311 311
 
312
-				$fields[ $result->id ] = $result;
313
-                $count++;
312
+				$fields[$result->id] = $result;
313
+                $count ++;
314 314
                 if ( $limit == 1 ) {
315 315
                     $fields = $result;
316 316
                     break;
317 317
                 }
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
319
+                if ( ! empty( $limit ) && $count >= $limit ) {
320 320
                     break;
321 321
                 }
322 322
 
323
-                unset($result);
323
+                unset( $result );
324 324
             }
325
-            return stripslashes_deep($fields);
325
+            return stripslashes_deep( $fields );
326 326
         }
327 327
 
328 328
         self::$use_cache = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333 333
         self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
334
+        self::include_sub_fields( $results, $inc_sub, $type );
335 335
 
336 336
         return $results;
337 337
     }
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+            if ( empty( $limit ) ) {
347 347
 				return $results;
348 348
             }
349 349
 
350 350
             $fields = array();
351 351
             $count = 0;
352 352
             foreach ( $results as $result ) {
353
-				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
353
+				$fields[$result->id] = $result;
354
+                if ( ! empty( $limit ) && $count >= $limit ) {
355 355
                     break;
356 356
                 }
357 357
             }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+        if ( empty( $limit ) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374 374
         }
375 375
 
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
         $form_fields = $results;
399 399
 		$index_offset = 1;
400 400
         foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
402 402
                 continue;
403 403
             }
404 404
 
405 405
             if ( $type == 'all' ) {
406 406
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407 407
             } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
409 409
             }
410 410
 
411
-            if ( ! empty($sub_fields) ) {
411
+            if ( ! empty( $sub_fields ) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414
-				array_splice($results, $index, 0, $sub_fields);
414
+				array_splice( $results, $index, 0, $sub_fields );
415 415
             }
416
-            unset($field, $sub_fields);
416
+            unset( $field, $sub_fields );
417 417
         }
418 418
     }
419 419
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422 422
         if ( self::$use_cache ) {
423 423
             // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
424
+            $results = wp_cache_get( $cache_key, 'frm_field' );
425 425
             if ( false !== $results ) {
426
-                return stripslashes_deep($results);
426
+                return stripslashes_deep( $results );
427 427
             }
428 428
         }
429 429
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+        $limit = FrmAppHelper::esc_limit( $limit );
452 452
 
453 453
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454 454
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
456
+        if ( is_array( $where ) ) {
457 457
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 				wp_cache_set( $result->id, $result, 'frm_field' );
481 481
 				wp_cache_set( $result->field_key, $result, 'frm_field' );
482 482
 
483
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
484
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
485
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
483
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
484
+				$results[$r_key]->options = maybe_unserialize( $result->options );
485
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
486 486
 
487 487
 				unset( $r_key, $result );
488 488
 			}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	private static function prepare_options( &$results ) {
502 502
 		$results->field_options = maybe_unserialize( $results->field_options );
503 503
 
504
-		$results->options = maybe_unserialize($results->options);
505
-		$results->default_value = maybe_unserialize($results->default_value);
504
+		$results->options = maybe_unserialize( $results->options );
505
+		$results->default_value = maybe_unserialize( $results->default_value );
506 506
 	}
507 507
 
508 508
 	/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 			if ( count( $next_fields ) >= self::$transient_size ) {
531 531
 				// if this transient is full, check for another
532
-				$next++;
532
+				$next ++;
533 533
 				self::get_next_transient( $fields, $base_name, $next );
534 534
 			}
535 535
 		}
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 				return;
556 556
 			}
557 557
 
558
-			$next++;
558
+			$next ++;
559 559
 		}
560 560
 	}
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564 564
         global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
565
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567 567
         }
568 568
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
576 576
 
577 577
         return $results;
578 578
     }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 			$is_multi_value_field = (
604 604
 				$field['type'] == 'checkbox' ||
605 605
 				$field['type'] == 'address' ||
606
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
606
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
607 607
 				self::is_multiple_select( $field )
608 608
 			);
609 609
 
@@ -627,9 +627,9 @@  discard block
 block discarded – undo
627 627
 	 */
628 628
 	public static function is_multiple_select( $field ) {
629 629
 		if ( is_array( $field ) ) {
630
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
630
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
631 631
 		} else {
632
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
632
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
633 633
 		}
634 634
 	}
635 635
 
@@ -676,23 +676,23 @@  discard block
 block discarded – undo
676 676
 	}
677 677
 
678 678
 	public static function is_option_true_in_array( $field, $option ) {
679
-		return isset( $field[ $option ] ) && $field[ $option ];
679
+		return isset( $field[$option] ) && $field[$option];
680 680
 	}
681 681
 
682 682
 	public static function is_option_true_in_object( $field, $option ) {
683
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
683
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
684 684
 	}
685 685
 
686 686
 	public static function is_option_empty_in_array( $field, $option ) {
687
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
687
+		return ! isset( $field[$option] ) || empty( $field[$option] );
688 688
 	}
689 689
 
690 690
 	public static function is_option_empty_in_object( $field, $option ) {
691
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
691
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
692 692
 	}
693 693
 
694 694
 	public static function is_option_value_in_object( $field, $option ) {
695
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
695
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
696 696
 	}
697 697
 
698 698
 	/**
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 	}
709 709
 
710 710
 	public static function get_option_in_array( $field, $option ) {
711
-		return $field[ $option ];
711
+		return $field[$option];
712 712
 	}
713 713
 
714 714
 	public static function get_option_in_object( $field, $option ) {
715
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
715
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
716 716
 	}
717 717
 
718 718
 	/**
Please login to merge, or discard this patch.
classes/models/FrmFormAction.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	public $action_options;     // Option array passed to wp_register_sidebar_widget()
9 9
 	public $control_options;	// Option array passed to wp_register_widget_control()
10 10
 
11
-    public $form_id;        // The ID of the form to evaluate
11
+	public $form_id;        // The ID of the form to evaluate
12 12
 	public $number = false;	// Unique ID number of the current instance.
13 13
 	public $id = '';		// Unique ID string of the current instance (id_base-number)
14 14
 	public $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 	/**
32
-     * Echo the settings update form
32
+	 * Echo the settings update form
33 33
 	 *
34 34
 	 * @param array $instance Current settings
35 35
 	 */
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @return array of the default options
43 43
 	 */
44 44
 	public function get_defaults() {
45
-	    return array();
45
+		return array();
46 46
 	}
47 47
 
48 48
 	public function get_switch_fields() {
49
-	    return array();
49
+		return array();
50 50
 	}
51 51
 
52 52
 	public function migrate_values( $action, $form ) {
53
-	    return $action;
53
+		return $action;
54 54
 	}
55 55
 
56 56
 	// Functions you'll need to call.
@@ -69,24 +69,24 @@  discard block
 block discarded – undo
69 69
 	 *	 - height: currently not used but may be needed in the future
70 70
 	 */
71 71
 	public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
-	    if ( ! defined('ABSPATH') ) {
73
-            die('You are not allowed to call this page directly.');
74
-        }
72
+		if ( ! defined('ABSPATH') ) {
73
+			die('You are not allowed to call this page directly.');
74
+		}
75 75
 
76 76
 		$this->id_base = strtolower($id_base);
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
80
-        $default_options = array(
81
-            'classes'   => '',
82
-            'active'    => true,
80
+		$default_options = array(
81
+			'classes'   => '',
82
+			'active'    => true,
83 83
 			'event'     => array( 'create' ),
84
-            'limit'     => 1,
85
-            'force_event' => false,
86
-            'priority'  => 20,
87
-            'ajax_load' => true,
88
-            'tooltip'   => $name,
89
-        );
84
+			'limit'     => 1,
85
+			'force_event' => false,
86
+			'priority'  => 20,
87
+			'ajax_load' => true,
88
+			'tooltip'   => $name,
89
+		);
90 90
 
91 91
 		$action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
92 92
 		$this->action_options = wp_parse_args( $action_options, $default_options );
@@ -135,132 +135,132 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	public function prepare_new( $form_id = false ) {
138
-        if ( $form_id ) {
139
-            $this->form_id = $form_id;
140
-        }
141
-
142
-        $post_content = array();
143
-        $default_values = $this->get_global_defaults();
144
-
145
-        // fill default values
146
-        $post_content = wp_parse_args( $post_content, $default_values);
147
-
148
-        if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
-            $post_content['event'] = array( reset($this->action_options['event']) );
150
-        }
151
-
152
-        $form_action = array(
153
-            'post_title'    => $this->name,
154
-            'post_content'  => $post_content,
155
-            'post_excerpt'  => $this->id_base,
156
-            'ID'            => '',
157
-            'post_status'   => 'publish',
158
-            'post_type'     => FrmFormActionsController::$action_post_type,
138
+		if ( $form_id ) {
139
+			$this->form_id = $form_id;
140
+		}
141
+
142
+		$post_content = array();
143
+		$default_values = $this->get_global_defaults();
144
+
145
+		// fill default values
146
+		$post_content = wp_parse_args( $post_content, $default_values);
147
+
148
+		if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
+			$post_content['event'] = array( reset($this->action_options['event']) );
150
+		}
151
+
152
+		$form_action = array(
153
+			'post_title'    => $this->name,
154
+			'post_content'  => $post_content,
155
+			'post_excerpt'  => $this->id_base,
156
+			'ID'            => '',
157
+			'post_status'   => 'publish',
158
+			'post_type'     => FrmFormActionsController::$action_post_type,
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
-            'menu_order'    => $this->form_id,
161
-        );
162
-        unset($post_content);
160
+			'menu_order'    => $this->form_id,
161
+		);
162
+		unset($post_content);
163 163
 
164
-        return (object) $form_action;
165
-    }
164
+		return (object) $form_action;
165
+	}
166 166
 
167 167
 	public function create( $form_id ) {
168
-        $this->form_id = $form_id;
168
+		$this->form_id = $form_id;
169 169
 
170
-        $action = $this->prepare_new();
170
+		$action = $this->prepare_new();
171 171
 
172
-        return $this->save_settings($action);
173
-    }
172
+		return $this->save_settings($action);
173
+	}
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
176
-        if ( $form_id == $old_id ) {
177
-            // don't duplicate the actions if this is a template getting updated
178
-            return;
179
-        }
180
-
181
-        $this->form_id = $old_id;
182
-        $actions = $this->get_all( $old_id );
183
-
184
-        $this->form_id = $form_id;
185
-        foreach ( $actions as $action ) {
186
-            $this->duplicate_one($action, $form_id);
187
-            unset($action);
188
-        }
189
-    }
190
-
191
-    /* Check if imported action should be created or updated
176
+		if ( $form_id == $old_id ) {
177
+			// don't duplicate the actions if this is a template getting updated
178
+			return;
179
+		}
180
+
181
+		$this->form_id = $old_id;
182
+		$actions = $this->get_all( $old_id );
183
+
184
+		$this->form_id = $form_id;
185
+		foreach ( $actions as $action ) {
186
+			$this->duplicate_one($action, $form_id);
187
+			unset($action);
188
+		}
189
+	}
190
+
191
+	/* Check if imported action should be created or updated
192 192
     *
193 193
     * Since 2.0
194 194
     *
195 195
     * @param array $action
196 196
     * @return integer $post_id
197 197
     */
198
-    public function maybe_create_action( $action, $forms ) {
198
+	public function maybe_create_action( $action, $forms ) {
199 199
 		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
200
-            // Update action only
201
-            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
-            $post_id = $this->save_settings( $action );
203
-        } else {
204
-            // Create action
205
-            $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
-            $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
-        }
208
-        return $post_id;
209
-    }
200
+			// Update action only
201
+			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
+			$post_id = $this->save_settings( $action );
203
+		} else {
204
+			// Create action
205
+			$action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
+			$post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
+		}
208
+		return $post_id;
209
+	}
210 210
 
211 211
 	public function duplicate_one( $action, $form_id ) {
212
-        global $frm_duplicate_ids;
212
+		global $frm_duplicate_ids;
213 213
 
214
-        $action->menu_order = $form_id;
215
-        $switch = $this->get_global_switch_fields();
216
-        foreach ( (array) $action->post_content as $key => $val ) {
214
+		$action->menu_order = $form_id;
215
+		$switch = $this->get_global_switch_fields();
216
+		foreach ( (array) $action->post_content as $key => $val ) {
217 217
 			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218 218
 				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
219
-            } else if ( ! is_array( $val ) ) {
219
+			} else if ( ! is_array( $val ) ) {
220 220
 				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221 221
 			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
222
-                // loop through each value if empty
222
+				// loop through each value if empty
223 223
 				if ( empty( $switch[ $key ] ) ) {
224 224
 					$switch[ $key ] = array_keys( $val );
225 225
 				}
226 226
 
227 227
 				foreach ( $switch[ $key ] as $subkey ) {
228 228
 					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
229
-                }
230
-            }
229
+				}
230
+			}
231 231
 
232
-            unset($key, $val);
233
-        }
234
-        unset($action->ID);
232
+			unset($key, $val);
233
+		}
234
+		unset($action->ID);
235 235
 
236
-        return $this->save_settings($action);
237
-    }
236
+		return $this->save_settings($action);
237
+	}
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240
-        global $frm_duplicate_ids;
240
+		global $frm_duplicate_ids;
241 241
 
242
-        if ( is_array($subkey) ) {
243
-            foreach ( $subkey as $subkey2 ) {
244
-                foreach ( (array) $val as $ck => $cv ) {
245
-                    if ( is_array($cv) ) {
242
+		if ( is_array($subkey) ) {
243
+			foreach ( $subkey as $subkey2 ) {
244
+				foreach ( (array) $val as $ck => $cv ) {
245
+					if ( is_array($cv) ) {
246 246
 						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247 247
 					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248 248
 						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
249
-                    }
250
-                }
251
-            }
252
-        } else {
253
-            foreach ( (array) $val as $ck => $cv ) {
254
-                if ( is_array($cv) ) {
249
+					}
250
+				}
251
+			}
252
+		} else {
253
+			foreach ( (array) $val as $ck => $cv ) {
254
+				if ( is_array($cv) ) {
255 255
 					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256 256
 				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257 257
 					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
258
-                }
259
-            }
260
-        }
258
+				}
259
+			}
260
+		}
261 261
 
262
-        return $action;
263
-    }
262
+		return $action;
263
+	}
264 264
 
265 265
 	/**
266 266
 	 * Deal with changed settings.
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 */
271 271
  	public function update_callback( $form_id ) {
272
-        $this->form_id = $form_id;
272
+		$this->form_id = $form_id;
273 273
 
274 274
  		$all_instances = $this->get_settings();
275 275
 
@@ -284,25 +284,25 @@  discard block
 block discarded – undo
284 284
  			return;
285 285
  		}
286 286
 
287
-        $action_ids = array();
287
+		$action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290 290
  			$this->_set($number);
291 291
 
292 292
  			if ( ! isset($new_instance['post_title']) ) {
293
- 			    // settings were never opened, so don't update
294
- 			    $action_ids[] = $new_instance['ID'];
295
-         		$this->updated = true;
296
-         		continue;
293
+ 				// settings were never opened, so don't update
294
+ 				$action_ids[] = $new_instance['ID'];
295
+		 		$this->updated = true;
296
+		 		continue;
297 297
  			}
298 298
 
299 299
 			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
300 300
 
301 301
  			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
302 302
 			$new_instance['post_name']  = $this->form_id . '_' . $this->id_base . '_' . $this->number;
303
-            $new_instance['menu_order']   = $this->form_id;
304
-            $new_instance['post_status']  = 'publish';
305
-            $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
303
+			$new_instance['menu_order']   = $this->form_id;
304
+			$new_instance['post_status']  = 'publish';
305
+			$new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
306 306
 
307 307
  			$instance = $this->update( $new_instance, $old_instance );
308 308
 
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 				$all_instances[ $number ] = $instance;
329 329
 			}
330 330
 
331
-            $action_ids[] = $this->save_settings($instance);
331
+			$action_ids[] = $this->save_settings($instance);
332 332
 
333
-     		$this->updated = true;
333
+	 		$this->updated = true;
334 334
  		}
335 335
 
336 336
  		return $action_ids;
@@ -342,100 +342,100 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	public function get_single_action( $id ) {
345
-	    $action = get_post($id);
345
+		$action = get_post($id);
346 346
 		if ( $action ) {
347 347
 			$action = $this->prepare_action( $action );
348 348
 			$this->_set( $id );
349 349
 		}
350
-	    return $action;
350
+		return $action;
351 351
 	}
352 352
 
353 353
 	public function get_one( $form_id ) {
354
-	    return $this->get_all($form_id, 1);
354
+		return $this->get_all($form_id, 1);
355 355
 	}
356 356
 
357
-    public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
-        $action_controls = FrmFormActionsController::get_form_actions( $type );
359
-        if ( empty($action_controls) ) {
360
-            // don't continue if there are no available actions
361
-            return array();
362
-        }
357
+	public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
+		$action_controls = FrmFormActionsController::get_form_actions( $type );
359
+		if ( empty($action_controls) ) {
360
+			// don't continue if there are no available actions
361
+			return array();
362
+		}
363 363
 
364
-        if ( 'all' != $type ) {
365
-            return $action_controls->get_all( $form_id, $limit );
366
-        }
364
+		if ( 'all' != $type ) {
365
+			return $action_controls->get_all( $form_id, $limit );
366
+		}
367 367
 
368 368
 		$args = self::action_args( $form_id, $limit );
369 369
 		$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
370 370
 
371
-        if ( ! $actions ) {
372
-            return array();
373
-        }
371
+		if ( ! $actions ) {
372
+			return array();
373
+		}
374 374
 
375
-        $settings = array();
376
-        foreach ( $actions as $action ) {
375
+		$settings = array();
376
+		foreach ( $actions as $action ) {
377 377
 			// some plugins/themes are formatting the post_excerpt
378 378
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
379 379
 
380 380
 			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
381
-                continue;
382
-            }
381
+				continue;
382
+			}
383 383
 
384
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
384
+			$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
385 385
 			$settings[ $action->ID ] = $action;
386 386
 
387 387
 			if ( count( $settings ) >= $limit ) {
388 388
 				break;
389 389
 			}
390
-        }
390
+		}
391 391
 
392
-        if ( 1 === $limit ) {
393
-            $settings = reset($settings);
394
-        }
392
+		if ( 1 === $limit ) {
393
+			$settings = reset($settings);
394
+		}
395 395
 
396
-        return $settings;
397
-    }
396
+		return $settings;
397
+	}
398 398
 
399 399
 	public function get_all( $form_id = false, $limit = 99 ) {
400
-	    if ( $form_id ) {
401
-	        $this->form_id = $form_id;
402
-	    }
400
+		if ( $form_id ) {
401
+			$this->form_id = $form_id;
402
+		}
403 403
 
404
-	    $type = $this->id_base;
404
+		$type = $this->id_base;
405 405
 
406
-	    global $frm_vars;
407
-	    $frm_vars['action_type'] = $type;
406
+		global $frm_vars;
407
+		$frm_vars['action_type'] = $type;
408 408
 
409
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
409
+		add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
410 410
 		$query = self::action_args( $form_id, $limit );
411
-        $query['post_status']      = 'any';
412
-        $query['suppress_filters'] = false;
411
+		$query['post_status']      = 'any';
412
+		$query['suppress_filters'] = false;
413 413
 
414 414
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
415
-        unset($query);
415
+		unset($query);
416 416
 
417
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
417
+		remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
418 418
 
419
-        if ( empty($actions) ) {
420
-            return array();
421
-        }
419
+		if ( empty($actions) ) {
420
+			return array();
421
+		}
422 422
 
423
-        $settings = array();
424
-        foreach ( $actions as $action ) {
425
-            if ( count($settings) >= $limit ) {
426
-                continue;
427
-            }
423
+		$settings = array();
424
+		foreach ( $actions as $action ) {
425
+			if ( count($settings) >= $limit ) {
426
+				continue;
427
+			}
428 428
 
429
-            $action = $this->prepare_action($action);
429
+			$action = $this->prepare_action($action);
430 430
 
431 431
 			$settings[ $action->ID ] = $action;
432
-        }
432
+		}
433 433
 
434
-        if ( 1 === $limit ) {
435
-            $settings = reset($settings);
436
-        }
434
+		if ( 1 === $limit ) {
435
+			$settings = reset($settings);
436
+		}
437 437
 
438
-        return $settings;
438
+		return $settings;
439 439
 	}
440 440
 
441 441
 	public static function action_args( $form_id = 0, $limit = 99 ) {
@@ -458,45 +458,45 @@  discard block
 block discarded – undo
458 458
 		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
459 459
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
460 460
 
461
-        $default_values = $this->get_global_defaults();
461
+		$default_values = $this->get_global_defaults();
462 462
 
463
-        // fill default values
464
-        $action->post_content += $default_values;
463
+		// fill default values
464
+		$action->post_content += $default_values;
465 465
 
466
-        foreach ( $default_values as $k => $vals ) {
467
-            if ( is_array($vals) && ! empty($vals) ) {
466
+		foreach ( $default_values as $k => $vals ) {
467
+			if ( is_array($vals) && ! empty($vals) ) {
468 468
 				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
469
-                    continue;
470
-                }
469
+					continue;
470
+				}
471 471
 				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
472
-            }
473
-        }
472
+			}
473
+		}
474 474
 
475
-        if ( ! is_array($action->post_content['event']) ) {
476
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
477
-        }
475
+		if ( ! is_array($action->post_content['event']) ) {
476
+			$action->post_content['event'] = explode(',', $action->post_content['event']);
477
+		}
478 478
 
479
-        return $action;
479
+		return $action;
480 480
 	}
481 481
 
482 482
 	public function destroy( $form_id = false, $type = 'default' ) {
483
-	    global $wpdb;
483
+		global $wpdb;
484 484
 
485
-	    $this->form_id = $form_id;
485
+		$this->form_id = $form_id;
486 486
 
487
-	    $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
488
-	    if ( $form_id ) {
489
-	        $query['menu_order'] = $form_id;
490
-	    }
491
-	    if ( 'all' != $type ) {
492
-	        $query['post_excerpt'] = $this->id_base;
493
-	    }
487
+		$query = array( 'post_type' => FrmFormActionsController::$action_post_type );
488
+		if ( $form_id ) {
489
+			$query['menu_order'] = $form_id;
490
+		}
491
+		if ( 'all' != $type ) {
492
+			$query['post_excerpt'] = $this->id_base;
493
+		}
494 494
 
495
-        $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
495
+		$post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
496 496
 
497
-        foreach ( $post_ids as $id ) {
498
-            wp_delete_post($id);
499
-        }
497
+		foreach ( $post_ids as $id ) {
498
+			wp_delete_post($id);
499
+		}
500 500
 		self::clear_cache();
501 501
 	}
502 502
 
@@ -514,69 +514,69 @@  discard block
 block discarded – undo
514 514
 	}
515 515
 
516 516
 	public function get_global_defaults() {
517
-	    $defaults = $this->get_defaults();
517
+		$defaults = $this->get_defaults();
518 518
 
519
-	    if ( ! isset($defaults['event']) ) {
519
+		if ( ! isset($defaults['event']) ) {
520 520
 			$defaults['event'] = array( 'create' );
521
-	    }
521
+		}
522 522
 
523
-	    if ( ! isset($defaults['conditions']) ) {
524
-	        $defaults['conditions'] = array(
525
-                'send_stop' => '',
526
-                'any_all'   => '',
527
-            );
528
-        }
523
+		if ( ! isset($defaults['conditions']) ) {
524
+			$defaults['conditions'] = array(
525
+				'send_stop' => '',
526
+				'any_all'   => '',
527
+			);
528
+		}
529 529
 
530
-        return $defaults;
530
+		return $defaults;
531 531
 	}
532 532
 
533 533
 	public function get_global_switch_fields() {
534
-	    $switch = $this->get_switch_fields();
534
+		$switch = $this->get_switch_fields();
535 535
 		$switch['conditions'] = array( 'hide_field' );
536
-	    return $switch;
536
+		return $switch;
537 537
 	}
538 538
 
539 539
 	/**
540 540
 	 * Migrate settings from form->options into new action.
541 541
 	 */
542 542
 	public function migrate_to_2( $form, $update = 'update' ) {
543
-        $action = $this->prepare_new($form->id);
544
-        $form->options = maybe_unserialize($form->options);
543
+		$action = $this->prepare_new($form->id);
544
+		$form->options = maybe_unserialize($form->options);
545 545
 
546
-        // fill with existing options
547
-        foreach ( $action->post_content as $name => $val ) {
546
+		// fill with existing options
547
+		foreach ( $action->post_content as $name => $val ) {
548 548
 			if ( isset( $form->options[ $name ] ) ) {
549 549
 				$action->post_content[ $name ] = $form->options[ $name ];
550 550
 				unset( $form->options[ $name ] );
551
-            }
552
-        }
551
+			}
552
+		}
553 553
 
554
-        $action = $this->migrate_values($action, $form);
554
+		$action = $this->migrate_values($action, $form);
555 555
 
556
-        // check if action already exists
557
-        $post_id = get_posts( array(
558
-            'name'          => $action->post_name,
559
-            'post_type'     => FrmFormActionsController::$action_post_type,
560
-            'post_status'   => $action->post_status,
561
-            'numberposts'   => 1,
562
-        ) );
556
+		// check if action already exists
557
+		$post_id = get_posts( array(
558
+			'name'          => $action->post_name,
559
+			'post_type'     => FrmFormActionsController::$action_post_type,
560
+			'post_status'   => $action->post_status,
561
+			'numberposts'   => 1,
562
+		) );
563 563
 
564
-        if ( empty($post_id) ) {
565
-            // create action now
566
-            $post_id = $this->save_settings($action);
567
-        }
564
+		if ( empty($post_id) ) {
565
+			// create action now
566
+			$post_id = $this->save_settings($action);
567
+		}
568 568
 
569
-        if ( $post_id && 'update' == $update ) {
570
-            global $wpdb;
571
-            $form->options = maybe_serialize($form->options);
569
+		if ( $post_id && 'update' == $update ) {
570
+			global $wpdb;
571
+			$form->options = maybe_serialize($form->options);
572 572
 
573
-            // update form options
573
+			// update form options
574 574
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
575
-            wp_cache_delete( $form->id, 'frm_form');
576
-        }
575
+			wp_cache_delete( $form->id, 'frm_form');
576
+		}
577 577
 
578
-        return $post_id;
579
-    }
578
+		return $post_id;
579
+	}
580 580
 
581 581
 	public static function action_conditions_met( $action, $entry ) {
582 582
 		$notification = $action->post_content;
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormAction {
4 4
 
5
-	public $id_base;			// Root id for all actions of this type.
6
-	public $name;				// Name for this action type.
5
+	public $id_base; // Root id for all actions of this type.
6
+	public $name; // Name for this action type.
7 7
 	public $option_name;
8
-	public $action_options;     // Option array passed to wp_register_sidebar_widget()
9
-	public $control_options;	// Option array passed to wp_register_widget_control()
8
+	public $action_options; // Option array passed to wp_register_sidebar_widget()
9
+	public $control_options; // Option array passed to wp_register_widget_control()
10 10
 
11
-    public $form_id;        // The ID of the form to evaluate
12
-	public $number = false;	// Unique ID number of the current instance.
13
-	public $id = '';		// Unique ID string of the current instance (id_base-number)
14
-	public $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
11
+    public $form_id; // The ID of the form to evaluate
12
+	public $number = false; // Unique ID number of the current instance.
13
+	public $id = ''; // Unique ID string of the current instance (id_base-number)
14
+	public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice.
15 15
 
16 16
 	// Member functions that you must over-ride.
17 17
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 *	 - height: currently not used but may be needed in the future
70 70
 	 */
71 71
 	public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
-	    if ( ! defined('ABSPATH') ) {
73
-            die('You are not allowed to call this page directly.');
72
+	    if ( ! defined( 'ABSPATH' ) ) {
73
+            die( 'You are not allowed to call this page directly.' );
74 74
         }
75 75
 
76
-		$this->id_base = strtolower($id_base);
76
+		$this->id_base = strtolower( $id_base );
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
         $default_values = $this->get_global_defaults();
144 144
 
145 145
         // fill default values
146
-        $post_content = wp_parse_args( $post_content, $default_values);
146
+        $post_content = wp_parse_args( $post_content, $default_values );
147 147
 
148
-        if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
-            $post_content['event'] = array( reset($this->action_options['event']) );
148
+        if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) {
149
+            $post_content['event'] = array( reset( $this->action_options['event'] ) );
150 150
         }
151 151
 
152 152
         $form_action = array(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160 160
             'menu_order'    => $this->form_id,
161 161
         );
162
-        unset($post_content);
162
+        unset( $post_content );
163 163
 
164 164
         return (object) $form_action;
165 165
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
         $action = $this->prepare_new();
171 171
 
172
-        return $this->save_settings($action);
172
+        return $this->save_settings( $action );
173 173
     }
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 
184 184
         $this->form_id = $form_id;
185 185
         foreach ( $actions as $action ) {
186
-            $this->duplicate_one($action, $form_id);
187
-            unset($action);
186
+            $this->duplicate_one( $action, $form_id );
187
+            unset( $action );
188 188
         }
189 189
     }
190 190
 
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
     * @return integer $post_id
197 197
     */
198 198
     public function maybe_create_action( $action, $forms ) {
199
-		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
199
+		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) {
200 200
             // Update action only
201 201
             $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202 202
             $post_id = $this->save_settings( $action );
203 203
         } else {
204 204
             // Create action
205
-            $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
-            $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
205
+            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
206
+            $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] );
207 207
         }
208 208
         return $post_id;
209 209
     }
@@ -214,47 +214,47 @@  discard block
 block discarded – undo
214 214
         $action->menu_order = $form_id;
215 215
         $switch = $this->get_global_switch_fields();
216 216
         foreach ( (array) $action->post_content as $key => $val ) {
217
-			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218
-				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
217
+			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) {
218
+				$action->post_content[$key] = $frm_duplicate_ids[$val];
219 219
             } else if ( ! is_array( $val ) ) {
220
-				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221
-			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
220
+				$action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val );
221
+			} else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) {
222 222
                 // loop through each value if empty
223
-				if ( empty( $switch[ $key ] ) ) {
224
-					$switch[ $key ] = array_keys( $val );
223
+				if ( empty( $switch[$key] ) ) {
224
+					$switch[$key] = array_keys( $val );
225 225
 				}
226 226
 
227
-				foreach ( $switch[ $key ] as $subkey ) {
228
-					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
227
+				foreach ( $switch[$key] as $subkey ) {
228
+					$action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val );
229 229
                 }
230 230
             }
231 231
 
232
-            unset($key, $val);
232
+            unset( $key, $val );
233 233
         }
234
-        unset($action->ID);
234
+        unset( $action->ID );
235 235
 
236
-        return $this->save_settings($action);
236
+        return $this->save_settings( $action );
237 237
     }
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240 240
         global $frm_duplicate_ids;
241 241
 
242
-        if ( is_array($subkey) ) {
242
+        if ( is_array( $subkey ) ) {
243 243
             foreach ( $subkey as $subkey2 ) {
244 244
                 foreach ( (array) $val as $ck => $cv ) {
245
-                    if ( is_array($cv) ) {
246
-						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247
-					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248
-						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
245
+                    if ( is_array( $cv ) ) {
246
+						$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv );
247
+					} else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) {
248
+						$action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]];
249 249
                     }
250 250
                 }
251 251
             }
252 252
         } else {
253 253
             foreach ( (array) $val as $ck => $cv ) {
254
-                if ( is_array($cv) ) {
255
-					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256
-				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257
-					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
254
+                if ( is_array( $cv ) ) {
255
+					$action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv );
256
+				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) {
257
+					$action[$ck] = $frm_duplicate_ids[$cv];
258 258
                 }
259 259
             }
260 260
         }
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
  			return;
279 279
  		}
280 280
 
281
-		if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
282
-			$settings = $_POST[ $this->option_name ];
281
+		if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) {
282
+			$settings = $_POST[$this->option_name];
283 283
  		} else {
284 284
  			return;
285 285
  		}
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
         $action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290
- 			$this->_set($number);
290
+ 			$this->_set( $number );
291 291
 
292
- 			if ( ! isset($new_instance['post_title']) ) {
292
+ 			if ( ! isset( $new_instance['post_title'] ) ) {
293 293
  			    // settings were never opened, so don't update
294 294
  			    $action_ids[] = $new_instance['ID'];
295 295
          		$this->updated = true;
296 296
          		continue;
297 297
  			}
298 298
 
299
-			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
299
+			$old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array();
300 300
 
301
- 			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
302
-			$new_instance['post_name']  = $this->form_id . '_' . $this->id_base . '_' . $this->number;
301
+ 			$new_instance['post_type'] = FrmFormActionsController::$action_post_type;
302
+			$new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
303 303
             $new_instance['menu_order']   = $this->form_id;
304 304
             $new_instance['post_status']  = 'publish';
305 305
             $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 			 */
322 322
 			$instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
323 323
 
324
-			$instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this);
324
+			$instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
325 325
 			$instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
326 326
 
327 327
 			if ( false !== $instance ) {
328
-				$all_instances[ $number ] = $instance;
328
+				$all_instances[$number] = $instance;
329 329
 			}
330 330
 
331
-            $action_ids[] = $this->save_settings($instance);
331
+            $action_ids[] = $this->save_settings( $instance );
332 332
 
333 333
      		$this->updated = true;
334 334
  		}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	public function get_single_action( $id ) {
345
-	    $action = get_post($id);
345
+	    $action = get_post( $id );
346 346
 		if ( $action ) {
347 347
 			$action = $this->prepare_action( $action );
348 348
 			$this->_set( $id );
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	public function get_one( $form_id ) {
354
-	    return $this->get_all($form_id, 1);
354
+	    return $this->get_all( $form_id, 1 );
355 355
 	}
356 356
 
357 357
     public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358 358
         $action_controls = FrmFormActionsController::get_form_actions( $type );
359
-        if ( empty($action_controls) ) {
359
+        if ( empty( $action_controls ) ) {
360 360
             // don't continue if there are no available actions
361 361
             return array();
362 362
         }
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
 			// some plugins/themes are formatting the post_excerpt
378 378
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
379 379
 
380
-			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
380
+			if ( ! isset( $action_controls[$action->post_excerpt] ) ) {
381 381
                 continue;
382 382
             }
383 383
 
384
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
385
-			$settings[ $action->ID ] = $action;
384
+            $action = $action_controls[$action->post_excerpt]->prepare_action( $action );
385
+			$settings[$action->ID] = $action;
386 386
 
387 387
 			if ( count( $settings ) >= $limit ) {
388 388
 				break;
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         }
391 391
 
392 392
         if ( 1 === $limit ) {
393
-            $settings = reset($settings);
393
+            $settings = reset( $settings );
394 394
         }
395 395
 
396 396
         return $settings;
@@ -423,33 +423,33 @@  discard block
 block discarded – undo
423 423
 	    global $frm_vars;
424 424
 	    $frm_vars['action_type'] = $type;
425 425
 
426
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
426
+	    add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
427 427
 		$query = self::action_args( $form_id, $limit );
428 428
         $query['post_status']      = 'any';
429 429
         $query['suppress_filters'] = false;
430 430
 
431 431
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
432
-        unset($query);
432
+        unset( $query );
433 433
 
434
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
434
+        remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' );
435 435
 
436
-        if ( empty($actions) ) {
436
+        if ( empty( $actions ) ) {
437 437
             return array();
438 438
         }
439 439
 
440 440
         $settings = array();
441 441
         foreach ( $actions as $action ) {
442
-            if ( count($settings) >= $limit ) {
442
+            if ( count( $settings ) >= $limit ) {
443 443
                 continue;
444 444
             }
445 445
 
446
-            $action = $this->prepare_action($action);
446
+            $action = $this->prepare_action( $action );
447 447
 
448
-			$settings[ $action->ID ] = $action;
448
+			$settings[$action->ID] = $action;
449 449
         }
450 450
 
451 451
         if ( 1 === $limit ) {
452
-            $settings = reset($settings);
452
+            $settings = reset( $settings );
453 453
         }
454 454
 
455 455
         return $settings;
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 
474 474
 	public function prepare_action( $action ) {
475
-		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
475
+		$action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
476 476
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
477 477
 
478 478
         $default_values = $this->get_global_defaults();
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
         $action->post_content += $default_values;
482 482
 
483 483
         foreach ( $default_values as $k => $vals ) {
484
-            if ( is_array($vals) && ! empty($vals) ) {
485
-				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
484
+            if ( is_array( $vals ) && ! empty( $vals ) ) {
485
+				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) {
486 486
                     continue;
487 487
                 }
488
-				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
488
+				$action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals );
489 489
             }
490 490
         }
491 491
 
492
-        if ( ! is_array($action->post_content['event']) ) {
493
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
492
+        if ( ! is_array( $action->post_content['event'] ) ) {
493
+            $action->post_content['event'] = explode( ',', $action->post_content['event'] );
494 494
         }
495 495
 
496 496
         return $action;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
513 513
 
514 514
         foreach ( $post_ids as $id ) {
515
-            wp_delete_post($id);
515
+            wp_delete_post( $id );
516 516
         }
517 517
 		self::clear_cache();
518 518
 	}
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function get_global_defaults() {
534 534
 	    $defaults = $this->get_defaults();
535 535
 
536
-	    if ( ! isset($defaults['event']) ) {
536
+	    if ( ! isset( $defaults['event'] ) ) {
537 537
 			$defaults['event'] = array( 'create' );
538 538
 	    }
539 539
 
540
-	    if ( ! isset($defaults['conditions']) ) {
540
+	    if ( ! isset( $defaults['conditions'] ) ) {
541 541
 	        $defaults['conditions'] = array(
542 542
                 'send_stop' => '',
543 543
                 'any_all'   => '',
@@ -557,18 +557,18 @@  discard block
 block discarded – undo
557 557
 	 * Migrate settings from form->options into new action.
558 558
 	 */
559 559
 	public function migrate_to_2( $form, $update = 'update' ) {
560
-        $action = $this->prepare_new($form->id);
561
-        $form->options = maybe_unserialize($form->options);
560
+        $action = $this->prepare_new( $form->id );
561
+        $form->options = maybe_unserialize( $form->options );
562 562
 
563 563
         // fill with existing options
564 564
         foreach ( $action->post_content as $name => $val ) {
565
-			if ( isset( $form->options[ $name ] ) ) {
566
-				$action->post_content[ $name ] = $form->options[ $name ];
567
-				unset( $form->options[ $name ] );
565
+			if ( isset( $form->options[$name] ) ) {
566
+				$action->post_content[$name] = $form->options[$name];
567
+				unset( $form->options[$name] );
568 568
             }
569 569
         }
570 570
 
571
-        $action = $this->migrate_values($action, $form);
571
+        $action = $this->migrate_values( $action, $form );
572 572
 
573 573
         // check if action already exists
574 574
         $post_id = get_posts( array(
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
             'numberposts'   => 1,
579 579
         ) );
580 580
 
581
-        if ( empty($post_id) ) {
581
+        if ( empty( $post_id ) ) {
582 582
             // create action now
583
-            $post_id = $this->save_settings($action);
583
+            $post_id = $this->save_settings( $action );
584 584
         }
585 585
 
586 586
         if ( $post_id && 'update' == $update ) {
587 587
             global $wpdb;
588
-            $form->options = maybe_serialize($form->options);
588
+            $form->options = maybe_serialize( $form->options );
589 589
 
590 590
             // update form options
591 591
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
592
-            wp_cache_delete( $form->id, 'frm_form');
592
+            wp_cache_delete( $form->id, 'frm_form' );
593 593
         }
594 594
 
595 595
         return $post_id;
@@ -617,18 +617,18 @@  discard block
 block discarded – undo
617 617
 
618 618
 			$observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
619 619
 
620
-			$stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']);
620
+			$stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] );
621 621
 
622 622
 			if ( $notification['conditions']['send_stop'] == 'send' ) {
623 623
 				$stop = $stop ? false : true;
624 624
 			}
625 625
 
626
-			$met[ $stop ] = $stop;
626
+			$met[$stop] = $stop;
627 627
 		}
628 628
 
629 629
 		if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
630
-			$stop = ($notification['conditions']['send_stop'] == 'send');
631
-		} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) {
630
+			$stop = ( $notification['conditions']['send_stop'] == 'send' );
631
+		} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) {
632 632
 			$stop = false;
633 633
 		}
634 634
 
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
 	private static function get_value_from_entry( $entry, $field_id ) {
666 666
 		$observed_value = '';
667 667
 
668
-		if ( isset( $entry->metas[ $field_id ] ) ) {
669
-			$observed_value = $entry->metas[ $field_id ];
668
+		if ( isset( $entry->metas[$field_id] ) ) {
669
+			$observed_value = $entry->metas[$field_id];
670 670
 		} else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) {
671 671
 			$field = FrmField::getOne( $field_id );
672 672
 			$observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field, array( 'links' => false, 'truncate' => false ) );
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -1,251 +1,251 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
3
+	die('You are not allowed to call this page directly.');
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27
-        $options = array();
27
+		$options = array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
35
+		$new_values['options'] = serialize($options);
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
77
+			$new_options['email_to'] = get_option('admin_email');
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
95
+			FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+		$new_opts = $values['options'] = maybe_unserialize($values['options']);
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
-        }
108
+		if ( isset($new_opts['success_msg']) ) {
109
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
+		}
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+		if ( isset($values['form_key']) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134
-        $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
134
+		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+		$new_values = self::set_update_options( array(), $values);
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
138
+		foreach ( $values as $value_key => $value ) {
139
+			if ( in_array($value_key, $form_fields) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
156
-        unset($new_values);
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156
+		unset($new_values);
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+		$values = self::update_fields($id, $values);
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
171
-            return $new_values;
172
-        }
170
+		if ( ! isset($values['options']) ) {
171
+			return $new_values;
172
+		}
173 173
 
174
-        $options = array();
174
+		$options = array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
183
+		$new_values['options'] = serialize($options);
184 184
 
185
-        return $new_values;
186
-    }
185
+		return $new_values;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
-            return $values;
196
-        }
194
+		if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+			return $values;
196
+		}
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
200
-            return $values;
201
-        }
198
+		$all_fields = FrmField::get_all_for_form($id);
199
+		if ( empty($all_fields) ) {
200
+			return $values;
201
+		}
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
204
-            $values['item_meta'] = array();
205
-        }
203
+		if ( ! isset($values['item_meta']) ) {
204
+			$values['item_meta'] = array();
205
+		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
209
-        foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys($values['item_meta']);
209
+		foreach ( $all_fields as $fid ) {
210
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
215
-        unset($all_fields);
214
+		}
215
+		unset($all_fields);
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
221
-                $field = FrmField::getOne($field_id);
222
-            }
220
+			} else {
221
+				$field = FrmField::getOne($field_id);
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
229
-                //updating the settings page
229
+				//updating the settings page
230 230
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
231 231
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
232
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
232
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
233 233
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
234
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
235
-                    $prev_opts = $field->field_options;
236
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
-                    if ( $prev_opts != $field->field_options ) {
234
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
235
+					$prev_opts = $field->field_options;
236
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
+					if ( $prev_opts != $field->field_options ) {
238 238
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
239
-                    }
240
-                    unset($prev_opts);
241
-                }
242
-            }
239
+					}
240
+					unset($prev_opts);
241
+				}
242
+			}
243 243
 
244 244
 			if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) {
245
-                continue;
246
-            }
245
+				continue;
246
+			}
247 247
 
248
-            //updating the form
248
+			//updating the form
249 249
 			$update_options = array(
250 250
 				'size', 'max', 'label', 'invalid', 'blank',
251 251
 				'classes', 'captcha_size', 'default_blank',
@@ -254,129 +254,129 @@  discard block
 block discarded – undo
254 254
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
255 255
 			foreach ( $update_options as $opt ) {
256 256
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( $values['field_options'][ $opt . '_' . $field_id ] ) : '';
257
-            }
257
+			}
258 258
 
259 259
 			$field->field_options['required_indicator'] = isset( $values['field_options'][ 'required_indicator_' . $field_id ] ) ? trim( $values['field_options'][ 'required_indicator_' . $field_id ] ) : '*';
260 260
 			$field->field_options['separate_value'] = isset( $values['field_options'][ 'separate_value_' . $field_id ] ) ? trim( $values['field_options'][ 'separate_value_' . $field_id ] ) : 0;
261 261
 
262
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
262
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
263 263
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
264 264
 			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
265 265
 			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
266 266
 			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
267 267
 			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
268 268
 
269
-            FrmField::update($field_id, array(
270
-                'field_key' => $field_key, 'type' => $field_type,
271
-                'default_value' => $default_value, 'field_options' => $field->field_options,
272
-                'description' => $field_description, 'required' => $required,
273
-            ) );
269
+			FrmField::update($field_id, array(
270
+				'field_key' => $field_key, 'type' => $field_type,
271
+				'default_value' => $default_value, 'field_options' => $field->field_options,
272
+				'description' => $field_description, 'required' => $required,
273
+			) );
274 274
 
275
-            FrmField::delete_form_transient($field->form_id);
276
-        }
275
+			FrmField::delete_form_transient($field->form_id);
276
+		}
277 277
 
278
-        return $values;
279
-    }
278
+		return $values;
279
+	}
280 280
 
281
-    /**
282
-     * @param string $status
283
-     * @return int|boolean
284
-     */
281
+	/**
282
+	 * @param string $status
283
+	 * @return int|boolean
284
+	 */
285 285
 	public static function set_status( $id, $status ) {
286
-        if ( 'trash' == $status ) {
287
-            return self::trash($id);
288
-        }
286
+		if ( 'trash' == $status ) {
287
+			return self::trash($id);
288
+		}
289 289
 
290 290
 		$statuses  = array( 'published', 'draft', 'trash' );
291
-        if ( ! in_array( $status, $statuses ) ) {
292
-            return false;
293
-        }
291
+		if ( ! in_array( $status, $statuses ) ) {
292
+			return false;
293
+		}
294 294
 
295
-        global $wpdb;
295
+		global $wpdb;
296 296
 
297
-        if ( is_array($id) ) {
297
+		if ( is_array($id) ) {
298 298
 			$where = array( 'id' => $id );
299 299
 			FrmDb::get_where_clause_and_values( $where );
300 300
 			array_unshift( $where['values'], $status );
301 301
 
302 302
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
303
-        } else {
303
+		} else {
304 304
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
305
-        }
305
+		}
306 306
 
307
-        if ( $query_results ) {
307
+		if ( $query_results ) {
308 308
 			self::clear_form_cache();
309
-        }
309
+		}
310 310
 
311
-        return $query_results;
312
-    }
311
+		return $query_results;
312
+	}
313 313
 
314
-    /**
315
-     * @return int|boolean
316
-     */
314
+	/**
315
+	 * @return int|boolean
316
+	 */
317 317
 	public static function trash( $id ) {
318
-        if ( ! EMPTY_TRASH_DAYS ) {
319
-            return self::destroy( $id );
320
-        }
318
+		if ( ! EMPTY_TRASH_DAYS ) {
319
+			return self::destroy( $id );
320
+		}
321 321
 
322
-        $form = self::getOne($id);
323
-        if ( ! $form ) {
324
-            return false;
325
-        }
322
+		$form = self::getOne($id);
323
+		if ( ! $form ) {
324
+			return false;
325
+		}
326 326
 
327
-        $options = $form->options;
328
-        $options['trash_time'] = time();
327
+		$options = $form->options;
328
+		$options['trash_time'] = time();
329 329
 
330
-        global $wpdb;
331
-        $query_results = $wpdb->update(
330
+		global $wpdb;
331
+		$query_results = $wpdb->update(
332 332
 			$wpdb->prefix . 'frm_forms',
333 333
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
334 334
 			array( 'id' => $id )
335
-        );
335
+		);
336 336
 
337
-        if ( $query_results ) {
337
+		if ( $query_results ) {
338 338
 			self::clear_form_cache();
339
-        }
339
+		}
340 340
 
341
-        return $query_results;
342
-    }
341
+		return $query_results;
342
+	}
343 343
 
344
-    /**
345
-     * @return int|boolean
346
-     */
344
+	/**
345
+	 * @return int|boolean
346
+	 */
347 347
 	public static function destroy( $id ) {
348
-        global $wpdb;
348
+		global $wpdb;
349 349
 
350
-        $form = self::getOne($id);
351
-        if ( ! $form ) {
352
-            return false;
353
-        }
350
+		$form = self::getOne($id);
351
+		if ( ! $form ) {
352
+			return false;
353
+		}
354 354
 
355
-        // Disconnect the entries from this form
355
+		// Disconnect the entries from this form
356 356
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
357
-        foreach ( $entries as $entry_id ) {
358
-            FrmEntry::destroy($entry_id);
359
-            unset($entry_id);
360
-        }
357
+		foreach ( $entries as $entry_id ) {
358
+			FrmEntry::destroy($entry_id);
359
+			unset($entry_id);
360
+		}
361 361
 
362
-        // Disconnect the fields from this form
362
+		// Disconnect the fields from this form
363 363
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
364 364
 
365 365
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
366
-        if ( $query_results ) {
367
-            // Delete all form actions linked to this form
368
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
369
-            $action_control->destroy($id, 'all');
366
+		if ( $query_results ) {
367
+			// Delete all form actions linked to this form
368
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
369
+			$action_control->destroy($id, 'all');
370 370
 
371 371
 			// Clear form caching
372 372
 			self::clear_form_cache();
373 373
 
374 374
 			do_action( 'frm_destroy_form', $id );
375 375
 			do_action( 'frm_destroy_form_' . $id );
376
-        }
376
+		}
377 377
 
378
-        return $query_results;
379
-    }
378
+		return $query_results;
379
+	}
380 380
 
381 381
 	/**
382 382
 	 * Delete trashed forms based on how long they have been trashed
@@ -408,49 +408,49 @@  discard block
 block discarded – undo
408 408
 		return $count;
409 409
 	}
410 410
 
411
-    /**
412
-     * @return string form name
413
-     */
414
-    public static function &getName( $id ) {
415
-        global $wpdb;
416
-
417
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
418
-        if ( $form ) {
419
-            $r = stripslashes($form->name);
420
-            return $r;
421
-        }
422
-
423
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
424
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
425
-        $r = stripslashes($r);
426
-
427
-        return $r;
428
-    }
429
-
430
-    /**
431
-     * @param string $key
432
-     * @return int form id
433
-     */
411
+	/**
412
+	 * @return string form name
413
+	 */
414
+	public static function &getName( $id ) {
415
+		global $wpdb;
416
+
417
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
418
+		if ( $form ) {
419
+			$r = stripslashes($form->name);
420
+			return $r;
421
+		}
422
+
423
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
424
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
425
+		$r = stripslashes($r);
426
+
427
+		return $r;
428
+	}
429
+
430
+	/**
431
+	 * @param string $key
432
+	 * @return int form id
433
+	 */
434 434
 	public static function &getIdByKey( $key ) {
435
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
436
-        return $id;
437
-    }
438
-
439
-    /**
440
-     * @param int $id
441
-     * @return string form key
442
-     */
435
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
436
+		return $id;
437
+	}
438
+
439
+	/**
440
+	 * @param int $id
441
+	 * @return string form key
442
+	 */
443 443
 	public static function &getKeyById( $id ) {
444
-        $id = (int) $id;
445
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
446
-        if ( $cache ) {
447
-            return $cache->form_key;
448
-        }
444
+		$id = (int) $id;
445
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
446
+		if ( $cache ) {
447
+			return $cache->form_key;
448
+		}
449 449
 
450
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
450
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
451 451
 
452
-        return $key;
453
-    }
452
+		return $key;
453
+	}
454 454
 
455 455
 	/**
456 456
 	 * If $form is numeric, get the form object
@@ -463,47 +463,47 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 	}
465 465
 
466
-    /**
467
-     * @return object form
468
-     */
469
-    public static function getOne( $id, $blog_id = false ) {
470
-        global $wpdb;
466
+	/**
467
+	 * @return object form
468
+	 */
469
+	public static function getOne( $id, $blog_id = false ) {
470
+		global $wpdb;
471 471
 
472
-        if ( $blog_id && is_multisite() ) {
473
-            global $wpmuBaseTablePrefix;
472
+		if ( $blog_id && is_multisite() ) {
473
+			global $wpmuBaseTablePrefix;
474 474
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
475 475
 
476 476
 			$table_name = $prefix . 'frm_forms';
477
-        } else {
477
+		} else {
478 478
 			$table_name = $wpdb->prefix . 'frm_forms';
479
-            $cache = wp_cache_get($id, 'frm_form');
480
-            if ( $cache ) {
481
-                if ( isset($cache->options) ) {
482
-                    $cache->options = maybe_unserialize($cache->options);
483
-                }
484
-
485
-                return stripslashes_deep($cache);
486
-            }
487
-        }
488
-
489
-        if ( is_numeric($id) ) {
490
-            $where = array( 'id' => $id );
491
-        } else {
492
-            $where = array( 'form_key' => $id );
493
-        }
494
-
495
-        $results = FrmDb::get_row( $table_name, $where );
496
-
497
-        if ( isset($results->options) ) {
498
-            wp_cache_set($results->id, $results, 'frm_form');
499
-            $results->options = maybe_unserialize($results->options);
500
-        }
501
-        return stripslashes_deep($results);
502
-    }
503
-
504
-    /**
505
-     * @return object|array of objects
506
-     */
479
+			$cache = wp_cache_get($id, 'frm_form');
480
+			if ( $cache ) {
481
+				if ( isset($cache->options) ) {
482
+					$cache->options = maybe_unserialize($cache->options);
483
+				}
484
+
485
+				return stripslashes_deep($cache);
486
+			}
487
+		}
488
+
489
+		if ( is_numeric($id) ) {
490
+			$where = array( 'id' => $id );
491
+		} else {
492
+			$where = array( 'form_key' => $id );
493
+		}
494
+
495
+		$results = FrmDb::get_row( $table_name, $where );
496
+
497
+		if ( isset($results->options) ) {
498
+			wp_cache_set($results->id, $results, 'frm_form');
499
+			$results->options = maybe_unserialize($results->options);
500
+		}
501
+		return stripslashes_deep($results);
502
+	}
503
+
504
+	/**
505
+	 * @return object|array of objects
506
+	 */
507 507
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
508 508
 		if ( is_array( $where ) && ! empty( $where ) ) {
509 509
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 			$results = reset( $results );
528 528
 		}
529 529
 
530
-        return stripslashes_deep($results);
531
-    }
530
+		return stripslashes_deep($results);
531
+	}
532 532
 
533 533
 	/**
534 534
 	 * Get all published forms
@@ -546,47 +546,47 @@  discard block
 block discarded – undo
546 546
 		return $forms;
547 547
 	}
548 548
 
549
-    /**
550
-     * @return int count of forms
551
-     */
552
-    public static function &get_count() {
553
-    	global $wpdb;
549
+	/**
550
+	 * @return int count of forms
551
+	 */
552
+	public static function &get_count() {
553
+		global $wpdb;
554 554
 
555
-    	$cache_key = 'frm_form_counts';
555
+		$cache_key = 'frm_form_counts';
556 556
 
557
-    	$counts = wp_cache_get( $cache_key, 'counts' );
558
-    	if ( false !== $counts ) {
559
-    	    return $counts;
560
-    	}
557
+		$counts = wp_cache_get( $cache_key, 'counts' );
558
+		if ( false !== $counts ) {
559
+			return $counts;
560
+		}
561 561
 
562
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
562
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
563 563
 
564 564
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
565
-    	$counts = array_fill_keys( $statuses, 0 );
565
+		$counts = array_fill_keys( $statuses, 0 );
566 566
 
567
-    	foreach ( $results as $row ) {
568
-            if ( 'trash' != $row->status ) {
569
-    	        if ( $row->is_template ) {
567
+		foreach ( $results as $row ) {
568
+			if ( 'trash' != $row->status ) {
569
+				if ( $row->is_template ) {
570 570
 					$counts['template']++;
571
-    	        } else {
571
+				} else {
572 572
 					$counts['published']++;
573
-    	        }
574
-    	    } else {
573
+				}
574
+			} else {
575 575
 				$counts['trash']++;
576
-        	}
576
+			}
577 577
 
578
-    	    if ( 'draft' == $row->status ) {
578
+			if ( 'draft' == $row->status ) {
579 579
 				$counts['draft']++;
580
-    	    }
580
+			}
581 581
 
582
-    		unset($row);
583
-    	}
582
+			unset($row);
583
+		}
584 584
 
585
-    	$counts = (object) $counts;
586
-    	wp_cache_set( $cache_key, $counts, 'counts' );
585
+		$counts = (object) $counts;
586
+		wp_cache_set( $cache_key, $counts, 'counts' );
587 587
 
588
-    	return $counts;
589
-    }
588
+		return $counts;
589
+	}
590 590
 
591 591
 	/**
592 592
 	 * Clear form caching
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
 		FrmAppHelper::cache_delete_group( 'frm_form' );
600 600
 	}
601 601
 
602
-    /**
603
-     * @return array of errors
604
-     */
602
+	/**
603
+	 * @return array of errors
604
+	 */
605 605
 	public static function validate( $values ) {
606
-        $errors = array();
606
+		$errors = array();
607 607
 
608
-        return apply_filters('frm_validate_form', $errors, $values);
609
-    }
608
+		return apply_filters('frm_validate_form', $errors, $values);
609
+	}
610 610
 
611 611
 	public static function get_params( $form = null ) {
612 612
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
         $options = array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
         $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
140
-				$new_values[ $value_key ] = $value;
139
+            if ( in_array( $value_key, $form_fields ) ) {
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
         $options = array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,57 +191,57 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
228
+			if ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) {
229 229
                 //updating the settings page
230
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
231
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
232
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
230
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
231
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
232
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
233 233
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
234 234
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
235 235
                     $prev_opts = $field->field_options;
236
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
236
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
237 237
                     if ( $prev_opts != $field->field_options ) {
238 238
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
239 239
                     }
240
-                    unset($prev_opts);
240
+                    unset( $prev_opts );
241 241
                 }
242 242
             }
243 243
 
244
-			if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) {
244
+			if ( ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) && ! defined( 'WP_IMPORTING' ) ) {
245 245
                 continue;
246 246
             }
247 247
 
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
252 252
 
253 253
 			foreach ( $update_options as $opt => $default ) {
254
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
254
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
255 255
             }
256 256
 
257
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
259
-			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
260
-			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
261
-			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
262
-			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
257
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
258
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
259
+			$field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
260
+			$required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false;
261
+			$field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type;
262
+			$field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description;
263 263
 
264
-            FrmField::update($field_id, array(
264
+            FrmField::update( $field_id, array(
265 265
                 'field_key' => $field_key, 'type' => $field_type,
266 266
                 'default_value' => $default_value, 'field_options' => $field->field_options,
267 267
                 'description' => $field_description, 'required' => $required,
268 268
             ) );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
270
+            FrmField::delete_form_transient( $field->form_id );
271 271
         }
272 272
 
273 273
         return $values;
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
      */
280 280
 	public static function set_status( $id, $status ) {
281 281
         if ( 'trash' == $status ) {
282
-            return self::trash($id);
282
+            return self::trash( $id );
283 283
         }
284 284
 
285
-		$statuses  = array( 'published', 'draft', 'trash' );
285
+		$statuses = array( 'published', 'draft', 'trash' );
286 286
         if ( ! in_array( $status, $statuses ) ) {
287 287
             return false;
288 288
         }
289 289
 
290 290
         global $wpdb;
291 291
 
292
-        if ( is_array($id) ) {
292
+        if ( is_array( $id ) ) {
293 293
 			$where = array( 'id' => $id );
294 294
 			FrmDb::get_where_clause_and_values( $where );
295 295
 			array_unshift( $where['values'], $status );
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             return self::destroy( $id );
315 315
         }
316 316
 
317
-        $form = self::getOne($id);
317
+        $form = self::getOne( $id );
318 318
         if ( ! $form ) {
319 319
             return false;
320 320
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	public static function destroy( $id ) {
343 343
         global $wpdb;
344 344
 
345
-        $form = self::getOne($id);
345
+        $form = self::getOne( $id );
346 346
         if ( ! $form ) {
347 347
             return false;
348 348
         }
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
         // Disconnect the entries from this form
351 351
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
352 352
         foreach ( $entries as $entry_id ) {
353
-            FrmEntry::destroy($entry_id);
354
-            unset($entry_id);
353
+            FrmEntry::destroy( $entry_id );
354
+            unset( $entry_id );
355 355
         }
356 356
 
357 357
         // Disconnect the fields from this form
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
         if ( $query_results ) {
362 362
             // Delete all form actions linked to this form
363 363
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
364
-            $action_control->destroy($id, 'all');
364
+            $action_control->destroy( $id, 'all' );
365 365
 
366 366
 			// Clear form caching
367 367
 			self::clear_form_cache();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			$form->options = maybe_unserialize( $form->options );
396 396
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
397 397
 				self::destroy( $form->id );
398
-				$count++;
398
+				$count ++;
399 399
 			}
400 400
 
401 401
 			unset( $form );
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
     public static function &getName( $id ) {
410 410
         global $wpdb;
411 411
 
412
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
412
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
413 413
         if ( $form ) {
414
-            $r = stripslashes($form->name);
414
+            $r = stripslashes( $form->name );
415 415
             return $r;
416 416
         }
417 417
 
418 418
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
419 419
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
420
-        $r = stripslashes($r);
420
+        $r = stripslashes( $r );
421 421
 
422 422
         return $r;
423 423
     }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      */
438 438
 	public static function &getKeyById( $id ) {
439 439
         $id = (int) $id;
440
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
440
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
441 441
         if ( $cache ) {
442 442
             return $cache->form_key;
443 443
         }
@@ -471,17 +471,17 @@  discard block
 block discarded – undo
471 471
 			$table_name = $prefix . 'frm_forms';
472 472
         } else {
473 473
 			$table_name = $wpdb->prefix . 'frm_forms';
474
-            $cache = wp_cache_get($id, 'frm_form');
474
+            $cache = wp_cache_get( $id, 'frm_form' );
475 475
             if ( $cache ) {
476
-                if ( isset($cache->options) ) {
477
-                    $cache->options = maybe_unserialize($cache->options);
476
+                if ( isset( $cache->options ) ) {
477
+                    $cache->options = maybe_unserialize( $cache->options );
478 478
                 }
479 479
 
480
-                return stripslashes_deep($cache);
480
+                return stripslashes_deep( $cache );
481 481
             }
482 482
         }
483 483
 
484
-        if ( is_numeric($id) ) {
484
+        if ( is_numeric( $id ) ) {
485 485
             $where = array( 'id' => $id );
486 486
         } else {
487 487
             $where = array( 'form_key' => $id );
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 
490 490
         $results = FrmDb::get_row( $table_name, $where );
491 491
 
492
-        if ( isset($results->options) ) {
493
-            wp_cache_set($results->id, $results, 'frm_form');
494
-            $results->options = maybe_unserialize($results->options);
492
+        if ( isset( $results->options ) ) {
493
+            wp_cache_set( $results->id, $results, 'frm_form' );
494
+            $results->options = maybe_unserialize( $results->options );
495 495
         }
496
-        return stripslashes_deep($results);
496
+        return stripslashes_deep( $results );
497 497
     }
498 498
 
499 499
     /**
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			$results = reset( $results );
523 523
 		}
524 524
 
525
-        return stripslashes_deep($results);
525
+        return stripslashes_deep( $results );
526 526
     }
527 527
 
528 528
 	/**
@@ -562,19 +562,19 @@  discard block
 block discarded – undo
562 562
     	foreach ( $results as $row ) {
563 563
             if ( 'trash' != $row->status ) {
564 564
     	        if ( $row->is_template ) {
565
-					$counts['template']++;
565
+					$counts['template'] ++;
566 566
     	        } else {
567
-					$counts['published']++;
567
+					$counts['published'] ++;
568 568
     	        }
569 569
     	    } else {
570
-				$counts['trash']++;
570
+				$counts['trash'] ++;
571 571
         	}
572 572
 
573 573
     	    if ( 'draft' == $row->status ) {
574
-				$counts['draft']++;
574
+				$counts['draft'] ++;
575 575
     	    }
576 576
 
577
-    		unset($row);
577
+    		unset( $row );
578 578
     	}
579 579
 
580 580
     	$counts = (object) $counts;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	public static function validate( $values ) {
601 601
         $errors = array();
602 602
 
603
-        return apply_filters('frm_validate_form', $errors, $values);
603
+        return apply_filters( 'frm_validate_form', $errors, $values );
604 604
     }
605 605
 
606 606
 	public static function get_params( $form = null ) {
@@ -612,11 +612,11 @@  discard block
 block discarded – undo
612 612
 			self::maybe_get_form( $form );
613 613
 		}
614 614
 
615
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
616
-			return $frm_vars['form_params'][ $form->id ];
615
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
616
+			return $frm_vars['form_params'][$form->id];
617 617
 		}
618 618
 
619
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
619
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
620 620
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
621 621
 
622 622
 		$default_values = array(
@@ -634,15 +634,15 @@  discard block
 block discarded – undo
634 634
 			//if there are two forms on the same page, make sure not to submit both
635 635
 			foreach ( $default_values as $var => $default ) {
636 636
 				if ( $var == 'action' ) {
637
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
637
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
638 638
 				} else {
639
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
639
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
640 640
 				}
641 641
 				unset( $var, $default );
642 642
 			}
643 643
 		} else {
644 644
 			foreach ( $default_values as $var => $default ) {
645
-				$values[ $var ] = $default;
645
+				$values[$var] = $default;
646 646
 				unset( $var, $default );
647 647
 			}
648 648
 		}
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	public static function list_page_params() {
658 658
 		$values = array();
659 659
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
660
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
660
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
661 661
 		}
662 662
 
663 663
 		return $values;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
678 678
 			'keep_post' => '',
679 679
 		) as $var => $default ) {
680
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
680
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
681 681
 		}
682 682
 
683 683
 		return $values;
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
 		$small_form = new stdClass();
720 720
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
721 721
 			$small_form->{$var} = $form->{$var};
722
-			unset($var);
722
+			unset( $var );
723 723
 		}
724 724
 
725 725
 		$frm_vars['forms_loaded'][] = $small_form;
726 726
 
727
-		if ( $this_load && empty($global_load) ) {
727
+		if ( $this_load && empty( $global_load ) ) {
728 728
 			$global_load = $frm_vars['load_css'] = true;
729 729
 		}
730 730
 
731
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
731
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
732 732
 	}
733 733
 
734 734
 	public static function show_submit( $form ) {
Please login to merge, or discard this patch.
classes/models/FrmDb.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     var $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
         global $wpdb;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $frm_db_version = FrmAppHelper::$db_version;
25 25
         $old_db_version = (float) $old_db_version;
26 26
         if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
27
+            $old_db_version = get_option( 'frm_db_version' );
28 28
         }
29 29
 
30 30
         if ( $frm_db_version != $old_db_version ) {
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36 36
             $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
37
+            $this->migrate_data( $frm_db_version, $old_db_version );
38 38
 
39 39
             /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
40
+            update_option( 'frm_db_version', $frm_db_version );
41 41
 
42 42
             /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43 43
             FrmXMLController::add_default_templates();
44 44
         }
45 45
 
46
-        do_action('frm_after_install');
46
+        do_action( 'frm_after_install' );
47 47
 
48 48
         /**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
156
+            unset( $q );
157 157
         }
158 158
     }
159 159
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * Change array into format $wpdb->prepare can use
175 175
      */
176 176
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
-        if ( empty($args) ) {
177
+        if ( empty( $args ) ) {
178 178
 			// add an arg to prevent prepare from failing
179 179
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
180 180
 			return;
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
     private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
231 231
 		$key = trim( $key );
232 232
 
233
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
-            $k = explode(' ', $key);
233
+        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
234
+            $k = explode( ' ', $key );
235 235
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236 236
             $values[] = '%Y-%m-%d %H:%i:%s';
237 237
         } else {
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
     public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356 356
         _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
-        return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
357
+        return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) );
358 358
     }
359 359
 
360 360
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 		);
388 388
 
389 389
 		$where_is = strtolower( $where_is );
390
-		if ( isset( $switch_to[ $where_is ] ) ) {
391
-			return ' ' . $switch_to[ $where_is ];
390
+		if ( isset( $switch_to[$where_is] ) ) {
391
+			return ' ' . $switch_to[$where_is];
392 392
 		}
393 393
 
394 394
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
     private static function get_group_and_table_name( &$table, &$group ) {
411 411
 		global $wpdb, $wpmuBaseTablePrefix;
412 412
 
413
-        $table_parts = explode(' ', $table);
414
-        $group = reset($table_parts);
413
+        $table_parts = explode( ' ', $table );
414
+        $group = reset( $table_parts );
415 415
         $group = str_replace( $wpdb->prefix, '', $group );
416 416
 
417 417
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     }
427 427
 
428 428
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
-        if ( ! is_array($args) ) {
429
+        if ( ! is_array( $args ) ) {
430 430
 			$args = array( 'order_by' => $args );
431 431
         }
432 432
 
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
         $temp_args = $args;
442 442
         foreach ( $temp_args as $k => $v ) {
443 443
             if ( $v == '' ) {
444
-				unset( $args[ $k ] );
444
+				unset( $args[$k] );
445 445
                 continue;
446 446
             }
447 447
 
448 448
             if ( $k == 'limit' ) {
449
-				$args[ $k ] = FrmAppHelper::esc_limit( $v );
449
+				$args[$k] = FrmAppHelper::esc_limit( $v );
450 450
             }
451 451
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
452 452
             if ( strpos( $v, $db_name ) === false ) {
453
-				$args[ $k ] = $db_name . ' ' . $v;
453
+				$args[$k] = $db_name . ' ' . $v;
454 454
             }
455 455
         }
456 456
     }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
     public function uninstall() {
459 459
 		if ( ! current_user_can( 'administrator' ) ) {
460 460
             $frm_settings = FrmAppHelper::get_settings();
461
-            wp_die($frm_settings->admin_permission);
461
+            wp_die( $frm_settings->admin_permission );
462 462
         }
463 463
 
464 464
         global $wpdb, $wp_roles;
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
469 469
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
470 470
 
471
-        delete_option('frm_options');
472
-        delete_option('frm_db_version');
471
+        delete_option( 'frm_options' );
472
+        delete_option( 'frm_db_version' );
473 473
 
474 474
         //delete roles
475 475
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
478 478
             foreach ( $roles as $role => $details ) {
479 479
                 $wp_roles->remove_cap( $role, $frm_role );
480
-                unset($role, $details);
480
+                unset( $role, $details );
481 481
     		}
482
-    		unset($frm_role, $frm_role_description);
482
+    		unset( $frm_role, $frm_role_description );
483 483
 		}
484
-		unset($roles, $frm_roles);
484
+		unset( $roles, $frm_roles );
485 485
 
486 486
 		// delete actions, views, and styles
487 487
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
505 505
 
506
-        do_action('frm_after_uninstall');
506
+        do_action( 'frm_after_uninstall' );
507 507
         return true;
508 508
     }
509 509
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 
561 561
         $updated = 0;
562 562
         foreach ( $fields as $f ) {
563
-            $f->field_options = maybe_unserialize($f->field_options);
564
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
563
+            $f->field_options = maybe_unserialize( $f->field_options );
564
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
565 565
                 continue;
566 566
             }
567 567
 
@@ -569,27 +569,27 @@  discard block
 block discarded – undo
569 569
             $f->field_options['size'] .= 'px';
570 570
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
571 571
             if ( $u ) {
572
-                $updated++;
572
+                $updated ++;
573 573
             }
574
-            unset($f);
574
+            unset( $f );
575 575
         }
576 576
 
577 577
         // Change the characters in widgets to pixels
578
-        $widgets = get_option('widget_frm_show_form');
579
-        if ( empty($widgets) ) {
578
+        $widgets = get_option( 'widget_frm_show_form' );
579
+        if ( empty( $widgets ) ) {
580 580
             return;
581 581
         }
582 582
 
583
-        $widgets = maybe_unserialize($widgets);
583
+        $widgets = maybe_unserialize( $widgets );
584 584
         foreach ( $widgets as $k => $widget ) {
585
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
585
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
586 586
                 continue;
587 587
             }
588 588
 			$size = round( $pixel_conversion * (int) $widget['size'] );
589 589
             $size .= 'px';
590
-			$widgets[ $k ]['size'] = $size;
590
+			$widgets[$k]['size'] = $size;
591 591
         }
592
-        update_option('widget_frm_show_form', $widgets);
592
+        update_option( 'widget_frm_show_form', $widgets );
593 593
     }
594 594
 
595 595
     /**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			}
639 639
 
640 640
             // Format form options
641
-            $form_options = maybe_unserialize($form->options);
641
+            $form_options = maybe_unserialize( $form->options );
642 642
 
643 643
             // Migrate settings to actions
644 644
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     private function migrate_to_11() {
649 649
         global $wpdb;
650 650
 
651
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
651
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
652 652
 
653 653
         $sending = __( 'Sending', 'formidable' );
654 654
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
660 660
 </div>
661 661
 DEFAULT_HTML;
662
-        unset($sending, $img);
662
+        unset( $sending, $img );
663 663
 
664
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
664
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
665 665
         $draft_link = FrmFormsHelper::get_draft_link();
666 666
 		foreach ( $forms as $form ) {
667
-            $form->options = maybe_unserialize($form->options);
668
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
667
+            $form->options = maybe_unserialize( $form->options );
668
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
669 669
                 continue;
670 670
             }
671 671
 
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
677 677
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
678 678
             }
679
-            unset($form);
679
+            unset( $form );
680 680
         }
681
-        unset($forms);
681
+        unset( $forms );
682 682
     }
683 683
 
684 684
     private function migrate_to_6() {
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 </div>
708 708
 DEFAULT_HTML;
709 709
 
710
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
710
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
711 711
         foreach ( $fields as $field ) {
712
-            $field->field_options = maybe_unserialize($field->field_options);
712
+            $field->field_options = maybe_unserialize( $field->field_options );
713 713
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
714 714
                 $field->field_options['custom_html'] = $new_default_html;
715 715
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
716 716
             }
717
-            unset($field);
717
+            unset( $field );
718 718
         }
719
-        unset($default_html, $old_default_html, $fields);
719
+        unset( $default_html, $old_default_html, $fields );
720 720
     }
721 721
 
722 722
     private function migrate_to_4() {
Please login to merge, or discard this patch.
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    var $fields;
5
-    var $forms;
6
-    var $entries;
7
-    var $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
13
-
14
-        global $wpdb;
15
-        $this->fields         = $wpdb->prefix . 'frm_fields';
16
-        $this->forms          = $wpdb->prefix . 'frm_forms';
17
-        $this->entries        = $wpdb->prefix . 'frm_items';
18
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
-    }
20
-
21
-    public function upgrade( $old_db_version = false ) {
22
-        global $wpdb;
23
-        //$frm_db_version is the version of the database we're moving to
24
-        $frm_db_version = FrmAppHelper::$db_version;
25
-        $old_db_version = (float) $old_db_version;
26
-        if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
28
-        }
29
-
30
-        if ( $frm_db_version != $old_db_version ) {
4
+	var $fields;
5
+	var $forms;
6
+	var $entries;
7
+	var $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13
+
14
+		global $wpdb;
15
+		$this->fields         = $wpdb->prefix . 'frm_fields';
16
+		$this->forms          = $wpdb->prefix . 'frm_forms';
17
+		$this->entries        = $wpdb->prefix . 'frm_items';
18
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
+	}
20
+
21
+	public function upgrade( $old_db_version = false ) {
22
+		global $wpdb;
23
+		//$frm_db_version is the version of the database we're moving to
24
+		$frm_db_version = FrmAppHelper::$db_version;
25
+		$old_db_version = (float) $old_db_version;
26
+		if ( ! $old_db_version ) {
27
+			$old_db_version = get_option('frm_db_version');
28
+		}
29
+
30
+		if ( $frm_db_version != $old_db_version ) {
31 31
 			// update rewrite rules for views and other custom post types
32 32
 			flush_rewrite_rules();
33 33
 
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36
-            $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
36
+			$this->create_tables();
37
+			$this->migrate_data($frm_db_version, $old_db_version);
38 38
 
39
-            /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
39
+			/***** SAVE DB VERSION *****/
40
+			update_option('frm_db_version', $frm_db_version);
41 41
 
42
-            /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
-            FrmXMLController::add_default_templates();
44
-        }
42
+			/**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
+			FrmXMLController::add_default_templates();
44
+		}
45 45
 
46
-        do_action('frm_after_install');
46
+		do_action('frm_after_install');
47 47
 
48
-        /**** update the styling settings ****/
48
+		/**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
50 50
 			$frm_style = new FrmStyle();
51 51
 			$frm_style->update( 'default' );
52 52
 		}
53
-    }
53
+	}
54 54
 
55
-    public function collation() {
56
-        global $wpdb;
57
-        if ( ! $wpdb->has_cap( 'collation' ) ) {
58
-            return '';
59
-        }
55
+	public function collation() {
56
+		global $wpdb;
57
+		if ( ! $wpdb->has_cap( 'collation' ) ) {
58
+			return '';
59
+		}
60 60
 
61
-        $charset_collate = '';
61
+		$charset_collate = '';
62 62
 		if ( ! empty( $wpdb->charset ) ) {
63 63
 			$charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset;
64 64
 		}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 			$charset_collate .= ' COLLATE ' . $wpdb->collate;
68 68
 		}
69 69
 
70
-        return $charset_collate;
71
-    }
70
+		return $charset_collate;
71
+	}
72 72
 
73
-    private function create_tables() {
74
-        $charset_collate = $this->collation();
75
-        $sql = array();
73
+	private function create_tables() {
74
+		$charset_collate = $this->collation();
75
+		$sql = array();
76 76
 
77
-        /* Create/Upgrade Fields Table */
77
+		/* Create/Upgrade Fields Table */
78 78
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
79 79
                 id int(11) NOT NULL auto_increment,
80 80
 				field_key varchar(100) default NULL,
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 UNIQUE KEY field_key (field_key)
94 94
         )';
95 95
 
96
-        /* Create/Upgrade Forms Table */
96
+		/* Create/Upgrade Forms Table */
97 97
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
98 98
                 id int(11) NOT NULL auto_increment,
99 99
 				form_key varchar(100) default NULL,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 UNIQUE KEY form_key (form_key)
112 112
         )';
113 113
 
114
-        /* Create/Upgrade Items Table */
114
+		/* Create/Upgrade Items Table */
115 115
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
116 116
                 id int(11) NOT NULL auto_increment,
117 117
 				item_key varchar(100) default NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 UNIQUE KEY item_key (item_key)
135 135
         )';
136 136
 
137
-        /* Create/Upgrade Meta Table */
137
+		/* Create/Upgrade Meta Table */
138 138
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
139 139
                 id int(11) NOT NULL auto_increment,
140 140
                 meta_value longtext default NULL,
@@ -146,39 +146,39 @@  discard block
 block discarded – undo
146 146
                 KEY item_id (item_id)
147 147
         )';
148 148
 
149
-        foreach ( $sql as $q ) {
149
+		foreach ( $sql as $q ) {
150 150
 			if ( function_exists( 'dbDelta' ) ) {
151 151
 				dbDelta( $q . $charset_collate . ';' );
152 152
 			} else {
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
157
-        }
158
-    }
156
+			unset($q);
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param integer $frm_db_version
162
-     */
160
+	/**
161
+	 * @param integer $frm_db_version
162
+	 */
163 163
 	private function migrate_data( $frm_db_version, $old_db_version ) {
164 164
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
165
-        foreach ( $migrations as $migration ) {
166
-            if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
165
+		foreach ( $migrations as $migration ) {
166
+			if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
167 167
 				$function_name = 'migrate_to_' . $migration;
168
-                $this->$function_name();
169
-            }
170
-        }
171
-    }
172
-
173
-    /**
174
-     * Change array into format $wpdb->prepare can use
175
-     */
176
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
-        if ( empty($args) ) {
168
+				$this->$function_name();
169
+			}
170
+		}
171
+	}
172
+
173
+	/**
174
+	 * Change array into format $wpdb->prepare can use
175
+	 */
176
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
+		if ( empty($args) ) {
178 178
 			// add an arg to prevent prepare from failing
179 179
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
180 180
 			return;
181
-        }
181
+		}
182 182
 
183 183
 		$where = '';
184 184
 		$values = array();
@@ -189,60 +189,60 @@  discard block
 block discarded – undo
189 189
 		}
190 190
 
191 191
 		$args = compact( 'where', 'values' );
192
-    }
193
-
194
-    /**
195
-     * @param string $base_where
196
-     * @param string $where
197
-     */
198
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
199
-        $condition = ' AND';
200
-        if ( isset( $args['or'] ) ) {
201
-            $condition = ' OR';
202
-            unset( $args['or'] );
203
-        }
204
-
205
-        foreach ( $args as $key => $value ) {
206
-            $where .= empty( $where ) ? $base_where : $condition;
207
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
208
-            if ( is_numeric( $key ) || $array_inc_null ) {
209
-                $where .= ' ( ';
210
-                $nested_where = '';
211
-                if ( $array_inc_null ) {
212
-                    foreach ( $value as $val ) {
213
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
214
-                    }
215
-                } else {
216
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
217
-                }
218
-                $where .= $nested_where;
219
-                $where .= ' ) ';
220
-            } else {
221
-                self::interpret_array_to_sql( $key, $value, $where, $values );
222
-            }
223
-        }
224
-    }
225
-
226
-    /**
227
-     * @param string $key
228
-     * @param string $where
229
-     */
230
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
192
+	}
193
+
194
+	/**
195
+	 * @param string $base_where
196
+	 * @param string $where
197
+	 */
198
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
199
+		$condition = ' AND';
200
+		if ( isset( $args['or'] ) ) {
201
+			$condition = ' OR';
202
+			unset( $args['or'] );
203
+		}
204
+
205
+		foreach ( $args as $key => $value ) {
206
+			$where .= empty( $where ) ? $base_where : $condition;
207
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
208
+			if ( is_numeric( $key ) || $array_inc_null ) {
209
+				$where .= ' ( ';
210
+				$nested_where = '';
211
+				if ( $array_inc_null ) {
212
+					foreach ( $value as $val ) {
213
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
214
+					}
215
+				} else {
216
+					self::parse_where_from_array( $value, '', $nested_where, $values );
217
+				}
218
+				$where .= $nested_where;
219
+				$where .= ' ) ';
220
+			} else {
221
+				self::interpret_array_to_sql( $key, $value, $where, $values );
222
+			}
223
+		}
224
+	}
225
+
226
+	/**
227
+	 * @param string $key
228
+	 * @param string $where
229
+	 */
230
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
231 231
 		$key = trim( $key );
232 232
 
233
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
-            $k = explode(' ', $key);
235
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236
-            $values[] = '%Y-%m-%d %H:%i:%s';
237
-        } else {
233
+		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
+			$k = explode(' ', $key);
235
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236
+			$values[] = '%Y-%m-%d %H:%i:%s';
237
+		} else {
238 238
 			$where .= ' ' . $key;
239
-        }
239
+		}
240 240
 
241 241
 		$lowercase_key = explode( ' ', strtolower( $key ) );
242 242
 		$lowercase_key = end( $lowercase_key );
243 243
 
244
-        if ( is_array( $value ) ) {
245
-            // translate array of values to "in"
244
+		if ( is_array( $value ) ) {
245
+			// translate array of values to "in"
246 246
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
247 247
 				$where = rtrim( $where, $key );
248 248
 				$where .= '(';
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 				$where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')';
261 261
 				$values = array_merge( $values, $value );
262 262
 			}
263
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
263
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
264 264
 			/**
265 265
 			 * Allow string to start or end with the value
266 266
 			 * If the key is like% then skip the first % for starts with
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 			$where .= ' %s';
280 280
 			$values[] = $start . FrmAppHelper::esc_like( $value ) . $end;
281 281
 
282
-        } else if ( $value === null ) {
283
-            $where .= ' IS NULL';
284
-        } else {
282
+		} else if ( $value === null ) {
283
+			$where .= ' IS NULL';
284
+		} else {
285 285
 			// allow a - to prevent = from being added
286 286
 			if ( substr( $key, -1 ) == '-' ) {
287 287
 				$where = rtrim( $where, '-' );
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
 				$where .= '=';
290 290
 			}
291 291
 
292
-            $where .= is_numeric( $value ) ? ( strpos( $value, '.' ) !== false ? '%f' : '%d' ) : '%s';
293
-            $values[] = $value;
294
-        }
295
-    }
296
-
297
-    /**
298
-     * @param string $table
299
-     */
300
-    public static function get_count( $table, $where = array(), $args = array() ) {
301
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
302
-        return $count;
303
-    }
304
-
305
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
306
-        $group = '';
307
-        self::get_group_and_table_name( $table, $group );
292
+			$where .= is_numeric( $value ) ? ( strpos( $value, '.' ) !== false ? '%f' : '%d' ) : '%s';
293
+			$values[] = $value;
294
+		}
295
+	}
296
+
297
+	/**
298
+	 * @param string $table
299
+	 */
300
+	public static function get_count( $table, $where = array(), $args = array() ) {
301
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
302
+		return $count;
303
+	}
304
+
305
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
306
+		$group = '';
307
+		self::get_group_and_table_name( $table, $group );
308 308
 		self::convert_options_to_array( $args, '', $limit );
309 309
 
310 310
 		$query = 'SELECT ' . $field . ' FROM ' . $table;
311 311
 		if ( is_array( $where ) || empty( $where ) ) {
312 312
 			// only separate into array values and query string if is array
313
-        	self::get_where_clause_and_values( $where );
313
+			self::get_where_clause_and_values( $where );
314 314
 			global $wpdb;
315 315
 			$query = $wpdb->prepare( $query . $where['where'] . ' ' . implode( ' ', $args ), $where['values'] );
316 316
 		} else {
@@ -324,47 +324,47 @@  discard block
 block discarded – undo
324 324
 
325 325
 		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) );
326 326
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type );
327
-        return $results;
328
-    }
329
-
330
-    /**
331
-     * @param string $table
332
-     * @param array $where
333
-     */
334
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
335
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
336
-    }
337
-
338
-    /**
339
-     * @since 2.0
340
-     * @param string $table
341
-     */
342
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
343
-        $args['limit'] = 1;
344
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
345
-    }
346
-
347
-    /**
348
-     * @param string $table
349
-     */
350
-    public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
351
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
327
+		return $results;
328
+	}
329
+
330
+	/**
331
+	 * @param string $table
332
+	 * @param array $where
333
+	 */
334
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
335
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
336
+	}
337
+
338
+	/**
339
+	 * @since 2.0
340
+	 * @param string $table
341
+	 */
342
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
343
+		$args['limit'] = 1;
344
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
345
+	}
346
+
347
+	/**
348
+	 * @param string $table
349
+	 */
350
+	public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
351
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
352 352
 		return self::get_var( $table, $args, $fields, array( 'order_by' => $order_by, 'limit' => 1 ), '', 'row' );
353
-    }
354
-
355
-    public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
-        return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
358
-    }
359
-
360
-    /**
361
-     * Prepare a key/value array before DB call
362
-     * @since 2.0
363
-     * @param string $table
364
-     */
365
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
366
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
367
-    }
353
+	}
354
+
355
+	public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
+		return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
358
+	}
359
+
360
+	/**
361
+	 * Prepare a key/value array before DB call
362
+	 * @since 2.0
363
+	 * @param string $table
364
+	 */
365
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
366
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
367
+	}
368 368
 
369 369
 	/**
370 370
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -400,59 +400,59 @@  discard block
 block discarded – undo
400 400
 		return '';
401 401
 	}
402 402
 
403
-    /**
404
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
405
-     * Also add the wpdb->prefix to the table if it's missing
406
-     *
407
-     * @param string $table
408
-     * @param string $group
409
-     */
410
-    private static function get_group_and_table_name( &$table, &$group ) {
403
+	/**
404
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
405
+	 * Also add the wpdb->prefix to the table if it's missing
406
+	 *
407
+	 * @param string $table
408
+	 * @param string $group
409
+	 */
410
+	private static function get_group_and_table_name( &$table, &$group ) {
411 411
 		global $wpdb, $wpmuBaseTablePrefix;
412 412
 
413
-        $table_parts = explode(' ', $table);
414
-        $group = reset($table_parts);
415
-        $group = str_replace( $wpdb->prefix, '', $group );
413
+		$table_parts = explode(' ', $table);
414
+		$group = reset($table_parts);
415
+		$group = str_replace( $wpdb->prefix, '', $group );
416 416
 
417 417
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
418 418
 		$group = str_replace( $prefix, '', $group );
419 419
 
420
-        if ( $group == $table ) {
421
-            $table = $wpdb->prefix . $table;
422
-        }
420
+		if ( $group == $table ) {
421
+			$table = $wpdb->prefix . $table;
422
+		}
423 423
 
424 424
 		// switch to singular group name
425 425
 		$group = rtrim( $group, 's' );
426
-    }
426
+	}
427 427
 
428
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
-        if ( ! is_array($args) ) {
428
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
+		if ( ! is_array($args) ) {
430 430
 			$args = array( 'order_by' => $args );
431
-        }
431
+		}
432 432
 
433
-        if ( ! empty( $order_by ) ) {
434
-            $args['order_by'] = $order_by;
435
-        }
433
+		if ( ! empty( $order_by ) ) {
434
+			$args['order_by'] = $order_by;
435
+		}
436 436
 
437
-        if ( ! empty( $limit ) ) {
438
-            $args['limit'] = $limit;
439
-        }
437
+		if ( ! empty( $limit ) ) {
438
+			$args['limit'] = $limit;
439
+		}
440 440
 
441
-        $temp_args = $args;
442
-        foreach ( $temp_args as $k => $v ) {
443
-            if ( $v == '' ) {
441
+		$temp_args = $args;
442
+		foreach ( $temp_args as $k => $v ) {
443
+			if ( $v == '' ) {
444 444
 				unset( $args[ $k ] );
445
-                continue;
446
-            }
445
+				continue;
446
+			}
447 447
 
448
-            if ( $k == 'limit' ) {
448
+			if ( $k == 'limit' ) {
449 449
 				$args[ $k ] = FrmAppHelper::esc_limit( $v );
450
-            }
451
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
452
-            if ( strpos( $v, $db_name ) === false ) {
450
+			}
451
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
452
+			if ( strpos( $v, $db_name ) === false ) {
453 453
 				$args[ $k ] = $db_name . ' ' . $v;
454
-            }
455
-        }
454
+			}
455
+		}
456 456
 
457 457
 		// Make sure LIMIT is the last argument
458 458
 		if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
@@ -460,33 +460,33 @@  discard block
 block discarded – undo
460 460
 			unset( $args['limit'] );
461 461
 			$args['limit'] = $temp_limit;
462 462
 		}
463
-    }
463
+	}
464 464
 
465
-    public function uninstall() {
465
+	public function uninstall() {
466 466
 		if ( ! current_user_can( 'administrator' ) ) {
467
-            $frm_settings = FrmAppHelper::get_settings();
468
-            wp_die($frm_settings->admin_permission);
469
-        }
467
+			$frm_settings = FrmAppHelper::get_settings();
468
+			wp_die($frm_settings->admin_permission);
469
+		}
470 470
 
471
-        global $wpdb, $wp_roles;
471
+		global $wpdb, $wp_roles;
472 472
 
473 473
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
474 474
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
475 475
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
476 476
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
477 477
 
478
-        delete_option('frm_options');
479
-        delete_option('frm_db_version');
478
+		delete_option('frm_options');
479
+		delete_option('frm_db_version');
480 480
 
481
-        //delete roles
482
-        $frm_roles = FrmAppHelper::frm_capabilities();
483
-        $roles = get_editable_roles();
484
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
485
-            foreach ( $roles as $role => $details ) {
486
-                $wp_roles->remove_cap( $role, $frm_role );
487
-                unset($role, $details);
488
-    		}
489
-    		unset($frm_role, $frm_role_description);
481
+		//delete roles
482
+		$frm_roles = FrmAppHelper::frm_capabilities();
483
+		$roles = get_editable_roles();
484
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
485
+			foreach ( $roles as $role => $details ) {
486
+				$wp_roles->remove_cap( $role, $frm_role );
487
+				unset($role, $details);
488
+			}
489
+			unset($frm_role, $frm_role_description);
490 490
 		}
491 491
 		unset($roles, $frm_roles);
492 492
 
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 
511 511
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
512 512
 
513
-        do_action('frm_after_uninstall');
514
-        return true;
515
-    }
513
+		do_action('frm_after_uninstall');
514
+		return true;
515
+	}
516 516
 
517 517
 	/**
518 518
 	 * Migrate old styling settings. If sites are using the old
@@ -551,150 +551,150 @@  discard block
 block discarded – undo
551 551
 		}
552 552
 	}
553 553
 
554
-    /**
555
-     * Change field size from character to pixel -- Multiply by 9
556
-     */
557
-    private function migrate_to_17() {
558
-        global $wpdb;
554
+	/**
555
+	 * Change field size from character to pixel -- Multiply by 9
556
+	 */
557
+	private function migrate_to_17() {
558
+		global $wpdb;
559 559
 		$pixel_conversion = 9;
560 560
 
561
-        // Get query arguments
561
+		// Get query arguments
562 562
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
563 563
 		$query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' );
564 564
 
565
-        // Get results
565
+		// Get results
566 566
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
567 567
 
568
-        $updated = 0;
569
-        foreach ( $fields as $f ) {
570
-            $f->field_options = maybe_unserialize($f->field_options);
571
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
572
-                continue;
573
-            }
568
+		$updated = 0;
569
+		foreach ( $fields as $f ) {
570
+			$f->field_options = maybe_unserialize($f->field_options);
571
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
572
+				continue;
573
+			}
574 574
 
575 575
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
576
-            $f->field_options['size'] .= 'px';
577
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
578
-            if ( $u ) {
579
-                $updated++;
580
-            }
581
-            unset($f);
582
-        }
583
-
584
-        // Change the characters in widgets to pixels
585
-        $widgets = get_option('widget_frm_show_form');
586
-        if ( empty($widgets) ) {
587
-            return;
588
-        }
589
-
590
-        $widgets = maybe_unserialize($widgets);
591
-        foreach ( $widgets as $k => $widget ) {
592
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
593
-                continue;
594
-            }
576
+			$f->field_options['size'] .= 'px';
577
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
578
+			if ( $u ) {
579
+				$updated++;
580
+			}
581
+			unset($f);
582
+		}
583
+
584
+		// Change the characters in widgets to pixels
585
+		$widgets = get_option('widget_frm_show_form');
586
+		if ( empty($widgets) ) {
587
+			return;
588
+		}
589
+
590
+		$widgets = maybe_unserialize($widgets);
591
+		foreach ( $widgets as $k => $widget ) {
592
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
593
+				continue;
594
+			}
595 595
 			$size = round( $pixel_conversion * (int) $widget['size'] );
596
-            $size .= 'px';
596
+			$size .= 'px';
597 597
 			$widgets[ $k ]['size'] = $size;
598
-        }
599
-        update_option('widget_frm_show_form', $widgets);
600
-    }
601
-
602
-    /**
603
-     * Migrate post and email notification settings into actions
604
-     */
605
-    private function migrate_to_16() {
606
-        global $wpdb;
607
-
608
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
609
-
610
-        /**
611
-        * Old email settings format:
612
-        * email_to: Email or field id
613
-        * also_email_to: array of fields ids
614
-        * reply_to: Email, field id, 'custom'
615
-        * cust_reply_to: string
616
-        * reply_to_name: field id, 'custom'
617
-        * cust_reply_to_name: string
618
-        * plain_text: 0|1
619
-        * email_message: string or ''
620
-        * email_subject: string or ''
621
-        * inc_user_info: 0|1
622
-        * update_email: 0, 1, 2
623
-        *
624
-        * Old autoresponder settings format:
625
-        * auto_responder: 0|1
626
-        * ar_email_message: string or ''
627
-        * ar_email_to: field id
628
-        * ar_plain_text: 0|1
629
-        * ar_reply_to_name: string
630
-        * ar_reply_to: string
631
-        * ar_email_subject: string
632
-        * ar_update_email: 0, 1, 2
633
-        *
634
-        * New email settings:
635
-        * post_content: json settings
636
-        * post_title: form id
637
-        * post_excerpt: message
638
-        *
639
-        */
640
-
641
-        foreach ( $forms as $form ) {
598
+		}
599
+		update_option('widget_frm_show_form', $widgets);
600
+	}
601
+
602
+	/**
603
+	 * Migrate post and email notification settings into actions
604
+	 */
605
+	private function migrate_to_16() {
606
+		global $wpdb;
607
+
608
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
609
+
610
+		/**
611
+		 * Old email settings format:
612
+		 * email_to: Email or field id
613
+		 * also_email_to: array of fields ids
614
+		 * reply_to: Email, field id, 'custom'
615
+		 * cust_reply_to: string
616
+		 * reply_to_name: field id, 'custom'
617
+		 * cust_reply_to_name: string
618
+		 * plain_text: 0|1
619
+		 * email_message: string or ''
620
+		 * email_subject: string or ''
621
+		 * inc_user_info: 0|1
622
+		 * update_email: 0, 1, 2
623
+		 *
624
+		 * Old autoresponder settings format:
625
+		 * auto_responder: 0|1
626
+		 * ar_email_message: string or ''
627
+		 * ar_email_to: field id
628
+		 * ar_plain_text: 0|1
629
+		 * ar_reply_to_name: string
630
+		 * ar_reply_to: string
631
+		 * ar_email_subject: string
632
+		 * ar_update_email: 0, 1, 2
633
+		 *
634
+		 * New email settings:
635
+		 * post_content: json settings
636
+		 * post_title: form id
637
+		 * post_excerpt: message
638
+		 *
639
+		 */
640
+
641
+		foreach ( $forms as $form ) {
642 642
 			if ( $form->is_template && $form->default_template ) {
643 643
 				// don't migrate the default templates since the email will be added anyway
644 644
 				continue;
645 645
 			}
646 646
 
647
-            // Format form options
648
-            $form_options = maybe_unserialize($form->options);
647
+			// Format form options
648
+			$form_options = maybe_unserialize($form->options);
649 649
 
650
-            // Migrate settings to actions
651
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
652
-        }
653
-    }
650
+			// Migrate settings to actions
651
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
652
+		}
653
+	}
654 654
 
655
-    private function migrate_to_11() {
656
-        global $wpdb;
655
+	private function migrate_to_11() {
656
+		global $wpdb;
657 657
 
658
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
658
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
659 659
 
660
-        $sending = __( 'Sending', 'formidable' );
660
+		$sending = __( 'Sending', 'formidable' );
661 661
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
662
-        $old_default_html = <<<DEFAULT_HTML
662
+		$old_default_html = <<<DEFAULT_HTML
663 663
 <div class="frm_submit">
664 664
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
665 665
 <input type="submit" value="[button_label]" [button_action] />
666 666
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
667 667
 </div>
668 668
 DEFAULT_HTML;
669
-        unset($sending, $img);
669
+		unset($sending, $img);
670 670
 
671
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
672
-        $draft_link = FrmFormsHelper::get_draft_link();
671
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
672
+		$draft_link = FrmFormsHelper::get_draft_link();
673 673
 		foreach ( $forms as $form ) {
674
-            $form->options = maybe_unserialize($form->options);
675
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
676
-                continue;
677
-            }
674
+			$form->options = maybe_unserialize($form->options);
675
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
676
+				continue;
677
+			}
678 678
 
679
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
680
-                $form->options['submit_html'] = $new_default_html;
679
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
680
+				$form->options['submit_html'] = $new_default_html;
681 681
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
682 682
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
683 683
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
684 684
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
685
-            }
686
-            unset($form);
687
-        }
688
-        unset($forms);
689
-    }
685
+			}
686
+			unset($form);
687
+		}
688
+		unset($forms);
689
+	}
690 690
 
691
-    private function migrate_to_6() {
692
-        global $wpdb;
691
+	private function migrate_to_6() {
692
+		global $wpdb;
693 693
 
694 694
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
695 695
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
696 696
 
697
-        $default_html = <<<DEFAULT_HTML
697
+		$default_html = <<<DEFAULT_HTML
698 698
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
699 699
     <label class="frm_pos_[label_position]">[field_name]
700 700
         <span class="frm_required">[required_label]</span>
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 </div>
705 705
 DEFAULT_HTML;
706 706
 
707
-        $old_default_html = <<<DEFAULT_HTML
707
+		$old_default_html = <<<DEFAULT_HTML
708 708
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
709 709
     <label class="frm_pos_[label_position]">[field_name]
710 710
         <span class="frm_required">[required_label]</span>
@@ -714,23 +714,23 @@  discard block
 block discarded – undo
714 714
 </div>
715 715
 DEFAULT_HTML;
716 716
 
717
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
718
-        foreach ( $fields as $field ) {
719
-            $field->field_options = maybe_unserialize($field->field_options);
717
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
718
+		foreach ( $fields as $field ) {
719
+			$field->field_options = maybe_unserialize($field->field_options);
720 720
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
721
-                $field->field_options['custom_html'] = $new_default_html;
721
+				$field->field_options['custom_html'] = $new_default_html;
722 722
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
723
-            }
724
-            unset($field);
725
-        }
726
-        unset($default_html, $old_default_html, $fields);
727
-    }
728
-
729
-    private function migrate_to_4() {
730
-        global $wpdb;
723
+			}
724
+			unset($field);
725
+		}
726
+		unset($default_html, $old_default_html, $fields);
727
+	}
728
+
729
+	private function migrate_to_4() {
730
+		global $wpdb;
731 731
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
732
-        foreach ( $user_ids as $user_id ) {
732
+		foreach ( $user_ids as $user_id ) {
733 733
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
734
-        }
735
-    }
734
+		}
735
+	}
736 736
 }
Please login to merge, or discard this patch.