Completed
Push — master ( 609861...30b340 )
by Stephanie
02:35
created
classes/views/frm-entries/form.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?>
3
-<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
2
+if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?>
3
+<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container">
4 4
 	<div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?>
5 5
     </div>
6 6
 </div>
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
19 19
 <fieldset>
20 20
 <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?>
21
-<?php do_action( 'frm_after_title', compact('form') ) ?>
22
-<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" />
23
-<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" />
24
-<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" />
25
-<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" />
21
+<?php do_action( 'frm_after_title', compact( 'form' ) ) ?>
22
+<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" />
23
+<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" />
24
+<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" />
25
+<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" />
26 26
 <input type="hidden" name="item_meta[0]" value="" />
27 27
 <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
28
-<input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ) ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param('frm_verify', '', 'get', 'wp_kses_post' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> />
28
+<input type="text" class="frm_hidden frm_verify" id="frm_verify_<?php echo esc_attr( $form->id ) ?>" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param( 'frm_verify', '', 'get', 'wp_kses_post' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> />
29 29
 
30 30
 <?php if ( isset( $id ) ) { ?><input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /><?php }
31 31
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		} else {
37 37
 			do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) );
38 38
 		}
39
-    	do_action('frm_get_field_scripts', $field, $form, $form->id);
39
+    	do_action( 'frm_get_field_scripts', $field, $form, $form->id );
40 40
 	}
41 41
 }
42 42
 
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 if ( FrmAppHelper::is_admin() ) { ?>
45 45
 <div class="frm_form_field form-field">
46 46
 <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label>
47
-<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
47
+<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" />
48 48
 </div>
49 49
 <?php } else { ?>
50
-<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" />
50
+<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" />
51 51
 <?php }
52 52
 
53
-do_action('frm_entry_form', $form, $form_action, $errors);
53
+do_action( 'frm_entry_form', $form, $form_action, $errors );
54 54
 
55 55
 global $frm_vars;
56 56
 // close open section div
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 // close open collapsible toggle div
63
-if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
63
+if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) {
64 64
     echo "</div>\n";
65
-    unset($frm_vars['collapse_div']);
65
+    unset( $frm_vars['collapse_div'] );
66 66
 }
67 67
 
68
-echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form);
68
+echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form );
69 69
 
70 70
 if ( FrmForm::show_submit( $form ) ) {
71 71
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 </fieldset>
79 79
 </div>
80 80
 <?php
81
-if ( has_action('frm_entries_footer_scripts') ) {
81
+if ( has_action( 'frm_entries_footer_scripts' ) ) {
82 82
 ?><script type="text/javascript"><?php
83 83
 do_action( 'frm_entries_footer_scripts', $values['fields'], $form );
84 84
 ?></script><?php
Please login to merge, or discard this patch.
classes/models/FrmForm.php 1 patch
Spacing   +96 added lines, -96 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 = isset( $values['options'] ) ? (array) $values['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 ) );
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
107 107
 		$values['options'] = $new_opts;
108 108
 
109
-        if ( isset($new_opts['success_msg']) ) {
110
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
109
+        if ( isset( $new_opts['success_msg'] ) ) {
110
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
111 111
         }
112 112
 
113
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114 114
 
115 115
         if ( $new_opts != $values['options'] ) {
116 116
             global $wpdb;
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
             $values['status'] = 'published';
129 129
         }
130 130
 
131
-        if ( isset($values['form_key']) ) {
131
+        if ( isset( $values['form_key'] ) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133 133
         }
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137
-        $new_values = self::set_update_options( array(), $values);
137
+        $new_values = self::set_update_options( array(), $values );
138 138
 
139 139
         foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141
-				$new_values[ $value_key ] = $value;
141
+				$new_values[$value_key] = $value;
142 142
             }
143 143
         }
144 144
 
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         } else {
155 155
             $query_results = true;
156 156
         }
157
-        unset($new_values);
157
+        unset( $new_values );
158 158
 
159
-        $values = self::update_fields($id, $values);
159
+        $values = self::update_fields( $id, $values );
160 160
 
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
      * @return array
169 169
      */
170 170
 	public static function set_update_options( $new_values, $values ) {
171
-        if ( ! isset($values['options']) ) {
171
+        if ( ! isset( $values['options'] ) ) {
172 172
             return $new_values;
173 173
         }
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
177 177
 
178
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
178
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
179
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
180
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
181
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
182 182
 
183
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
184
-        $new_values['options'] = serialize($options);
183
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
184
+        $new_values['options'] = serialize( $options );
185 185
 
186 186
         return $new_values;
187 187
     }
@@ -192,54 +192,54 @@  discard block
 block discarded – undo
192 192
      */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195
-        if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+        if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196 196
             return $values;
197 197
         }
198 198
 
199
-        $all_fields = FrmField::get_all_for_form($id);
200
-        if ( empty($all_fields) ) {
199
+        $all_fields = FrmField::get_all_for_form( $id );
200
+        if ( empty( $all_fields ) ) {
201 201
             return $values;
202 202
         }
203 203
 
204
-        if ( ! isset($values['item_meta']) ) {
204
+        if ( ! isset( $values['item_meta'] ) ) {
205 205
             $values['item_meta'] = array();
206 206
         }
207 207
 
208 208
         $field_array = array();
209
-        $existing_keys = array_keys($values['item_meta']);
209
+        $existing_keys = array_keys( $values['item_meta'] );
210 210
         foreach ( $all_fields as $fid ) {
211
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212
-				$values['item_meta'][ $fid->id ] = '';
211
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
+				$values['item_meta'][$fid->id] = '';
213 213
             }
214
-			$field_array[ $fid->id ] = $fid;
214
+			$field_array[$fid->id] = $fid;
215 215
         }
216
-        unset($all_fields);
216
+        unset( $all_fields );
217 217
 
218 218
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
-			if ( isset( $field_array[ $field_id ] ) ) {
220
-				$field = $field_array[ $field_id ];
219
+			if ( isset( $field_array[$field_id] ) ) {
220
+				$field = $field_array[$field_id];
221 221
             } else {
222
-                $field = FrmField::getOne($field_id);
222
+                $field = FrmField::getOne( $field_id );
223 223
             }
224 224
 
225 225
             if ( ! $field ) {
226 226
                 continue;
227 227
             }
228 228
 
229
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
230 230
 			if ( $is_settings_page ) {
231 231
                 //updating the settings page
232
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
233
-					$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 ) );
234
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
232
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
233
+					$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 ) );
234
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
235 235
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
236 236
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237 237
                     $prev_opts = $field->field_options;
238
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
239 239
                     if ( $prev_opts != $field->field_options ) {
240 240
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
241 241
                     }
242
-                    unset($prev_opts);
242
+                    unset( $prev_opts );
243 243
                 }
244 244
             }
245 245
 
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
254 254
 
255 255
 			foreach ( $update_options as $opt => $default ) {
256
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
257 257
             }
258 258
 
259
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
260
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
259
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
260
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
261 261
 
262 262
 			$new_field = array(
263 263
 				'field_options' => $field->field_options,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 			FrmField::update( $field_id, $new_field );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
271
+            FrmField::delete_form_transient( $field->form_id );
272 272
         }
273 273
 		self::clear_form_cache();
274 274
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 		foreach ( $field_cols as $col => $default ) {
284 284
 			$default = ( $default === '' ) ? $field->{$col} : $default;
285
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
285
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
286 286
 		}
287 287
 	}
288 288
 
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
      */
293 293
 	public static function set_status( $id, $status ) {
294 294
         if ( 'trash' == $status ) {
295
-            return self::trash($id);
295
+            return self::trash( $id );
296 296
         }
297 297
 
298
-		$statuses  = array( 'published', 'draft', 'trash' );
298
+		$statuses = array( 'published', 'draft', 'trash' );
299 299
         if ( ! in_array( $status, $statuses ) ) {
300 300
             return false;
301 301
         }
302 302
 
303 303
         global $wpdb;
304 304
 
305
-        if ( is_array($id) ) {
305
+        if ( is_array( $id ) ) {
306 306
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
307 307
 			FrmDb::get_where_clause_and_values( $where );
308 308
 			array_unshift( $where['values'], $status );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             return self::destroy( $id );
329 329
         }
330 330
 
331
-        $form = self::getOne($id);
331
+        $form = self::getOne( $id );
332 332
         if ( ! $form ) {
333 333
             return false;
334 334
         }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	public static function destroy( $id ) {
363 363
         global $wpdb;
364 364
 
365
-        $form = self::getOne($id);
365
+        $form = self::getOne( $id );
366 366
         if ( ! $form ) {
367 367
             return false;
368 368
         }
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
         // Disconnect the entries from this form
372 372
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
373 373
         foreach ( $entries as $entry_id ) {
374
-            FrmEntry::destroy($entry_id);
375
-            unset($entry_id);
374
+            FrmEntry::destroy( $entry_id );
375
+            unset( $entry_id );
376 376
         }
377 377
 
378 378
         // Disconnect the fields from this form
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         if ( $query_results ) {
383 383
             // Delete all form actions linked to this form
384 384
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
385
-            $action_control->destroy($id, 'all');
385
+            $action_control->destroy( $id, 'all' );
386 386
 
387 387
 			// Clear form caching
388 388
 			self::clear_form_cache();
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 			$form->options = maybe_unserialize( $form->options );
417 417
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
418 418
 				self::destroy( $form->id );
419
-				$count++;
419
+				$count ++;
420 420
 			}
421 421
 
422 422
 			unset( $form );
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
      * @return string form name
429 429
      */
430 430
     public static function getName( $id ) {
431
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
431
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
432 432
         if ( $form ) {
433
-            $r = stripslashes($form->name);
433
+            $r = stripslashes( $form->name );
434 434
             return $r;
435 435
         }
436 436
 
437 437
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
438 438
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
439
-        $r = stripslashes($r);
439
+        $r = stripslashes( $r );
440 440
 
441 441
         return $r;
442 442
     }
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      */
456 456
 	public static function getKeyById( $id ) {
457 457
         $id = (int) $id;
458
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
458
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
459 459
         if ( $cache ) {
460 460
             return $cache->form_key;
461 461
         }
@@ -489,17 +489,17 @@  discard block
 block discarded – undo
489 489
 			$table_name = $prefix . 'frm_forms';
490 490
         } else {
491 491
 			$table_name = $wpdb->prefix . 'frm_forms';
492
-            $cache = wp_cache_get($id, 'frm_form');
492
+            $cache = wp_cache_get( $id, 'frm_form' );
493 493
             if ( $cache ) {
494
-                if ( isset($cache->options) ) {
495
-                    $cache->options = maybe_unserialize($cache->options);
494
+                if ( isset( $cache->options ) ) {
495
+                    $cache->options = maybe_unserialize( $cache->options );
496 496
                 }
497 497
 
498
-                return stripslashes_deep($cache);
498
+                return stripslashes_deep( $cache );
499 499
             }
500 500
         }
501 501
 
502
-        if ( is_numeric($id) ) {
502
+        if ( is_numeric( $id ) ) {
503 503
             $where = array( 'id' => $id );
504 504
         } else {
505 505
             $where = array( 'form_key' => $id );
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 
508 508
         $results = FrmDb::get_row( $table_name, $where );
509 509
 
510
-        if ( isset($results->options) ) {
510
+        if ( isset( $results->options ) ) {
511 511
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
512
-            $results->options = maybe_unserialize($results->options);
512
+            $results->options = maybe_unserialize( $results->options );
513 513
         }
514
-        return stripslashes_deep($results);
514
+        return stripslashes_deep( $results );
515 515
     }
516 516
 
517 517
     /**
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 			$results = reset( $results );
541 541
 		}
542 542
 
543
-        return stripslashes_deep($results);
543
+        return stripslashes_deep( $results );
544 544
     }
545 545
 
546 546
 	/**
@@ -580,19 +580,19 @@  discard block
 block discarded – undo
580 580
     	foreach ( $results as $row ) {
581 581
             if ( 'trash' != $row->status ) {
582 582
     	        if ( $row->is_template ) {
583
-					$counts['template']++;
583
+					$counts['template'] ++;
584 584
     	        } else {
585
-					$counts['published']++;
585
+					$counts['published'] ++;
586 586
     	        }
587 587
     	    } else {
588
-				$counts['trash']++;
588
+				$counts['trash'] ++;
589 589
         	}
590 590
 
591 591
     	    if ( 'draft' == $row->status ) {
592
-				$counts['draft']++;
592
+				$counts['draft'] ++;
593 593
     	    }
594 594
 
595
-    		unset($row);
595
+    		unset( $row );
596 596
     	}
597 597
 
598 598
     	$counts = (object) $counts;
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	public static function validate( $values ) {
619 619
         $errors = array();
620 620
 
621
-        return apply_filters('frm_validate_form', $errors, $values);
621
+        return apply_filters( 'frm_validate_form', $errors, $values );
622 622
     }
623 623
 
624 624
 	public static function get_params( $form = null ) {
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
 			self::maybe_get_form( $form );
631 631
 		}
632 632
 
633
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
634
-			return $frm_vars['form_params'][ $form->id ];
633
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
634
+			return $frm_vars['form_params'][$form->id];
635 635
 		}
636 636
 
637
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
637
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
638 638
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
639 639
 
640 640
 		$default_values = array(
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 			//if there are two forms on the same page, make sure not to submit both
653 653
 			foreach ( $default_values as $var => $default ) {
654 654
 				if ( $var == 'action' ) {
655
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
655
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
656 656
 				} else {
657
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
657
+					$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
658 658
 				}
659 659
 				unset( $var, $default );
660 660
 			}
661 661
 		} else {
662 662
 			foreach ( $default_values as $var => $default ) {
663
-				$values[ $var ] = $default;
663
+				$values[$var] = $default;
664 664
 				unset( $var, $default );
665 665
 			}
666 666
 		}
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	public static function list_page_params() {
676 676
 		$values = array();
677 677
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
678
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
678
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
679 679
 		}
680 680
 
681 681
 		return $values;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
696 696
 			'keep_post' => '',
697 697
 		) as $var => $default ) {
698
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
698
+			$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
699 699
 		}
700 700
 
701 701
 		return $values;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		$small_form = new stdClass();
753 753
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
754 754
 			$small_form->{$var} = $form->{$var};
755
-			unset($var);
755
+			unset( $var );
756 756
 		}
757 757
 
758 758
 		$frm_vars['forms_loaded'][] = $small_form;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 			$frm_vars['load_css'] = true;
763 763
 		}
764 764
 
765
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
765
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
766 766
 	}
767 767
 
768 768
 	public static function show_submit( $form ) {
@@ -776,6 +776,6 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public static function get_option( $atts ) {
778 778
 		$form = $atts['form'];
779
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
779
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
780 780
 	}
781 781
 }
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        FrmEntry::sanitize_entry_post( $values );
6
-        $errors = array();
4
+	public static function validate( $values, $exclude = false ) {
5
+		FrmEntry::sanitize_entry_post( $values );
6
+		$errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
-            return $errors;
11
-        }
8
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
+			return $errors;
11
+		}
12 12
 
13 13
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
14
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
-        }
14
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
+		}
16 16
 
17 17
 		self::set_item_key( $values );
18 18
 
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
 		return FrmField::getAll( $where, 'field_order' );
58 58
 	}
59 59
 
60
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
-        $defaults = array(
62
-            'id'              => $posted_field->id,
63
-            'parent_field_id' => '', // the id of the repeat or embed form
64
-            'key_pointer'     => '', // the pointer in the posted array
65
-            'exclude'         => array(), // exclude these field types from validation
66
-        );
67
-        $args = wp_parse_args( $args, $defaults );
60
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
+		$defaults = array(
62
+			'id'              => $posted_field->id,
63
+			'parent_field_id' => '', // the id of the repeat or embed form
64
+			'key_pointer'     => '', // the pointer in the posted array
65
+			'exclude'         => array(), // exclude these field types from validation
66
+		);
67
+		$args = wp_parse_args( $args, $defaults );
68 68
 
69
-        if ( empty($args['parent_field_id']) ) {
69
+		if ( empty($args['parent_field_id']) ) {
70 70
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
71
-        } else {
72
-            // value is from a nested form
73
-            $value = $values;
74
-        }
71
+		} else {
72
+			// value is from a nested form
73
+			$value = $values;
74
+		}
75 75
 
76
-        // Check for values in "Other" fields
77
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
76
+		// Check for values in "Other" fields
77
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
78 78
 
79 79
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80 80
 
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 			$value = reset($value);
84 84
 		}
85 85
 
86
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
86
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
87 87
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
88
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
89
-            $_POST['item_name'] = $value;
90
-        }
88
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
89
+			$_POST['item_name'] = $value;
90
+		}
91 91
 
92 92
 		if ( $value != '' ) {
93 93
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
97 97
 		}
98 98
 
99
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
99
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
100 100
 
101
-        self::validate_recaptcha($errors, $posted_field, $args);
101
+		self::validate_recaptcha($errors, $posted_field, $args);
102 102
 
103 103
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
104 104
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
105
-    }
105
+	}
106 106
 
107 107
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
108 108
 		$is_default = ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value );
@@ -124,32 +124,32 @@  discard block
 block discarded – undo
124 124
 
125 125
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
126 126
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
127
-            return;
128
-        }
127
+			return;
128
+		}
129 129
 
130
-        if ( trim($value) == 'http://' ) {
131
-            $value = '';
132
-        } else {
133
-            $value = esc_url_raw( $value );
130
+		if ( trim($value) == 'http://' ) {
131
+			$value = '';
132
+		} else {
133
+			$value = esc_url_raw( $value );
134 134
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
135
-        }
135
+		}
136 136
 
137
-        // validate the url format
137
+		// validate the url format
138 138
 		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
139 139
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
140 140
 		}
141
-    }
141
+	}
142 142
 
143 143
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
144
-        if ( $value == '' || $field->type != 'email' ) {
145
-            return;
146
-        }
144
+		if ( $value == '' || $field->type != 'email' ) {
145
+			return;
146
+		}
147 147
 
148
-        //validate the email format
149
-        if ( ! is_email($value) ) {
148
+		//validate the email format
149
+		if ( ! is_email($value) ) {
150 150
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
151
-        }
152
-    }
151
+		}
152
+	}
153 153
 
154 154
 	public static function validate_number_field( &$errors, $field, &$value, $args ) {
155 155
 		//validate the number format
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 	}
248 248
 
249 249
 	public static function validate_recaptcha( &$errors, $field, $args ) {
250
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
251
-            return;
252
-        }
250
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
251
+			return;
252
+		}
253 253
 
254 254
 		$frm_settings = FrmAppHelper::get_settings();
255 255
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -257,61 +257,61 @@  discard block
 block discarded – undo
257 257
 			return;
258 258
 		}
259 259
 
260
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
261
-            // If captcha is missing, check if it was already verified
260
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
261
+			// If captcha is missing, check if it was already verified
262 262
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
263
-                // There was no captcha submitted
263
+				// There was no captcha submitted
264 264
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
265
-            }
266
-            return;
267
-        }
265
+			}
266
+			return;
267
+		}
268 268
 
269
-        $arg_array = array(
270
-            'body'      => array(
269
+		$arg_array = array(
270
+			'body'      => array(
271 271
 				'secret'   => $frm_settings->privkey,
272 272
 				'response' => $_POST['g-recaptcha-response'],
273 273
 				'remoteip' => FrmAppHelper::get_ip_address(),
274 274
 			),
275 275
 		);
276
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
277
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
276
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
277
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
278 278
 
279
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
280
-            // What happens when the CAPTCHA was entered incorrectly
279
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
280
+			// What happens when the CAPTCHA was entered incorrectly
281 281
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
282
-        } else if ( is_wp_error( $resp ) ) {
282
+		} else if ( is_wp_error( $resp ) ) {
283 283
 			$error_string = $resp->get_error_message();
284 284
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
285 285
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
286
-        }
287
-    }
288
-
289
-    /**
290
-     * check for spam
291
-     * @param boolean $exclude
292
-     * @param array $values
293
-     * @param array $errors by reference
294
-     */
295
-    public static function spam_check( $exclude, $values, &$errors ) {
296
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
297
-            // only check spam if there are no other errors
298
-            return;
299
-        }
286
+		}
287
+	}
288
+
289
+	/**
290
+	 * check for spam
291
+	 * @param boolean $exclude
292
+	 * @param array $values
293
+	 * @param array $errors by reference
294
+	 */
295
+	public static function spam_check( $exclude, $values, &$errors ) {
296
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
297
+			// only check spam if there are no other errors
298
+			return;
299
+		}
300 300
 
301 301
 		if ( self::is_honeypot_spam() || self::is_spam_bot() ) {
302 302
 			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
303 303
 		}
304 304
 
305
-    	if ( self::blacklist_check( $values ) ) {
306
-            $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
307
-    	}
305
+		if ( self::blacklist_check( $values ) ) {
306
+			$errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
307
+		}
308 308
 
309
-        if ( self::is_akismet_spam( $values ) ) {
309
+		if ( self::is_akismet_spam( $values ) ) {
310 310
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
311 311
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
312 312
 			}
313
-	    }
314
-    }
313
+		}
314
+	}
315 315
 
316 316
 	private static function is_honeypot_spam() {
317 317
 		$honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' );
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
334 334
 	}
335 335
 
336
-    public static function blacklist_check( $values ) {
337
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
338
-            return false;
339
-        }
336
+	public static function blacklist_check( $values ) {
337
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
338
+			return false;
339
+		}
340 340
 
341
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
342
-    	if ( empty( $mod_keys ) ) {
343
-    		return false;
344
-    	}
341
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
342
+		if ( empty( $mod_keys ) ) {
343
+			return false;
344
+		}
345 345
 
346 346
 		$content = FrmEntriesHelper::entry_array_to_string( $values );
347 347
 		if ( empty( $content ) ) {
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$user_info = self::get_spam_check_user_info( $values );
354 354
 
355 355
 		return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
356
-    }
356
+	}
357 357
 
358 358
 	/**
359 359
 	 * Check entries for Akismet spam
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
         FrmEntry::sanitize_entry_post( $values );
6 6
         $errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
8
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
9 9
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10 10
             return $errors;
11 11
         }
12 12
 
13
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
13
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
14 14
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15 15
         }
16 16
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
         );
67 67
         $args = wp_parse_args( $args, $defaults );
68 68
 
69
-        if ( empty($args['parent_field_id']) ) {
70
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
69
+        if ( empty( $args['parent_field_id'] ) ) {
70
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
71 71
         } else {
72 72
             // value is from a nested form
73 73
             $value = $values;
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80 80
 
81 81
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
82
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
83
-			$value = reset($value);
82
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
83
+			$value = reset( $value );
84 84
 		}
85 85
 
86 86
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
87
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
87
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
88 88
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
89 89
             $_POST['item_name'] = $value;
90 90
         }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
97 97
 		}
98 98
 
99
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
99
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
100 100
 
101
-        self::validate_recaptcha($errors, $posted_field, $args);
101
+        self::validate_recaptcha( $errors, $posted_field, $args );
102 102
 
103 103
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
104 104
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             return;
128 128
         }
129 129
 
130
-        if ( trim($value) == 'http://' ) {
130
+        if ( trim( $value ) == 'http://' ) {
131 131
             $value = '';
132 132
         } else {
133 133
             $value = esc_url_raw( $value );
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
         }
136 136
 
137 137
         // validate the url format
138
-		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
139
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
138
+		if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
139
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
140 140
 		}
141 141
     }
142 142
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
         }
147 147
 
148 148
         //validate the email format
149
-        if ( ! is_email($value) ) {
150
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
149
+        if ( ! is_email( $value ) ) {
150
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
151 151
         }
152 152
     }
153 153
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 			$value = str_replace( ',', '', $value );
162 162
 		}
163 163
 
164
-		if ( ! is_numeric( $value) ) {
165
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
164
+		if ( ! is_numeric( $value ) ) {
165
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
166 166
 		}
167 167
 
168 168
 		// validate number settings
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
173 173
 				//minnum maxnum
174 174
 				if ( (float) $value < $field->field_options['minnum'] ) {
175
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
175
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
176 176
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
177
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
177
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
178 178
 				}
179 179
 			}
180 180
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			$pattern = self::phone_format( $field );
187 187
 
188 188
 			if ( ! preg_match( $pattern, $value ) ) {
189
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
189
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
190 190
 			}
191 191
 		}
192 192
 	}
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 			return;
258 258
 		}
259 259
 
260
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
260
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
261 261
             // If captcha is missing, check if it was already verified
262 262
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
263 263
                 // There was no captcha submitted
264
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
264
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
265 265
             }
266 266
             return;
267 267
         }
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
 			),
275 275
 		);
276 276
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
277
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
277
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
278 278
 
279 279
         if ( isset( $response['success'] ) && ! $response['success'] ) {
280 280
             // What happens when the CAPTCHA was entered incorrectly
281
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
281
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
282 282
         } else if ( is_wp_error( $resp ) ) {
283 283
 			$error_string = $resp->get_error_message();
284
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
285
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
284
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
285
+			$errors['field' . $args['id']] .= ' ' . $error_string;
286 286
         }
287 287
     }
288 288
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 	private static function is_akismet_spam( $values ) {
327 327
 		global $wpcom_api_key;
328
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
328
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
329 329
 	}
330 330
 
331 331
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	}
335 335
 
336 336
     public static function blacklist_check( $values ) {
337
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
337
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
338 338
             return false;
339 339
         }
340 340
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
391 391
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
392 392
 		$datas['blog_lang'] = get_locale();
393
-		$datas['blog_charset'] = get_option('blog_charset');
393
+		$datas['blog_charset'] = get_option( 'blog_charset' );
394 394
 
395 395
 		if ( akismet_test_mode() ) {
396 396
 			$datas['is_test'] = 'true';
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 			// Send any potentially useful $_SERVER vars, but avoid sending junk we don't need.
446 446
 			if ( $include_value ) {
447
-				$datas[ $key ] = $value;
447
+				$datas[$key] = $value;
448 448
 			}
449 449
 			unset( $key, $value );
450 450
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 2 patches
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public static function get_direct_link( $key, $form = false ) {
21 21
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
22
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
23
-
24
-        return $target_url;
25
-    }
26
-
27
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
28
-        $defaults = array(
29
-            'blank'     => true,
30
-            'field_id'  => false,
31
-            'onchange'  => false,
32
-            'exclude'   => false,
33
-            'class'     => '',
22
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
23
+
24
+		return $target_url;
25
+	}
26
+
27
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
28
+		$defaults = array(
29
+			'blank'     => true,
30
+			'field_id'  => false,
31
+			'onchange'  => false,
32
+			'exclude'   => false,
33
+			'class'     => '',
34 34
 			'inc_children' => 'exclude',
35
-        );
36
-        $args = wp_parse_args( $args, $defaults );
35
+		);
36
+		$args = wp_parse_args( $args, $defaults );
37 37
 
38
-        if ( ! $args['field_id'] ) {
39
-            $args['field_id'] = $field_name;
40
-        }
38
+		if ( ! $args['field_id'] ) {
39
+			$args['field_id'] = $field_name;
40
+		}
41 41
 
42 42
 		$query = array();
43
-        if ( $args['exclude'] ) {
43
+		if ( $args['exclude'] ) {
44 44
 			$query['id !'] = $args['exclude'];
45
-        }
45
+		}
46 46
 
47
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
47
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
48 48
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
49 49
 		$add_html = array();
50 50
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
51 51
 		self::add_html_attr( $args['class'], 'class', $add_html );
52 52
 
53
-        ?>
53
+		?>
54 54
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
55 55
 		<?php if ( $args['blank'] ) { ?>
56 56
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		<?php } ?>
63 63
         </select>
64 64
         <?php
65
-    }
65
+	}
66 66
 
67 67
 	/**
68 68
 	 * @param string $class
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		}
78 78
 	}
79 79
 
80
-    public static function form_switcher() {
80
+	public static function form_switcher() {
81 81
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
82 82
 		$forms = FrmForm::get_published_forms( $where );
83 83
 
@@ -86,32 +86,32 @@  discard block
 block discarded – undo
86 86
 			unset( $args['form'] );
87 87
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
88 88
 			unset( $args['id'] );
89
-        }
89
+		}
90 90
 
91 91
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
92 92
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
93
-            $args['frm_action'] = 'list';
94
-            $args['form'] = 0;
93
+			$args['frm_action'] = 'list';
94
+			$args['form'] = 0;
95 95
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
96
-            $args['frm_action'] = 'edit';
96
+			$args['frm_action'] = 'edit';
97 97
 		} else if ( isset( $_GET['post'] ) ) {
98
-            $args['form'] = 0;
99
-            $base = admin_url('edit.php?post_type=frm_display');
100
-        }
98
+			$args['form'] = 0;
99
+			$base = admin_url('edit.php?post_type=frm_display');
100
+		}
101 101
 
102
-        ?>
102
+		?>
103 103
 		<li class="dropdown last" id="frm_bs_dropdown">
104 104
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
105 105
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
106 106
 			<?php
107 107
 			foreach ( $forms as $form ) {
108 108
 				if ( isset( $args['id'] ) ) {
109
-			        $args['id'] = $form->id;
109
+					$args['id'] = $form->id;
110 110
 				}
111
-			    if ( isset( $args['form'] ) ) {
112
-			        $args['form'] = $form->id;
111
+				if ( isset( $args['form'] ) ) {
112
+					$args['form'] = $form->id;
113 113
 				}
114
-                ?>
114
+				?>
115 115
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
116 116
 			<?php
117 117
 				unset( $form );
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 			</ul>
120 120
 		</li>
121 121
         <?php
122
-    }
122
+	}
123 123
 
124 124
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
125
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
127
-    }
125
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
127
+	}
128 128
 
129 129
 	/**
130 130
 	 * Get the invalid form error message
@@ -148,104 +148,104 @@  discard block
 block discarded – undo
148 148
 		return $message;
149 149
 	}
150 150
 
151
-    /**
152
-     * Used when a form is created
153
-     */
154
-    public static function setup_new_vars( $values = array() ) {
155
-        global $wpdb;
151
+	/**
152
+	 * Used when a form is created
153
+	 */
154
+	public static function setup_new_vars( $values = array() ) {
155
+		global $wpdb;
156 156
 
157
-        if ( ! empty( $values ) ) {
158
-            $post_values = $values;
159
-        } else {
160
-            $values = array();
161
-            $post_values = isset($_POST) ? $_POST : array();
162
-        }
157
+		if ( ! empty( $values ) ) {
158
+			$post_values = $values;
159
+		} else {
160
+			$values = array();
161
+			$post_values = isset($_POST) ? $_POST : array();
162
+		}
163 163
 
164 164
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
165 165
 			if ( ! isset( $values[ $var ] ) ) {
166 166
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
167
-            }
168
-        }
167
+			}
168
+		}
169 169
 
170
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
170
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
171 171
 
172 172
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
173
-            if ( ! isset( $values[ $var ] ) ) {
173
+			if ( ! isset( $values[ $var ] ) ) {
174 174
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
175
-            }
176
-        }
175
+			}
176
+		}
177 177
 
178
-        if ( ! isset( $values['form_key'] ) ) {
178
+		if ( ! isset( $values['form_key'] ) ) {
179 179
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
180
-        }
180
+		}
181 181
 
182 182
 		$values = self::fill_default_opts( $values, false, $post_values );
183 183
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
184 184
 
185
-        return apply_filters('frm_setup_new_form_vars', $values);
186
-    }
185
+		return apply_filters('frm_setup_new_form_vars', $values);
186
+	}
187 187
 
188
-    /**
189
-     * Used when editing a form
190
-     */
191
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
188
+	/**
189
+	 * Used when editing a form
190
+	 */
191
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
192 192
 		if ( empty( $post_values ) ) {
193 193
 			$post_values = stripslashes_deep( $_POST );
194 194
 		}
195 195
 
196
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
199
-        $values['status'] = $record->status;
196
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
199
+		$values['status'] = $record->status;
200 200
 
201
-        $values = self::fill_default_opts($values, $record, $post_values);
201
+		$values = self::fill_default_opts($values, $record, $post_values);
202 202
 
203
-        return apply_filters('frm_setup_edit_form_vars', $values);
204
-    }
203
+		return apply_filters('frm_setup_edit_form_vars', $values);
204
+	}
205 205
 
206 206
 	public static function fill_default_opts( $values, $record, $post_values ) {
207 207
 
208
-        $defaults = self::get_default_opts();
208
+		$defaults = self::get_default_opts();
209 209
 		foreach ( $defaults as $var => $default ) {
210
-            if ( is_array($default) ) {
211
-                if ( ! isset( $values[ $var ] ) ) {
210
+			if ( is_array($default) ) {
211
+				if ( ! isset( $values[ $var ] ) ) {
212 212
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
213
-                }
213
+				}
214 214
 
215
-                foreach ( $default as $k => $v ) {
215
+				foreach ( $default as $k => $v ) {
216 216
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
217 217
 
218
-                    if ( is_array( $v ) ) {
219
-                        foreach ( $v as $k1 => $v1 ) {
218
+					if ( is_array( $v ) ) {
219
+						foreach ( $v as $k1 => $v1 ) {
220 220
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
221
-                            unset( $k1, $v1 );
222
-                        }
223
-                    }
221
+							unset( $k1, $v1 );
222
+						}
223
+					}
224 224
 
225
-                    unset($k, $v);
226
-                }
227
-            } else {
225
+					unset($k, $v);
226
+				}
227
+			} else {
228 228
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
229
-            }
229
+			}
230 230
 
231
-            unset($var, $default);
232
-        }
231
+			unset($var, $default);
232
+		}
233 233
 
234
-        return $values;
235
-    }
234
+		return $values;
235
+	}
236 236
 
237
-    public static function get_default_opts() {
238
-        $frm_settings = FrmAppHelper::get_settings();
237
+	public static function get_default_opts() {
238
+		$frm_settings = FrmAppHelper::get_settings();
239 239
 
240
-        return array(
241
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
-            'before_html' => self::get_default_html('before'),
245
-            'after_html' => '',
246
-            'submit_html' => self::get_default_html('submit'),
247
-        );
248
-    }
240
+		return array(
241
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
+			'before_html' => self::get_default_html('before'),
245
+			'after_html' => '',
246
+			'submit_html' => self::get_default_html('submit'),
247
+		);
248
+	}
249 249
 
250 250
 	/**
251 251
 	 * @param array $options
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 		}
261 261
 	}
262 262
 
263
-    /**
264
-     * @param string $loc
265
-     */
263
+	/**
264
+	 * @param string $loc
265
+	 */
266 266
 	public static function get_default_html( $loc ) {
267 267
 		if ( $loc == 'submit' ) {
268
-            $draft_link = self::get_draft_link();
269
-            $default_html = <<<SUBMIT_HTML
268
+			$draft_link = self::get_draft_link();
269
+			$default_html = <<<SUBMIT_HTML
270 270
 <div class="frm_submit">
271 271
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
272 272
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -274,22 +274,22 @@  discard block
 block discarded – undo
274 274
 </div>
275 275
 SUBMIT_HTML;
276 276
 		} else if ( $loc == 'before' ) {
277
-            $default_html = <<<BEFORE_HTML
277
+			$default_html = <<<BEFORE_HTML
278 278
 <legend class="frm_hidden">[form_name]</legend>
279 279
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
280 280
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
281 281
 BEFORE_HTML;
282 282
 		} else {
283
-            $default_html = '';
284
-        }
283
+			$default_html = '';
284
+		}
285 285
 
286
-        return $default_html;
287
-    }
286
+		return $default_html;
287
+	}
288 288
 
289
-    public static function get_draft_link() {
290
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
291
-        return $link;
292
-    }
289
+	public static function get_draft_link() {
290
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
291
+		return $link;
292
+	}
293 293
 
294 294
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
295 295
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		echo $button_parts[1];
317 317
 	}
318 318
 
319
-    /**
320
-     * Automatically add end section fields if they don't exist (2.0 migration)
321
-     * @since 2.0
322
-     *
323
-     * @param boolean $reset_fields
324
-     */
325
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
319
+	/**
320
+	 * Automatically add end section fields if they don't exist (2.0 migration)
321
+	 * @since 2.0
322
+	 *
323
+	 * @param boolean $reset_fields
324
+	 */
325
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
326 326
 		if ( empty( $fields ) ) {
327 327
 			return;
328 328
 		}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		$prev_order = false;
333 333
 		$add_order = 0;
334 334
 		$last_field = false;
335
-        foreach ( $fields as $field ) {
335
+		foreach ( $fields as $field ) {
336 336
 			if ( $prev_order === $field->field_order ) {
337 337
 				$add_order++;
338 338
 			}
@@ -343,48 +343,48 @@  discard block
 block discarded – undo
343 343
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
344 344
 			}
345 345
 
346
-            switch ( $field->type ) {
347
-                case 'divider':
348
-                    // create an end section if open
346
+			switch ( $field->type ) {
347
+				case 'divider':
348
+					// create an end section if open
349 349
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
350 350
 
351
-                    // mark it open for the next end section
352
-                    $open = true;
353
-                break;
354
-                case 'break';
351
+					// mark it open for the next end section
352
+					$open = true;
353
+				break;
354
+				case 'break';
355 355
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
356
-                break;
357
-                case 'end_divider':
358
-                    if ( ! $open ) {
359
-                        // the section isn't open, so this is an extra field that needs to be removed
360
-                        FrmField::destroy( $field->id );
361
-                        $reset_fields = true;
362
-                    }
363
-
364
-                    // There is already an end section here, so there is no need to create one
365
-                    $open = false;
366
-            }
356
+				break;
357
+				case 'end_divider':
358
+					if ( ! $open ) {
359
+						// the section isn't open, so this is an extra field that needs to be removed
360
+						FrmField::destroy( $field->id );
361
+						$reset_fields = true;
362
+					}
363
+
364
+					// There is already an end section here, so there is no need to create one
365
+					$open = false;
366
+			}
367 367
 			$prev_order = $field->field_order;
368 368
 
369 369
 			$last_field = $field;
370 370
 			unset( $field );
371
-        }
371
+		}
372 372
 
373 373
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
374
-    }
374
+	}
375 375
 
376 376
 	/**
377 377
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
378 378
 	 * Fix any ordering that may be messed up
379 379
 	 */
380 380
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
381
-        if ( ! $open ) {
382
-            return;
383
-        }
381
+		if ( ! $open ) {
382
+			return;
383
+		}
384 384
 
385 385
 		$end_section_values['field_order'] = $field->field_order + 1;
386 386
 
387
-        FrmField::create( $end_section_values );
387
+		FrmField::create( $end_section_values );
388 388
 
389 389
 		if ( $move == 'move' ) {
390 390
 			// bump the order of current field unless we're at the end of the form
@@ -392,39 +392,39 @@  discard block
 block discarded – undo
392 392
 		}
393 393
 
394 394
 		$add_order += 2;
395
-        $open = false;
396
-        $reset_fields = true;
397
-    }
395
+		$open = false;
396
+		$reset_fields = true;
397
+	}
398 398
 
399
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
399
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
400 400
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
401
-            if ( $code == 'form_name' ) {
402
-                $replace_with = $form->name;
403
-            } else if ( $code == 'form_description' ) {
404
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
405
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
406
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
407
-            } else {
408
-                $replace_with = '';
409
-            }
401
+			if ( $code == 'form_name' ) {
402
+				$replace_with = $form->name;
403
+			} else if ( $code == 'form_description' ) {
404
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
405
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
406
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
407
+			} else {
408
+				$replace_with = '';
409
+			}
410 410
 
411
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
412
-        }
411
+			FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
412
+		}
413 413
 
414
-        //replace [form_key]
415
-        $html = str_replace('[form_key]', $form->form_key, $html);
414
+		//replace [form_key]
415
+		$html = str_replace('[form_key]', $form->form_key, $html);
416 416
 
417
-        //replace [frmurl]
418
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
417
+		//replace [frmurl]
418
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
419 419
 
420 420
 		if ( strpos( $html, '[button_label]' ) ) {
421 421
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
422 422
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
423 423
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
424 424
 			$html = str_replace( '[button_label]', $submit_label, $html );
425
-        }
425
+		}
426 426
 
427
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
427
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
428 428
 
429 429
 		if ( strpos( $html, '[if back_button]' ) ) {
430 430
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -438,17 +438,17 @@  discard block
 block discarded – undo
438 438
 			$html = do_shortcode( $html );
439 439
 		}
440 440
 
441
-        return $html;
442
-    }
441
+		return $html;
442
+	}
443 443
 
444 444
 	public static function submit_button_label( $submit ) {
445
-        if ( ! $submit || empty($submit) ) {
446
-            $frm_settings = FrmAppHelper::get_settings();
447
-            $submit = $frm_settings->submit_value;
448
-        }
445
+		if ( ! $submit || empty($submit) ) {
446
+			$frm_settings = FrmAppHelper::get_settings();
447
+			$submit = $frm_settings->submit_value;
448
+		}
449 449
 
450
-        return $submit;
451
-    }
450
+		return $submit;
451
+	}
452 452
 
453 453
 	/**
454 454
 	 * If the Formidable styling isn't being loaded,
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	public static function get_form_style_class( $form = false ) {
468
-        $style = self::get_form_style($form);
469
-        $class = ' with_frm_style';
470
-
471
-        if ( empty($style) ) {
472
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
473
-                return $class;
474
-            } else {
475
-                return;
476
-            }
477
-        }
478
-
479
-        //If submit button needs to be inline or centered
480
-        if ( is_object($form) ) {
468
+		$style = self::get_form_style($form);
469
+		$class = ' with_frm_style';
470
+
471
+		if ( empty($style) ) {
472
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
473
+				return $class;
474
+			} else {
475
+				return;
476
+			}
477
+		}
478
+
479
+		//If submit button needs to be inline or centered
480
+		if ( is_object($form) ) {
481 481
 			$form = $form->options;
482 482
 		}
483 483
 
@@ -489,17 +489,17 @@  discard block
 block discarded – undo
489 489
 			$class .= ' frm_center_submit';
490 490
 		}
491 491
 
492
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
492
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
493 493
 
494
-        return $class;
495
-    }
494
+		return $class;
495
+	}
496 496
 
497
-    /**
498
-     * @param string|boolean $form
499
-     *
500
-     * @return string
501
-     */
502
-    public static function get_form_style( $form ) {
497
+	/**
498
+	 * @param string|boolean $form
499
+	 *
500
+	 * @return string
501
+	 */
502
+	public static function get_form_style( $form ) {
503 503
 		$style = 1;
504 504
 		if ( empty( $form ) || 'default' == 'form' ) {
505 505
 			return $style;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
520 520
 
521 521
 		return $style;
522
-    }
522
+	}
523 523
 
524 524
 	/**
525 525
 	 * Display the validation error messages when an entry is submitted
@@ -581,74 +581,74 @@  discard block
 block discarded – undo
581 581
 	}
582 582
 
583 583
 	public static function get_scroll_js( $form_id ) {
584
-        ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
585
-    }
584
+		?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
585
+	}
586 586
 
587 587
 	public static function edit_form_link( $form_id ) {
588
-        if ( is_object($form_id) ) {
589
-            $form = $form_id;
590
-            $name = $form->name;
591
-            $form_id = $form->id;
592
-        } else {
593
-            $name = FrmForm::getName($form_id);
594
-        }
595
-
596
-        if ( $form_id ) {
588
+		if ( is_object($form_id) ) {
589
+			$form = $form_id;
590
+			$name = $form->name;
591
+			$form_id = $form->id;
592
+		} else {
593
+			$name = FrmForm::getName($form_id);
594
+		}
595
+
596
+		if ( $form_id ) {
597 597
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
598
-	    } else {
599
-	        $val = '';
600
-	    }
598
+		} else {
599
+			$val = '';
600
+		}
601 601
 
602
-	    return $val;
602
+		return $val;
603 603
 	}
604 604
 
605 605
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
606
-        $link = '';
607
-        $labels = array(
608
-            'restore' => array(
609
-                'long'  => __( 'Restore from Trash', 'formidable' ),
610
-                'short' => __( 'Restore', 'formidable' ),
611
-            ),
612
-            'trash' => array(
613
-                'long'  => __( 'Move to Trash', 'formidable' ),
614
-                'short' => __( 'Trash', 'formidable' ),
615
-            ),
616
-            'delete' => array(
617
-                'long'  => __( 'Delete Permanently', 'formidable' ),
618
-                'short' => __( 'Delete', 'formidable' ),
619
-            ),
620
-        );
621
-
622
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
606
+		$link = '';
607
+		$labels = array(
608
+			'restore' => array(
609
+				'long'  => __( 'Restore from Trash', 'formidable' ),
610
+				'short' => __( 'Restore', 'formidable' ),
611
+			),
612
+			'trash' => array(
613
+				'long'  => __( 'Move to Trash', 'formidable' ),
614
+				'short' => __( 'Trash', 'formidable' ),
615
+			),
616
+			'delete' => array(
617
+				'long'  => __( 'Delete Permanently', 'formidable' ),
618
+				'short' => __( 'Delete', 'formidable' ),
619
+			),
620
+		);
621
+
622
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
623 623
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
624
-        if ( 'trash' == $status ) {
624
+		if ( 'trash' == $status ) {
625 625
 			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
626
-        } else if ( current_user_can('frm_delete_forms') ) {
627
-            if ( EMPTY_TRASH_DAYS ) {
626
+		} else if ( current_user_can('frm_delete_forms') ) {
627
+			if ( EMPTY_TRASH_DAYS ) {
628 628
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
629
-            } else {
629
+			} else {
630 630
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
631
-            }
632
-        }
631
+			}
632
+		}
633 633
 
634
-        return $link;
635
-    }
634
+		return $link;
635
+	}
636 636
 
637 637
 	public static function status_nice_name( $status ) {
638
-        $nice_names = array(
639
-            'draft'     => __( 'Draft', 'formidable' ),
640
-            'trash'     => __( 'Trash', 'formidable' ),
641
-            'publish'   => __( 'Published', 'formidable' ),
642
-        );
643
-
644
-        if ( ! in_array($status, array_keys($nice_names)) ) {
645
-            $status = 'publish';
646
-        }
638
+		$nice_names = array(
639
+			'draft'     => __( 'Draft', 'formidable' ),
640
+			'trash'     => __( 'Trash', 'formidable' ),
641
+			'publish'   => __( 'Published', 'formidable' ),
642
+		);
643
+
644
+		if ( ! in_array($status, array_keys($nice_names)) ) {
645
+			$status = 'publish';
646
+		}
647 647
 
648 648
 		$name = $nice_names[ $status ];
649 649
 
650
-        return $name;
651
-    }
650
+		return $name;
651
+	}
652 652
 
653 653
 	public static function get_params() {
654 654
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public static function get_direct_link( $key, $form = false ) {
21 21
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
22
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
22
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
23 23
 
24 24
         return $target_url;
25 25
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 			$query['id !'] = $args['exclude'];
45 45
         }
46 46
 
47
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
47
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
48 48
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
49 49
 		$add_html = array();
50 50
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
 		<?php foreach ( $forms as $form ) { ?>
59 59
 			<option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php
60
-				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ;
60
+				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' );
61 61
 			?></option>
62 62
 		<?php } ?>
63 63
         </select>
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public static function add_html_attr( $class, $param, &$add_html ) {
75 75
 		if ( ! empty( $class ) ) {
76
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
76
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
77 77
 		}
78 78
 	}
79 79
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$args = array( 'id' => 0, 'form' => 0 );
85 85
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
86 86
 			unset( $args['form'] );
87
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
87
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
88 88
 			unset( $args['id'] );
89 89
         }
90 90
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
93 93
             $args['frm_action'] = 'list';
94 94
             $args['form'] = 0;
95
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
95
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
96 96
             $args['frm_action'] = 'edit';
97 97
 		} else if ( isset( $_GET['post'] ) ) {
98 98
             $args['form'] = 0;
99
-            $base = admin_url('edit.php?post_type=frm_display');
99
+            $base = admin_url( 'edit.php?post_type=frm_display' );
100 100
         }
101 101
 
102 102
         ?>
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			        $args['form'] = $form->id;
113 113
 				}
114 114
                 ?>
115
-				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
115
+				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
116 116
 			<?php
117 117
 				unset( $form );
118 118
 			} ?>
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
     }
123 123
 
124 124
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
125
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
125
+        echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
126
+        echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
127 127
     }
128 128
 
129 129
 	/**
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
             $post_values = $values;
159 159
         } else {
160 160
             $values = array();
161
-            $post_values = isset($_POST) ? $_POST : array();
161
+            $post_values = isset( $_POST ) ? $_POST : array();
162 162
         }
163 163
 
164 164
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
165
-			if ( ! isset( $values[ $var ] ) ) {
166
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
165
+			if ( ! isset( $values[$var] ) ) {
166
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
167 167
             }
168 168
         }
169 169
 
170
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
170
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
171 171
 
172 172
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
173
-            if ( ! isset( $values[ $var ] ) ) {
174
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
173
+            if ( ! isset( $values[$var] ) ) {
174
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
175 175
             }
176 176
         }
177 177
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		$values = self::fill_default_opts( $values, false, $post_values );
183 183
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
184 184
 
185
-        return apply_filters('frm_setup_new_form_vars', $values);
185
+        return apply_filters( 'frm_setup_new_form_vars', $values );
186 186
     }
187 187
 
188 188
     /**
@@ -193,42 +193,42 @@  discard block
 block discarded – undo
193 193
 			$post_values = stripslashes_deep( $_POST );
194 194
 		}
195 195
 
196
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
196
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
197
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
198
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
199 199
         $values['status'] = $record->status;
200 200
 
201
-        $values = self::fill_default_opts($values, $record, $post_values);
201
+        $values = self::fill_default_opts( $values, $record, $post_values );
202 202
 
203
-        return apply_filters('frm_setup_edit_form_vars', $values);
203
+        return apply_filters( 'frm_setup_edit_form_vars', $values );
204 204
     }
205 205
 
206 206
 	public static function fill_default_opts( $values, $record, $post_values ) {
207 207
 
208 208
         $defaults = self::get_default_opts();
209 209
 		foreach ( $defaults as $var => $default ) {
210
-            if ( is_array($default) ) {
211
-                if ( ! isset( $values[ $var ] ) ) {
212
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
210
+            if ( is_array( $default ) ) {
211
+                if ( ! isset( $values[$var] ) ) {
212
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
213 213
                 }
214 214
 
215 215
                 foreach ( $default as $k => $v ) {
216
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
216
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
217 217
 
218 218
                     if ( is_array( $v ) ) {
219 219
                         foreach ( $v as $k1 => $v1 ) {
220
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
220
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
221 221
                             unset( $k1, $v1 );
222 222
                         }
223 223
                     }
224 224
 
225
-                    unset($k, $v);
225
+                    unset( $k, $v );
226 226
                 }
227 227
             } else {
228
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
228
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
229 229
             }
230 230
 
231
-            unset($var, $default);
231
+            unset( $var, $default );
232 232
         }
233 233
 
234 234
         return $values;
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
             'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242 242
             'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243 243
             'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
-            'before_html' => self::get_default_html('before'),
244
+            'before_html' => self::get_default_html( 'before' ),
245 245
             'after_html' => '',
246
-            'submit_html' => self::get_default_html('submit'),
246
+            'submit_html' => self::get_default_html( 'submit' ),
247 247
         );
248 248
     }
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	public static function fill_form_options( &$options, $values ) {
256 256
 		$defaults = self::get_default_opts();
257 257
 		foreach ( $defaults as $var => $default ) {
258
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
258
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
259 259
 			unset( $var, $default );
260 260
 		}
261 261
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		$last_field = false;
335 335
         foreach ( $fields as $field ) {
336 336
 			if ( $prev_order === $field->field_order ) {
337
-				$add_order++;
337
+				$add_order ++;
338 338
 			}
339 339
 
340 340
 			if ( $add_order ) {
@@ -401,21 +401,21 @@  discard block
 block discarded – undo
401 401
             if ( $code == 'form_name' ) {
402 402
                 $replace_with = $form->name;
403 403
             } else if ( $code == 'form_description' ) {
404
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
405
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
404
+                $replace_with = FrmAppHelper::use_wpautop( $form->description );
405
+            } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
406 406
                 $replace_with = FrmAppHelper::simple_get( 'entry' );
407 407
             } else {
408 408
                 $replace_with = '';
409 409
             }
410 410
 
411
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
411
+            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
412 412
         }
413 413
 
414 414
         //replace [form_key]
415
-        $html = str_replace('[form_key]', $form->form_key, $html);
415
+        $html = str_replace( '[form_key]', $form->form_key, $html );
416 416
 
417 417
         //replace [frmurl]
418
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
418
+        $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
419 419
 
420 420
 		if ( strpos( $html, '[button_label]' ) ) {
421 421
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			$html = str_replace( '[button_label]', $submit_label, $html );
425 425
         }
426 426
 
427
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
427
+        $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
428 428
 
429 429
 		if ( strpos( $html, '[if back_button]' ) ) {
430 430
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
 	public static function submit_button_label( $submit ) {
445
-        if ( ! $submit || empty($submit) ) {
445
+        if ( ! $submit || empty( $submit ) ) {
446 446
             $frm_settings = FrmAppHelper::get_settings();
447 447
             $submit = $frm_settings->submit_value;
448 448
         }
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	public static function get_form_style_class( $form = false ) {
468
-        $style = self::get_form_style($form);
468
+        $style = self::get_form_style( $form );
469 469
         $class = ' with_frm_style';
470 470
 
471
-        if ( empty($style) ) {
472
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
471
+        if ( empty( $style ) ) {
472
+            if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
473 473
                 return $class;
474 474
             } else {
475 475
                 return;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         }
478 478
 
479 479
         //If submit button needs to be inline or centered
480
-        if ( is_object($form) ) {
480
+        if ( is_object( $form ) ) {
481 481
 			$form = $form->options;
482 482
 		}
483 483
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 			$class .= ' frm_center_submit';
490 490
 		}
491 491
 
492
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
492
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
493 493
 
494 494
         return $class;
495 495
     }
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
     }
586 586
 
587 587
 	public static function edit_form_link( $form_id ) {
588
-        if ( is_object($form_id) ) {
588
+        if ( is_object( $form_id ) ) {
589 589
             $form = $form_id;
590 590
             $name = $form->name;
591 591
             $form_id = $form->id;
592 592
         } else {
593
-            $name = FrmForm::getName($form_id);
593
+            $name = FrmForm::getName( $form_id );
594 594
         }
595 595
 
596 596
         if ( $form_id ) {
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
623 623
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
624 624
         if ( 'trash' == $status ) {
625
-			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
626
-        } else if ( current_user_can('frm_delete_forms') ) {
625
+			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>';
626
+        } else if ( current_user_can( 'frm_delete_forms' ) ) {
627 627
             if ( EMPTY_TRASH_DAYS ) {
628
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
628
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>';
629 629
             } else {
630
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
630
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>';
631 631
             }
632 632
         }
633 633
 
@@ -641,11 +641,11 @@  discard block
 block discarded – undo
641 641
             'publish'   => __( 'Published', 'formidable' ),
642 642
         );
643 643
 
644
-        if ( ! in_array($status, array_keys($nice_names)) ) {
644
+        if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
645 645
             $status = 'publish';
646 646
         }
647 647
 
648
-		$name = $nice_names[ $status ];
648
+		$name = $nice_names[$status];
649 649
 
650 650
         return $name;
651 651
     }
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = self::fill_form( $item );
130
+			$form = self::fill_form( $item );
131 131
 
132 132
 			self::update_custom_style_setting_on_import( $form );
133 133
 
134
-	        $this_form = self::maybe_get_form( $form );
134
+			$this_form = self::maybe_get_form( $form );
135 135
 
136 136
 			$old_id = false;
137 137
 			$form_fields = false;
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 				$form_fields = self::get_form_fields( $form_id );
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146
-		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
148
-		            // Keep track of whether this specific form was updated or not
146
+				if ( $form_id ) {
147
+					$imported['imported']['forms']++;
148
+					// Keep track of whether this specific form was updated or not
149 149
 					$imported['form_status'][ $form_id ] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151
-		        }
151
+				}
152 152
 			}
153 153
 
154 154
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
155 155
 
156 156
 			self::delete_removed_fields( $form_fields );
157 157
 
158
-		    // Update field ids/keys to new ones
158
+			// Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161 161
 			$imported['forms'][ (int) $item->id ] = $form_id;
162 162
 
163
-            // Send pre 2.0 form options through function that creates actions
164
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
163
+			// Send pre 2.0 form options through function that creates actions
164
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+			unset($form, $item);
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
172 172
 
173 173
 		return $imported;
174
-    }
174
+	}
175 175
 
176 176
 	private static function fill_form( $item ) {
177 177
 		$form = array(
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Put child forms first so they will be imported before parents
243
-	*
244
-	* @since 2.0.16
245
-	* @param array $forms
246
-	*/
242
+	 * Put child forms first so they will be imported before parents
243
+	 *
244
+	 * @since 2.0.16
245
+	 * @param array $forms
246
+	 */
247 247
 	private static function put_child_forms_first( &$forms ) {
248 248
 		$child_forms = array();
249 249
 		$regular_forms = array();
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Keep track of all imported child forms
266
-	*
267
-	* @since 2.0.16
268
-	* @param int $form_id
269
-	* @param int $parent_form_id
270
-	* @param array $child_forms
271
-	*/
265
+	 * Keep track of all imported child forms
266
+	 *
267
+	 * @since 2.0.16
268
+	 * @param int $form_id
269
+	 * @param int $parent_form_id
270
+	 * @param array $child_forms
271
+	 */
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274 274
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	/**
279
-	* Update the parent_form_id on imported child forms
280
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
-	*
282
-	* @since 2.0.6
283
-	* @param array $imported_forms
284
-	* @param array $child_forms
285
-	*/
279
+	 * Update the parent_form_id on imported child forms
280
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
281
+	 *
282
+	 * @since 2.0.6
283
+	 * @param array $imported_forms
284
+	 * @param array $child_forms
285
+	 */
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 	}
297 297
 
298 298
 	/**
299
-	* Import all fields for a form
300
-	* @since 2.0.13
301
-	*
302
-	* TODO: Cut down on params
303
-	*/
299
+	 * Import all fields for a form
300
+	 * @since 2.0.13
301
+	 *
302
+	 * TODO: Cut down on params
303
+	 */
304 304
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
305 305
 		$in_section = 0;
306 306
 
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
311
-		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
313
-		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
310
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
311
+				'text', 'email', 'url', 'textarea',
312
+				'number','phone', 'date',
313
+				'hidden', 'password', 'tag', 'image',
314
+			)) ) {
315
+				if ( count($f['default_value']) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317
-		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
319
-		        }
320
-		    }
317
+				} else {
318
+					$f['default_value'] = reset($f['default_value']);
319
+				}
320
+			}
321 321
 
322 322
 			self::maybe_update_in_section_variable( $in_section, $f );
323 323
 			self::maybe_update_form_select( $f, $imported );
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 	}
397 397
 
398 398
 	/**
399
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
400
-	*
401
-	* @since 2.0.16
402
-	* @param array $f
403
-	* @param array $imported
404
-	*/
399
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
400
+	 *
401
+	 * @since 2.0.16
402
+	 * @param array $f
403
+	 * @param array $imported
404
+	 */
405 405
 	private static function maybe_update_form_select( &$f, $imported ) {
406 406
 		if ( ! isset( $imported['forms'] ) ) {
407 407
 			return;
@@ -453,13 +453,13 @@  discard block
 block discarded – undo
453 453
 	}
454 454
 
455 455
 	/**
456
-	* Updates the custom style setting on import
457
-	* Convert the post slug to an ID
458
-	*
459
-	* @since 2.0.19
460
-	* @param array $form
461
-	*
462
-	*/
456
+	 * Updates the custom style setting on import
457
+	 * Convert the post slug to an ID
458
+	 *
459
+	 * @since 2.0.19
460
+	 * @param array $form
461
+	 *
462
+	 */
463 463
 	private static function update_custom_style_setting_on_import( &$form ) {
464 464
 		if ( ! isset( $form['options']['custom_style'] ) ) {
465 465
 			return;
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 
515 515
 	public static function import_xml_views( $views, $imported ) {
516
-        $imported['posts'] = array();
517
-        $form_action_type = FrmFormActionsController::$action_post_type;
516
+		$imported['posts'] = array();
517
+		$form_action_type = FrmFormActionsController::$action_post_type;
518 518
 
519
-        $post_types = array(
520
-            'frm_display' => 'views',
521
-            $form_action_type => 'actions',
522
-            'frm_styles'    => 'styles',
523
-        );
519
+		$post_types = array(
520
+			'frm_display' => 'views',
521
+			$form_action_type => 'actions',
522
+			'frm_styles'    => 'styles',
523
+		);
524 524
 
525
-        foreach ( $views as $item ) {
525
+		foreach ( $views as $item ) {
526 526
 			$post = array(
527 527
 				'post_title'    => (string) $item->title,
528 528
 				'post_name'     => (string) $item->post_name,
@@ -541,52 +541,52 @@  discard block
 block discarded – undo
541 541
 				'post_date'     => (string) $item->post_date,
542 542
 				'post_date_gmt' => (string) $item->post_date_gmt,
543 543
 				'ping_status'   => (string) $item->ping_status,
544
-                'postmeta'      => array(),
545
-                'tax_input'     => array(),
544
+				'postmeta'      => array(),
545
+				'tax_input'     => array(),
546 546
 			);
547 547
 
548
-            $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
548
+			$old_id = $post['post_id'];
549
+			self::populate_post($post, $item, $imported);
550 550
 
551 551
 			unset($item);
552 552
 
553 553
 			$post_id = false;
554
-            if ( $post['post_type'] == $form_action_type ) {
555
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
554
+			if ( $post['post_type'] == $form_action_type ) {
555
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
560
-            } else if ( $post['post_type'] == 'frm_styles' ) {
561
-                // Properly encode post content before inserting the post
562
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
559
+				unset($action_control);
560
+			} else if ( $post['post_type'] == 'frm_styles' ) {
561
+				// Properly encode post content before inserting the post
562
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563 563
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
564
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
564
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
565 565
 
566
-                // Create/update post now
567
-                $post_id = wp_insert_post( $post );
566
+				// Create/update post now
567
+				$post_id = wp_insert_post( $post );
568 568
 				self::maybe_update_custom_css( $custom_css );
569
-            } else {
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
572
-            }
569
+			} else {
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572
+			}
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
575
-                continue;
576
-            }
574
+			if ( ! is_numeric($post_id) ) {
575
+				continue;
576
+			}
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+			self::update_postmeta($post, $post_id);
579 579
 
580
-            $this_type = 'posts';
580
+			$this_type = 'posts';
581 581
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582 582
 				$this_type = $post_types[ $post['post_type'] ];
583
-            }
583
+			}
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
587
-            } else {
588
-                $imported['imported'][ $this_type ]++;
589
-            }
585
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
+				$imported['updated'][ $this_type ]++;
587
+			} else {
588
+				$imported['imported'][ $this_type ]++;
589
+			}
590 590
 
591 591
 			$imported['posts'][ (int) $old_id ] = $post_id;
592 592
 
@@ -598,16 +598,16 @@  discard block
 block discarded – undo
598 598
 		self::maybe_update_stylesheet( $imported );
599 599
 
600 600
 		return $imported;
601
-    }
601
+	}
602 602
 
603
-    private static function populate_post( &$post, $item, $imported ) {
603
+	private static function populate_post( &$post, $item, $imported ) {
604 604
 		if ( isset($item->attachment_url) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608 608
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
609
-		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
609
+			// update to new form id
610
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,144 +616,144 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
619
+			self::populate_postmeta($post, $meta, $imported);
620 620
 			unset($meta);
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+		self::populate_taxonomies($post, $item);
624 624
 
625
-        self::maybe_editing_post($post);
626
-    }
625
+		self::maybe_editing_post($post);
626
+	}
627 627
 
628
-    private static function populate_postmeta( &$post, $meta, $imported ) {
629
-        global $frm_duplicate_ids;
628
+	private static function populate_postmeta( &$post, $meta, $imported ) {
629
+		global $frm_duplicate_ids;
630 630
 
631
-	    $m = array(
631
+		$m = array(
632 632
 			'key'   => (string) $meta->meta_key,
633 633
 			'value' => (string) $meta->meta_value,
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637 637
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
638
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+			if ( ! empty($frm_duplicate_ids) ) {
643 643
 
644
-		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
-    		    } else if ( $m['key'] == 'frm_options' ) {
644
+				if ( $m['key'] == 'frm_dyncontent' ) {
645
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
646
+				} else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649 649
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650 650
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
651
-    		            }
652
-    		        }
653
-
654
-                    $check_dup_array = array();
655
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
659
-                            $check_dup_array[] = 'order_by';
660
-    		            }
661
-    		        }
662
-
663
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
-    		            $check_dup_array[] = 'where';
665
-    		        }
666
-
667
-                    foreach ( $check_dup_array as $check_k ) {
651
+						}
652
+					}
653
+
654
+					$check_dup_array = array();
655
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
658
+						} else if ( is_array( $m['value']['order_by'] ) ) {
659
+							$check_dup_array[] = 'order_by';
660
+						}
661
+					}
662
+
663
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
664
+						$check_dup_array[] = 'where';
665
+					}
666
+
667
+					foreach ( $check_dup_array as $check_k ) {
668 668
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669 669
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670 670
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
671
-		                    }
672
-		                    unset($mk, $mv);
673
-		                }
674
-                    }
675
-    		    }
676
-		    }
671
+							}
672
+							unset($mk, $mv);
673
+						}
674
+					}
675
+				}
676
+			}
677 677
 		}
678 678
 
679 679
 		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
680
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
681 681
 		}
682 682
 
683 683
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
684
-    }
685
-
686
-    /**
687
-     * Add terms to post
688
-     * @param array $post by reference
689
-     * @param object $item The XML object data
690
-     */
691
-    private static function populate_taxonomies( &$post, $item ) {
684
+	}
685
+
686
+	/**
687
+	 * Add terms to post
688
+	 * @param array $post by reference
689
+	 * @param object $item The XML object data
690
+	 */
691
+	private static function populate_taxonomies( &$post, $item ) {
692 692
 		foreach ( $item->category as $c ) {
693 693
 			$att = $c->attributes();
694 694
 			if ( ! isset( $att['nicename'] ) ) {
695
-                continue;
696
-            }
697
-
698
-		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
700
-		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
702
-		        if ( $h_term ) {
703
-		            $name = $h_term->term_id;
704
-		        }
705
-		        unset($h_term);
706
-		    } else {
707
-		        $name = (string) $c;
708
-		    }
695
+				continue;
696
+			}
697
+
698
+			$taxonomy = (string) $att['domain'];
699
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
700
+				$name = (string) $att['nicename'];
701
+				$h_term = get_term_by('slug', $name, $taxonomy);
702
+				if ( $h_term ) {
703
+					$name = $h_term->term_id;
704
+				}
705
+				unset($h_term);
706
+			} else {
707
+				$name = (string) $c;
708
+			}
709 709
 
710 710
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711 711
 				$post['tax_input'][ $taxonomy ] = array();
712 712
 			}
713 713
 
714 714
 			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
715
+			unset($name);
716 716
 		}
717
-    }
717
+	}
718 718
 
719
-    /**
720
-     * Edit post if the key and created time match
721
-     */
722
-    private static function maybe_editing_post( &$post ) {
719
+	/**
720
+	 * Edit post if the key and created time match
721
+	 */
722
+	private static function maybe_editing_post( &$post ) {
723 723
 		$match_by = array(
724
-		    'post_type'     => $post['post_type'],
725
-		    'name'          => $post['post_name'],
726
-		    'post_status'   => $post['post_status'],
727
-		    'posts_per_page' => 1,
724
+			'post_type'     => $post['post_type'],
725
+			'name'          => $post['post_name'],
726
+			'post_status'   => $post['post_status'],
727
+			'posts_per_page' => 1,
728 728
 		);
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731
-		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
731
+			$match_by['include'] = $post['post_id'];
732
+			unset($match_by['name']);
733 733
 		}
734 734
 
735 735
 		$editing = get_posts($match_by);
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
-            // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
740
-        }
741
-    }
737
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
738
+			// set the id of the post to edit
739
+			$post['ID'] = current($editing)->ID;
740
+		}
741
+	}
742 742
 
743
-    private static function update_postmeta( &$post, $post_id ) {
744
-        foreach ( $post['postmeta'] as $k => $v ) {
745
-            if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
747
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
-                //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
750
-            }
743
+	private static function update_postmeta( &$post, $post_id ) {
744
+		foreach ( $post['postmeta'] as $k => $v ) {
745
+			if ( '_edit_last' == $k ) {
746
+				$v = FrmAppHelper::get_user_id_param($v);
747
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748
+				//change the attachment ID
749
+				$v = FrmProXMLHelper::get_file_id($v);
750
+			}
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+			update_post_meta($post_id, $k, $v);
753 753
 
754
-            unset($k, $v);
755
-        }
756
-    }
754
+			unset($k, $v);
755
+		}
756
+	}
757 757
 
758 758
 	/**
759 759
 	 * If a template includes custom css, let's include it.
@@ -786,72 +786,72 @@  discard block
 block discarded – undo
786 786
 		}
787 787
 	}
788 788
 
789
-    /**
790
-     * @param string $message
791
-     */
789
+	/**
790
+	 * @param string $message
791
+	 */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
794
-            $errors[] = $result->get_error_message();
795
-        } else if ( ! $result ) {
796
-            return;
797
-        }
798
-
799
-        if ( ! is_array($result) ) {
800
-            $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
801
-            return;
802
-        }
803
-
804
-        $t_strings = array(
805
-            'imported'  => __( 'Imported', 'formidable' ),
806
-            'updated'   => __( 'Updated', 'formidable' ),
807
-        );
808
-
809
-        $message = '<ul>';
810
-        foreach ( $result as $type => $results ) {
793
+		if ( is_wp_error($result) ) {
794
+			$errors[] = $result->get_error_message();
795
+		} else if ( ! $result ) {
796
+			return;
797
+		}
798
+
799
+		if ( ! is_array($result) ) {
800
+			$message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
801
+			return;
802
+		}
803
+
804
+		$t_strings = array(
805
+			'imported'  => __( 'Imported', 'formidable' ),
806
+			'updated'   => __( 'Updated', 'formidable' ),
807
+		);
808
+
809
+		$message = '<ul>';
810
+		foreach ( $result as $type => $results ) {
811 811
 			if ( ! isset( $t_strings[ $type ] ) ) {
812
-                // only print imported and updated
813
-                continue;
814
-            }
812
+				// only print imported and updated
813
+				continue;
814
+			}
815 815
 
816
-            $s_message = array();
817
-            foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
820
-            }
816
+			$s_message = array();
817
+			foreach ( $results as $k => $m ) {
818
+				self::item_count_message($m, $k, $s_message);
819
+				unset($k, $m);
820
+			}
821 821
 
822
-            if ( ! empty($s_message) ) {
822
+			if ( ! empty($s_message) ) {
823 823
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
825
-                $message .= '</li>';
826
-            }
827
-        }
828
-
829
-        if ( $message == '<ul>' ) {
830
-            $message = '';
831
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
-        } else {
833
-            $message .= '</ul>';
834
-        }
835
-    }
824
+				$message .= implode(', ', $s_message);
825
+				$message .= '</li>';
826
+			}
827
+		}
828
+
829
+		if ( $message == '<ul>' ) {
830
+			$message = '';
831
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
832
+		} else {
833
+			$message .= '</ul>';
834
+		}
835
+	}
836 836
 
837 837
 	public static function item_count_message( $m, $type, &$s_message ) {
838
-        if ( ! $m ) {
839
-            return;
840
-        }
841
-
842
-        $strings = array(
843
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
-        );
838
+		if ( ! $m ) {
839
+			return;
840
+		}
841
+
842
+		$strings = array(
843
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
844
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
845
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
846
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
847
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
848
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
849
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
850
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851
+		);
852 852
 
853 853
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
854
-    }
854
+	}
855 855
 
856 856
 	/**
857 857
 	 * Prepare the form options for export
@@ -882,16 +882,16 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+		$str = maybe_unserialize($str);
886
+		if ( is_array($str) ) {
887
+			$str = json_encode($str);
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
893
-            return $str;
894
-        }
892
+		if ( is_numeric($str) ) {
893
+			return $str;
894
+		}
895 895
 
896 896
 		self::remove_invalid_characters_from_xml( $str );
897 897
 
@@ -912,58 +912,58 @@  discard block
 block discarded – undo
912 912
 		$str = str_replace( '\x1F', '', $str );
913 913
 	}
914 914
 
915
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
-        // Get post type
917
-        $post_type = FrmFormActionsController::$action_post_type;
918
-
919
-        // Set up imported index, if not set up yet
920
-        if ( ! isset( $imported['imported']['actions'] ) ) {
921
-            $imported['imported']['actions'] = 0;
922
-        }
923
-
924
-        // Migrate post settings to action
925
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
-
927
-        // Migrate email settings to action
928
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
-    }
930
-
931
-    /**
932
-    * Migrate post settings to form action
933
-    *
934
-    * @param string $post_type
935
-    */
936
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
-            return;
939
-        }
940
-
941
-        $new_action = array(
942
-            'post_type'     => $post_type,
943
-            'post_excerpt'  => 'wppost',
915
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
916
+		// Get post type
917
+		$post_type = FrmFormActionsController::$action_post_type;
918
+
919
+		// Set up imported index, if not set up yet
920
+		if ( ! isset( $imported['imported']['actions'] ) ) {
921
+			$imported['imported']['actions'] = 0;
922
+		}
923
+
924
+		// Migrate post settings to action
925
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
926
+
927
+		// Migrate email settings to action
928
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
929
+	}
930
+
931
+	/**
932
+	 * Migrate post settings to form action
933
+	 *
934
+	 * @param string $post_type
935
+	 */
936
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
938
+			return;
939
+		}
940
+
941
+		$new_action = array(
942
+			'post_type'     => $post_type,
943
+			'post_excerpt'  => 'wppost',
944 944
 			'post_title'    => __( 'Create Posts', 'formidable' ),
945
-            'menu_order'    => $form_id,
946
-            'post_status'   => 'publish',
947
-            'post_content'  => array(),
945
+			'menu_order'    => $form_id,
946
+			'post_status'   => 'publish',
947
+			'post_content'  => array(),
948 948
 			'post_name'     => $form_id . '_wppost_1',
949
-        );
949
+		);
950 950
 
951
-        $post_settings = array(
952
-            'post_type', 'post_category', 'post_content',
953
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
951
+		$post_settings = array(
952
+			'post_type', 'post_category', 'post_content',
953
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
954 954
 			'post_status', 'post_custom_fields', 'post_password',
955
-        );
955
+		);
956 956
 
957
-        foreach ( $post_settings as $post_setting ) {
957
+		foreach ( $post_settings as $post_setting ) {
958 958
 			if ( isset( $form_options[ $post_setting ] ) ) {
959 959
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
960
-            }
961
-            unset($post_setting);
962
-        }
960
+			}
961
+			unset($post_setting);
962
+		}
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
965 965
 
966
-        if ( $switch ) {
966
+		if ( $switch ) {
967 967
 			// Fields with string or int saved
968 968
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
969 969
 
@@ -971,22 +971,22 @@  discard block
 block discarded – undo
971 971
 			$array_fields = array( 'post_category', 'post_custom_fields' );
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974
-        }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
974
+		}
975
+		$new_action['post_content'] = json_encode($new_action['post_content']);
976 976
 
977
-        $exists = get_posts( array(
978
-            'name'          => $new_action['post_name'],
979
-            'post_type'     => $new_action['post_type'],
980
-            'post_status'   => $new_action['post_status'],
981
-            'numberposts'   => 1,
982
-        ) );
977
+		$exists = get_posts( array(
978
+			'name'          => $new_action['post_name'],
979
+			'post_type'     => $new_action['post_type'],
980
+			'post_status'   => $new_action['post_status'],
981
+			'numberposts'   => 1,
982
+		) );
983 983
 
984
-        if ( ! $exists ) {
984
+		if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
988
-        }
989
-    }
987
+			$imported['imported']['actions']++;
988
+		}
989
+	}
990 990
 
991 991
 	/**
992 992
 	 * Switch old field IDs for new field IDs in emails and post
@@ -999,88 +999,88 @@  discard block
 block discarded – undo
999 999
 	 * @return string $post_content - new field IDs
1000 1000
 	 */
1001 1001
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1002
-        global $frm_duplicate_ids;
1002
+		global $frm_duplicate_ids;
1003 1003
 
1004
-        // If there aren't IDs that were switched, end now
1005
-        if ( ! $frm_duplicate_ids ) {
1006
-            return;
1007
-        }
1004
+		// If there aren't IDs that were switched, end now
1005
+		if ( ! $frm_duplicate_ids ) {
1006
+			return;
1007
+		}
1008 1008
 
1009
-        // Get old IDs
1010
-        $old = array_keys( $frm_duplicate_ids );
1009
+		// Get old IDs
1010
+		$old = array_keys( $frm_duplicate_ids );
1011 1011
 
1012
-        // Get new IDs
1013
-        $new = array_values( $frm_duplicate_ids );
1012
+		// Get new IDs
1013
+		$new = array_values( $frm_duplicate_ids );
1014 1014
 
1015
-        // Do a str_replace with each item to set the new IDs
1016
-        foreach ( $post_content as $key => $setting ) {
1017
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
-                // Replace old IDs with new IDs
1015
+		// Do a str_replace with each item to set the new IDs
1016
+		foreach ( $post_content as $key => $setting ) {
1017
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018
+				// Replace old IDs with new IDs
1019 1019
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
-                foreach ( $setting as $k => $val ) {
1022
-                    // Replace old IDs with new IDs
1020
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021
+				foreach ( $setting as $k => $val ) {
1022
+					// Replace old IDs with new IDs
1023 1023
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
-                }
1025
-            }
1026
-            unset( $key, $setting );
1027
-        }
1028
-        return $post_content;
1029
-    }
1030
-
1031
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
-        // No old notifications or autoresponders to carry over
1024
+				}
1025
+			}
1026
+			unset( $key, $setting );
1027
+		}
1028
+		return $post_content;
1029
+	}
1030
+
1031
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1032
+		// No old notifications or autoresponders to carry over
1033 1033
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1034
-            return;
1035
-        }
1034
+			return;
1035
+		}
1036 1036
 
1037
-        // Initialize notifications array
1038
-        $notifications = array();
1037
+		// Initialize notifications array
1038
+		$notifications = array();
1039 1039
 
1040
-        // Migrate regular notifications
1041
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1040
+		// Migrate regular notifications
1041
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1042 1042
 
1043
-        // Migrate autoresponders
1044
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1043
+		// Migrate autoresponders
1044
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1045 1045
 
1046
-        if ( empty( $notifications ) ) {
1047
-            return;
1048
-        }
1046
+		if ( empty( $notifications ) ) {
1047
+			return;
1048
+		}
1049 1049
 
1050
-        foreach ( $notifications as $new_notification ) {
1051
-            $new_notification['post_type']      = $post_type;
1052
-            $new_notification['post_excerpt']   = 'email';
1050
+		foreach ( $notifications as $new_notification ) {
1051
+			$new_notification['post_type']      = $post_type;
1052
+			$new_notification['post_excerpt']   = 'email';
1053 1053
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
-            $new_notification['menu_order']     = $form_id;
1055
-            $new_notification['post_status']    = 'publish';
1054
+			$new_notification['menu_order']     = $form_id;
1055
+			$new_notification['post_status']    = 'publish';
1056 1056
 
1057
-            // Switch field IDs and keys, if needed
1058
-            if ( $switch ) {
1057
+			// Switch field IDs and keys, if needed
1058
+			if ( $switch ) {
1059 1059
 
1060 1060
 				// Switch field IDs in email conditional logic
1061 1061
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1062 1062
 
1063 1063
 				// Switch all other field IDs in email
1064
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
-            }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
-
1068
-            $exists = get_posts( array(
1069
-                'name'          => $new_notification['post_name'],
1070
-                'post_type'     => $new_notification['post_type'],
1071
-                'post_status'   => $new_notification['post_status'],
1072
-                'numberposts'   => 1,
1073
-            ) );
1074
-
1075
-            if ( empty($exists) ) {
1064
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065
+			}
1066
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+
1068
+			$exists = get_posts( array(
1069
+				'name'          => $new_notification['post_name'],
1070
+				'post_type'     => $new_notification['post_type'],
1071
+				'post_status'   => $new_notification['post_status'],
1072
+				'numberposts'   => 1,
1073
+			) );
1074
+
1075
+			if ( empty($exists) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1078
-            }
1079
-            unset($new_notification);
1080
-        }
1077
+				$imported['imported']['actions']++;
1078
+			}
1079
+			unset($new_notification);
1080
+		}
1081 1081
 
1082 1082
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
1083
-    }
1083
+	}
1084 1084
 
1085 1085
 	/**
1086 1086
 	 * Remove deprecated notification settings after migration
@@ -1100,130 +1100,130 @@  discard block
 block discarded – undo
1100 1100
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
1101 1101
 	}
1102 1102
 
1103
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1104
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1105
-            // add old settings into notification array
1103
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1104
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1105
+			// add old settings into notification array
1106 1106
 			$form_options['notification'] = array( 0 => $form_options );
1107
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1108
-            // make sure it's in the correct format
1107
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1108
+			// make sure it's in the correct format
1109 1109
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1110
-        }
1110
+		}
1111 1111
 
1112
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1112
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1114 1114
 
1115
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1115
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1116 1116
 
1117
-                // Format the email data
1118
-                self::format_email_data( $atts, $notification );
1117
+				// Format the email data
1118
+				self::format_email_data( $atts, $notification );
1119 1119
 
1120 1120
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1121 1121
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1122 1122
 				}
1123 1123
 
1124
-                // Setup the new notification
1125
-                $new_notification = array();
1126
-                self::setup_new_notification( $new_notification, $notification, $atts );
1124
+				// Setup the new notification
1125
+				$new_notification = array();
1126
+				self::setup_new_notification( $new_notification, $notification, $atts );
1127 1127
 
1128
-                $notifications[] = $new_notification;
1129
-            }
1130
-        }
1131
-    }
1128
+				$notifications[] = $new_notification;
1129
+			}
1130
+		}
1131
+	}
1132 1132
 
1133
-    private static function format_email_data( &$atts, $notification ) {
1134
-        // Format email_to
1135
-        self::format_email_to_data( $atts, $notification );
1133
+	private static function format_email_data( &$atts, $notification ) {
1134
+		// Format email_to
1135
+		self::format_email_to_data( $atts, $notification );
1136 1136
 
1137
-        // Format the reply to email and name
1138
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139
-        foreach ( $reply_fields as $f => $val ) {
1137
+		// Format the reply to email and name
1138
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139
+		foreach ( $reply_fields as $f => $val ) {
1140 1140
 			if ( isset( $notification[ $f ] ) ) {
1141 1141
 				$atts[ $f ] = $notification[ $f ];
1142 1142
 				if ( 'custom' == $notification[ $f ] ) {
1143 1143
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1144 1144
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1145 1145
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1146
-                }
1147
-            }
1148
-            unset( $f, $val );
1149
-        }
1146
+				}
1147
+			}
1148
+			unset( $f, $val );
1149
+		}
1150 1150
 
1151
-        // Format event
1151
+		// Format event
1152 1152
 		$atts['event'] = array( 'create' );
1153
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154
-            $atts['event'][] = 'update';
1155
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1153
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154
+			$atts['event'][] = 'update';
1155
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1156 1156
 			$atts['event'] = array( 'update' );
1157
-        }
1158
-    }
1157
+		}
1158
+	}
1159 1159
 
1160
-    private static function format_email_to_data( &$atts, $notification ) {
1161
-        if ( isset( $notification['email_to'] ) ) {
1160
+	private static function format_email_to_data( &$atts, $notification ) {
1161
+		if ( isset( $notification['email_to'] ) ) {
1162 1162
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1163
-        } else {
1164
-            $atts['email_to'] = array();
1165
-        }
1163
+		} else {
1164
+			$atts['email_to'] = array();
1165
+		}
1166 1166
 
1167
-        if ( isset( $notification['also_email_to'] ) ) {
1168
-            $email_fields = (array) $notification['also_email_to'];
1169
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1170
-            unset( $email_fields );
1171
-        }
1167
+		if ( isset( $notification['also_email_to'] ) ) {
1168
+			$email_fields = (array) $notification['also_email_to'];
1169
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1170
+			unset( $email_fields );
1171
+		}
1172 1172
 
1173
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1173
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1174 1174
 
1175
-            if ( is_numeric( $email_field ) ) {
1175
+			if ( is_numeric( $email_field ) ) {
1176 1176
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1177
-            }
1177
+			}
1178 1178
 
1179
-            if ( strpos( $email_field, '|') ) {
1180
-                $email_opt = explode( '|', $email_field );
1181
-                if ( isset( $email_opt[0] ) ) {
1179
+			if ( strpos( $email_field, '|') ) {
1180
+				$email_opt = explode( '|', $email_field );
1181
+				if ( isset( $email_opt[0] ) ) {
1182 1182
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1183
-                }
1184
-                unset( $email_opt );
1185
-            }
1186
-        }
1187
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1188
-    }
1189
-
1190
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1191
-        // Set up new notification
1192
-        $new_notification = array(
1193
-            'post_content'  => array(
1194
-                'email_to'      => $atts['email_to'],
1195
-                'event'         => $atts['event'],
1196
-            ),
1183
+				}
1184
+				unset( $email_opt );
1185
+			}
1186
+		}
1187
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1188
+	}
1189
+
1190
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1191
+		// Set up new notification
1192
+		$new_notification = array(
1193
+			'post_content'  => array(
1194
+				'email_to'      => $atts['email_to'],
1195
+				'event'         => $atts['event'],
1196
+			),
1197 1197
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1198
-        );
1198
+		);
1199 1199
 
1200
-        // Add more fields to the new notification
1201
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202
-        foreach ( $add_fields as $add_field ) {
1200
+		// Add more fields to the new notification
1201
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202
+		foreach ( $add_fields as $add_field ) {
1203 1203
 			if ( isset( $notification[ $add_field ] ) ) {
1204 1204
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1205
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1205
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1206 1206
 				$new_notification['post_content'][ $add_field ] = 0;
1207
-            } else {
1207
+			} else {
1208 1208
 				$new_notification['post_content'][ $add_field ] = '';
1209
-            }
1210
-            unset( $add_field );
1211
-        }
1209
+			}
1210
+			unset( $add_field );
1211
+		}
1212 1212
 
1213 1213
 		// Set reply to
1214 1214
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1215 1215
 
1216
-        // Set from
1216
+		// Set from
1217 1217
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1218 1218
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1219
-        }
1220
-    }
1219
+		}
1220
+	}
1221 1221
 
1222 1222
 	/**
1223
-	* Switch field IDs in pre-2.0 email conditional logic
1224
-	*
1225
-	* @param $post_content array, pass by reference
1226
-	*/
1223
+	 * Switch field IDs in pre-2.0 email conditional logic
1224
+	 *
1225
+	 * @param $post_content array, pass by reference
1226
+	 */
1227 1227
 	private static function switch_email_contition_field_ids( &$post_content ) {
1228 1228
 		// Switch field IDs in conditional logic
1229 1229
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1236,36 +1236,36 @@  discard block
 block discarded – undo
1236 1236
 		}
1237 1237
 	}
1238 1238
 
1239
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1241
-            // migrate autoresponder
1242
-
1243
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
-            if ( strpos($email_field, '|') ) {
1245
-                // data from entries field
1246
-                $email_field = explode('|', $email_field);
1247
-                if ( isset($email_field[1]) ) {
1248
-                    $email_field = $email_field[1];
1249
-                }
1250
-            }
1251
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1239
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1241
+			// migrate autoresponder
1242
+
1243
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
+			if ( strpos($email_field, '|') ) {
1245
+				// data from entries field
1246
+				$email_field = explode('|', $email_field);
1247
+				if ( isset($email_field[1]) ) {
1248
+					$email_field = $email_field[1];
1249
+				}
1250
+			}
1251
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1252 1252
 				$email_field = '[' . $email_field . ']';
1253
-            }
1254
-
1255
-            $notification = $form_options;
1256
-            $new_notification2 = array(
1257
-                'post_content'  => array(
1258
-                    'email_message' => $notification['ar_email_message'],
1259
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1260
-                    'email_to'      => $email_field,
1261
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1262
-                    'inc_user_info' => 0,
1263
-                ),
1253
+			}
1254
+
1255
+			$notification = $form_options;
1256
+			$new_notification2 = array(
1257
+				'post_content'  => array(
1258
+					'email_message' => $notification['ar_email_message'],
1259
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1260
+					'email_to'      => $email_field,
1261
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1262
+					'inc_user_info' => 0,
1263
+				),
1264 1264
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1265
-            );
1265
+			);
1266 1266
 
1267
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1267
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1269 1269
 
1270 1270
 			if ( ! empty( $reply_to ) ) {
1271 1271
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1275,9 +1275,9 @@  discard block
 block discarded – undo
1275 1275
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1276 1276
 			}
1277 1277
 
1278
-            $notifications[] = $new_notification2;
1279
-            unset( $new_notification2 );
1280
-        }
1281
-    }
1278
+			$notifications[] = $new_notification2;
1279
+			unset( $new_notification2 );
1280
+		}
1281
+	}
1282 1282
 }
1283 1283
 
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 			} else {
145 145
 				$form_id = FrmForm::create( $form );
146 146
 		        if ( $form_id ) {
147
-		            $imported['imported']['forms']++;
147
+		            $imported['imported']['forms'] ++;
148 148
 		            // Keep track of whether this specific form was updated or not
149
-					$imported['form_status'][ $form_id ] = 'imported';
149
+					$imported['form_status'][$form_id] = 'imported';
150 150
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
151 151
 		        }
152 152
 			}
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 		    // Update field ids/keys to new ones
159 159
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
160 160
 
161
-			$imported['forms'][ (int) $item->id ] = $form_id;
161
+			$imported['forms'][(int) $item->id] = $form_id;
162 162
 
163 163
             // Send pre 2.0 form options through function that creates actions
164 164
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
165 165
 
166 166
 			do_action( 'frm_after_import_form', $form_id, $form );
167 167
 
168
-		    unset($form, $item);
168
+		    unset( $form, $item );
169 169
 		}
170 170
 
171 171
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 	private static function update_form( $this_form, $form, &$imported ) {
208 208
 		$form_id = $this_form->id;
209 209
 		FrmForm::update( $form_id, $form );
210
-		$imported['updated']['forms']++;
210
+		$imported['updated']['forms'] ++;
211 211
 		// Keep track of whether this specific form was updated or not
212
-		$imported['form_status'][ $form_id ] = 'updated';
212
+		$imported['form_status'][$form_id] = 'updated';
213 213
 	}
214 214
 
215 215
 	private static function get_form_fields( $form_id ) {
216 216
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
217 217
 		$old_fields = array();
218 218
 		foreach ( $form_fields as $f ) {
219
-			$old_fields[ $f->id ] = $f;
220
-			$old_fields[ $f->field_key ] = $f->id;
221
-			unset($f);
219
+			$old_fields[$f->id] = $f;
220
+			$old_fields[$f->field_key] = $f->id;
221
+			unset( $f );
222 222
 		}
223 223
 		$form_fields = $old_fields;
224 224
 		return $form_fields;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		$regular_forms = array();
250 250
 
251 251
 		foreach ( $forms as $form ) {
252
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
252
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
253 253
 
254 254
 			if ( $parent_form_id ) {
255 255
 				$child_forms[] = $form;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	*/
272 272
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
273 273
 		if ( $parent_form_id ) {
274
-			$child_forms[ $form_id ] = $parent_form_id;
274
+			$child_forms[$form_id] = $parent_form_id;
275 275
 		}
276 276
 	}
277 277
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
287 287
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
288 288
 
289
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
289
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
290 290
 				// Update all children with this old parent_form_id
291
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
291
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
292 292
 
293 293
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
294 294
 			}
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
 		foreach ( $xml_fields as $field ) {
308 308
 			$f = self::fill_field( $field, $form_id );
309 309
 
310
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
310
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
311 311
 		        'text', 'email', 'url', 'textarea',
312
-		        'number','phone', 'date',
312
+		        'number', 'phone', 'date',
313 313
 		        'hidden', 'password', 'tag', 'image',
314
-		    )) ) {
315
-		        if ( count($f['default_value']) === 1 ) {
314
+		    ) ) ) {
315
+		        if ( count( $f['default_value'] ) === 1 ) {
316 316
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
317 317
 		        } else {
318
-		            $f['default_value'] = reset($f['default_value']);
318
+		            $f['default_value'] = reset( $f['default_value'] );
319 319
 		        }
320 320
 		    }
321 321
 
@@ -323,27 +323,27 @@  discard block
 block discarded – undo
323 323
 			self::maybe_update_form_select( $f, $imported );
324 324
 			self::maybe_update_get_values_form_setting( $imported, $f );
325 325
 
326
-			if ( ! empty($this_form) ) {
326
+			if ( ! empty( $this_form ) ) {
327 327
 				// check for field to edit by field id
328
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
328
+				if ( isset( $form_fields[$f['id']] ) ) {
329 329
 					FrmField::update( $f['id'], $f );
330
-					$imported['updated']['fields']++;
330
+					$imported['updated']['fields'] ++;
331 331
 
332
-					unset( $form_fields[ $f['id'] ] );
332
+					unset( $form_fields[$f['id']] );
333 333
 
334 334
 					//unset old field key
335
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
336
-						unset( $form_fields[ $f['field_key'] ] );
335
+					if ( isset( $form_fields[$f['field_key']] ) ) {
336
+						unset( $form_fields[$f['field_key']] );
337 337
 					}
338
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
338
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
339 339
 					// check for field to edit by field key
340
-					unset($f['id']);
340
+					unset( $f['id'] );
341 341
 
342
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
343
-					$imported['updated']['fields']++;
342
+					FrmField::update( $form_fields[$f['field_key']], $f );
343
+					$imported['updated']['fields'] ++;
344 344
 
345
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
346
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
345
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
346
+					unset( $form_fields[$f['field_key']] ); //unset old field key
347 347
 				} else {
348 348
 					// if no matching field id or key in this form, create the field
349 349
 					self::create_imported_field( $f, $imported );
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 			'name'          => (string) $field->name,
363 363
 			'description'   => (string) $field->description,
364 364
 			'type'          => (string) $field->type,
365
-			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
365
+			'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
366 366
 			'field_order'   => (int) $field->field_order,
367 367
 			'form_id'       => (int) $form_id,
368 368
 			'required'      => (int) $field->required,
369
-			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
369
+			'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
370 370
 			'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
371 371
 		);
372 372
 	}
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
411 411
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
412 412
 				$form_select = (int) $f['field_options']['form_select'];
413
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
414
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
413
+				if ( isset( $imported['forms'][$form_select] ) ) {
414
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
415 415
 				}
416 416
 			}
417 417
 		}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 
432 432
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
433 433
 			$old_form = $f['field_options']['get_values_form'];
434
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
435
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
434
+			if ( isset( $imported['forms'][$old_form] ) ) {
435
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
436 436
 			}
437 437
 		}
438 438
 	}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	private static function create_imported_field( $f, &$imported ) {
448 448
 		$new_id = FrmField::create( $f );
449 449
 		if ( $new_id != false ) {
450
-			$imported['imported']['fields']++;
450
+			$imported['imported']['fields'] ++;
451 451
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
452 452
 		}
453 453
 	}
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			);
547 547
 
548 548
             $old_id = $post['post_id'];
549
-            self::populate_post($post, $item, $imported);
549
+            self::populate_post( $post, $item, $imported );
550 550
 
551
-			unset($item);
551
+			unset( $item );
552 552
 
553 553
 			$post_id = false;
554 554
             if ( $post['post_type'] == $form_action_type ) {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				if ( $action_control && is_object( $action_control ) ) {
557 557
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
558 558
 				}
559
-                unset($action_control);
559
+                unset( $action_control );
560 560
             } else if ( $post['post_type'] == 'frm_styles' ) {
561 561
                 // Properly encode post content before inserting the post
562 562
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
                 $post_id = wp_insert_post( $post );
572 572
             }
573 573
 
574
-            if ( ! is_numeric($post_id) ) {
574
+            if ( ! is_numeric( $post_id ) ) {
575 575
                 continue;
576 576
             }
577 577
 
578
-            self::update_postmeta($post, $post_id);
578
+            self::update_postmeta( $post, $post_id );
579 579
 
580 580
             $this_type = 'posts';
581
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
582
-				$this_type = $post_types[ $post['post_type'] ];
581
+			if ( isset( $post_types[$post['post_type']] ) ) {
582
+				$this_type = $post_types[$post['post_type']];
583 583
             }
584 584
 
585
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
586
-                $imported['updated'][ $this_type ]++;
585
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
586
+                $imported['updated'][$this_type] ++;
587 587
             } else {
588
-                $imported['imported'][ $this_type ]++;
588
+                $imported['imported'][$this_type] ++;
589 589
             }
590 590
 
591
-			$imported['posts'][ (int) $old_id ] = $post_id;
591
+			$imported['posts'][(int) $old_id] = $post_id;
592 592
 
593 593
 			do_action( 'frm_after_import_view', $post_id, $post );
594 594
 
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
     }
602 602
 
603 603
     private static function populate_post( &$post, $item, $imported ) {
604
-		if ( isset($item->attachment_url) ) {
604
+		if ( isset( $item->attachment_url ) ) {
605 605
 			$post['attachment_url'] = (string) $item->attachment_url;
606 606
 		}
607 607
 
608
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
608
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
609 609
 		    // update to new form id
610
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
610
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
611 611
 		}
612 612
 
613 613
 		// Don't allow default styles to take over a site's default style
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		foreach ( $item->postmeta as $meta ) {
619
-		    self::populate_postmeta($post, $meta, $imported);
620
-			unset($meta);
619
+		    self::populate_postmeta( $post, $meta, $imported );
620
+			unset( $meta );
621 621
 		}
622 622
 
623
-        self::populate_taxonomies($post, $item);
623
+        self::populate_taxonomies( $post, $item );
624 624
 
625
-        self::maybe_editing_post($post);
625
+        self::maybe_editing_post( $post );
626 626
     }
627 627
 
628 628
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -634,27 +634,27 @@  discard block
 block discarded – undo
634 634
 		);
635 635
 
636 636
 		//switch old form and field ids to new ones
637
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
638
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
637
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
638
+		    $m['value'] = $imported['forms'][(int) $m['value']];
639 639
 		} else {
640
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
640
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
641 641
 
642
-		    if ( ! empty($frm_duplicate_ids) ) {
642
+		    if ( ! empty( $frm_duplicate_ids ) ) {
643 643
 
644 644
 		        if ( $m['key'] == 'frm_dyncontent' ) {
645
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
645
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
646 646
     		    } else if ( $m['key'] == 'frm_options' ) {
647 647
 
648 648
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
649
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
650
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
649
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
650
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
651 651
     		            }
652 652
     		        }
653 653
 
654 654
                     $check_dup_array = array();
655 655
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
656
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
657
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
656
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
657
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
658 658
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
659 659
                             $check_dup_array[] = 'order_by';
660 660
     		            }
@@ -665,22 +665,22 @@  discard block
 block discarded – undo
665 665
     		        }
666 666
 
667 667
                     foreach ( $check_dup_array as $check_k ) {
668
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
669
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
670
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
668
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
669
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
670
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
671 671
 		                    }
672
-		                    unset($mk, $mv);
672
+		                    unset( $mk, $mv );
673 673
 		                }
674 674
                     }
675 675
     		    }
676 676
 		    }
677 677
 		}
678 678
 
679
-		if ( ! is_array($m['value']) ) {
680
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
679
+		if ( ! is_array( $m['value'] ) ) {
680
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
681 681
 		}
682 682
 
683
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
683
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
684 684
     }
685 685
 
686 686
     /**
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
             }
697 697
 
698 698
 		    $taxonomy = (string) $att['domain'];
699
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
699
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
700 700
 		        $name = (string) $att['nicename'];
701
-		        $h_term = get_term_by('slug', $name, $taxonomy);
701
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
702 702
 		        if ( $h_term ) {
703 703
 		            $name = $h_term->term_id;
704 704
 		        }
705
-		        unset($h_term);
705
+		        unset( $h_term );
706 706
 		    } else {
707 707
 		        $name = (string) $c;
708 708
 		    }
709 709
 
710
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
711
-				$post['tax_input'][ $taxonomy ] = array();
710
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
711
+				$post['tax_input'][$taxonomy] = array();
712 712
 			}
713 713
 
714
-			$post['tax_input'][ $taxonomy ][] = $name;
715
-		    unset($name);
714
+			$post['tax_input'][$taxonomy][] = $name;
715
+		    unset( $name );
716 716
 		}
717 717
     }
718 718
 
@@ -729,29 +729,29 @@  discard block
 block discarded – undo
729 729
 
730 730
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
731 731
 		    $match_by['include'] = $post['post_id'];
732
-		    unset($match_by['name']);
732
+		    unset( $match_by['name'] );
733 733
 		}
734 734
 
735
-		$editing = get_posts($match_by);
735
+		$editing = get_posts( $match_by );
736 736
 
737
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
737
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
738 738
             // set the id of the post to edit
739
-            $post['ID'] = current($editing)->ID;
739
+            $post['ID'] = current( $editing )->ID;
740 740
         }
741 741
     }
742 742
 
743 743
     private static function update_postmeta( &$post, $post_id ) {
744 744
         foreach ( $post['postmeta'] as $k => $v ) {
745 745
             if ( '_edit_last' == $k ) {
746
-                $v = FrmAppHelper::get_user_id_param($v);
746
+                $v = FrmAppHelper::get_user_id_param( $v );
747 747
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
748 748
                 //change the attachment ID
749
-                $v = FrmProXMLHelper::get_file_id($v);
749
+                $v = FrmProXMLHelper::get_file_id( $v );
750 750
             }
751 751
 
752
-            update_post_meta($post_id, $k, $v);
752
+            update_post_meta( $post_id, $k, $v );
753 753
 
754
-            unset($k, $v);
754
+            unset( $k, $v );
755 755
         }
756 756
     }
757 757
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
      * @param string $message
791 791
      */
792 792
 	public static function parse_message( $result, &$message, &$errors ) {
793
-        if ( is_wp_error($result) ) {
793
+        if ( is_wp_error( $result ) ) {
794 794
             $errors[] = $result->get_error_message();
795 795
         } else if ( ! $result ) {
796 796
             return;
797 797
         }
798 798
 
799
-        if ( ! is_array($result) ) {
799
+        if ( ! is_array( $result ) ) {
800 800
             $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
801 801
             return;
802 802
         }
@@ -808,20 +808,20 @@  discard block
 block discarded – undo
808 808
 
809 809
         $message = '<ul>';
810 810
         foreach ( $result as $type => $results ) {
811
-			if ( ! isset( $t_strings[ $type ] ) ) {
811
+			if ( ! isset( $t_strings[$type] ) ) {
812 812
                 // only print imported and updated
813 813
                 continue;
814 814
             }
815 815
 
816 816
             $s_message = array();
817 817
             foreach ( $results as $k => $m ) {
818
-                self::item_count_message($m, $k, $s_message);
819
-                unset($k, $m);
818
+                self::item_count_message( $m, $k, $s_message );
819
+                unset( $k, $m );
820 820
             }
821 821
 
822
-            if ( ! empty($s_message) ) {
823
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
824
-                $message .= implode(', ', $s_message);
822
+            if ( ! empty( $s_message ) ) {
823
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
824
+                $message .= implode( ', ', $s_message );
825 825
                 $message .= '</li>';
826 826
             }
827 827
         }
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
851 851
         );
852 852
 
853
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
853
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
854 854
     }
855 855
 
856 856
 	/**
@@ -882,14 +882,14 @@  discard block
 block discarded – undo
882 882
 	}
883 883
 
884 884
 	public static function cdata( $str ) {
885
-	    $str = maybe_unserialize($str);
886
-	    if ( is_array($str) ) {
887
-	        $str = json_encode($str);
885
+	    $str = maybe_unserialize( $str );
886
+	    if ( is_array( $str ) ) {
887
+	        $str = json_encode( $str );
888 888
 		} else if ( seems_utf8( $str ) == false ) {
889 889
 			$str = utf8_encode( $str );
890 890
 		}
891 891
 
892
-        if ( is_numeric($str) ) {
892
+        if ( is_numeric( $str ) ) {
893 893
             return $str;
894 894
         }
895 895
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     * @param string $post_type
935 935
     */
936 936
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
937
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
937
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
938 938
             return;
939 939
         }
940 940
 
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
         );
956 956
 
957 957
         foreach ( $post_settings as $post_setting ) {
958
-			if ( isset( $form_options[ $post_setting ] ) ) {
959
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
958
+			if ( isset( $form_options[$post_setting] ) ) {
959
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
960 960
             }
961
-            unset($post_setting);
961
+            unset( $post_setting );
962 962
         }
963 963
 
964 964
 		$new_action['event'] = array( 'create', 'update' );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 
973 973
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
974 974
         }
975
-        $new_action['post_content'] = json_encode($new_action['post_content']);
975
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
976 976
 
977 977
         $exists = get_posts( array(
978 978
             'name'          => $new_action['post_name'],
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         if ( ! $exists ) {
985 985
 			// this isn't an email, but we need to use a class that will always be included
986 986
 			FrmAppHelper::save_json_post( $new_action );
987
-            $imported['imported']['actions']++;
987
+            $imported['imported']['actions'] ++;
988 988
         }
989 989
     }
990 990
 
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
         foreach ( $post_content as $key => $setting ) {
1017 1017
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1018 1018
                 // Replace old IDs with new IDs
1019
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1019
+				$post_content[$key] = str_replace( $old, $new, $setting );
1020 1020
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1021 1021
                 foreach ( $setting as $k => $val ) {
1022 1022
                     // Replace old IDs with new IDs
1023
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1023
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1024 1024
                 }
1025 1025
             }
1026 1026
             unset( $key, $setting );
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
         foreach ( $notifications as $new_notification ) {
1051 1051
             $new_notification['post_type']      = $post_type;
1052 1052
             $new_notification['post_excerpt']   = 'email';
1053
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1053
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1054 1054
             $new_notification['menu_order']     = $form_id;
1055 1055
             $new_notification['post_status']    = 'publish';
1056 1056
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 				// Switch all other field IDs in email
1064 1064
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1065 1065
             }
1066
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1066
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067 1067
 
1068 1068
             $exists = get_posts( array(
1069 1069
                 'name'          => $new_notification['post_name'],
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
                 'numberposts'   => 1,
1073 1073
             ) );
1074 1074
 
1075
-            if ( empty($exists) ) {
1075
+            if ( empty( $exists ) ) {
1076 1076
 				FrmAppHelper::save_json_post( $new_notification );
1077
-                $imported['imported']['actions']++;
1077
+                $imported['imported']['actions'] ++;
1078 1078
             }
1079
-            unset($new_notification);
1079
+            unset( $new_notification );
1080 1080
         }
1081 1081
 
1082 1082
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1094 1094
 		$delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1095 1095
 		foreach ( $delete_settings as $index ) {
1096
-			if ( isset( $form_options[ $index ] ) ) {
1097
-				unset( $form_options[ $index ] );
1096
+			if ( isset( $form_options[$index] ) ) {
1097
+				unset( $form_options[$index] );
1098 1098
 			}
1099 1099
 		}
1100 1100
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1110 1110
         }
1111 1111
 
1112
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1112
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1113 1113
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1114 1114
 
1115 1115
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1137,12 +1137,12 @@  discard block
 block discarded – undo
1137 1137
         // Format the reply to email and name
1138 1138
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1139 1139
         foreach ( $reply_fields as $f => $val ) {
1140
-			if ( isset( $notification[ $f ] ) ) {
1141
-				$atts[ $f ] = $notification[ $f ];
1142
-				if ( 'custom' == $notification[ $f ] ) {
1143
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1144
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1145
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1140
+			if ( isset( $notification[$f] ) ) {
1141
+				$atts[$f] = $notification[$f];
1142
+				if ( 'custom' == $notification[$f] ) {
1143
+					$atts[$f] = $notification['cust_' . $f];
1144
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1145
+					$atts[$f] = '[' . $atts[$f] . ']';
1146 1146
                 }
1147 1147
             }
1148 1148
             unset( $f, $val );
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 		$atts['event'] = array( 'create' );
1153 1153
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1154 1154
             $atts['event'][] = 'update';
1155
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1155
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1156 1156
 			$atts['event'] = array( 'update' );
1157 1157
         }
1158 1158
     }
@@ -1173,18 +1173,18 @@  discard block
 block discarded – undo
1173 1173
         foreach ( $atts['email_to'] as $key => $email_field ) {
1174 1174
 
1175 1175
             if ( is_numeric( $email_field ) ) {
1176
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1176
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1177 1177
             }
1178 1178
 
1179
-            if ( strpos( $email_field, '|') ) {
1179
+            if ( strpos( $email_field, '|' ) ) {
1180 1180
                 $email_opt = explode( '|', $email_field );
1181 1181
                 if ( isset( $email_opt[0] ) ) {
1182
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1182
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1183 1183
                 }
1184 1184
                 unset( $email_opt );
1185 1185
             }
1186 1186
         }
1187
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1187
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1188 1188
     }
1189 1189
 
1190 1190
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1200,12 +1200,12 @@  discard block
 block discarded – undo
1200 1200
         // Add more fields to the new notification
1201 1201
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1202 1202
         foreach ( $add_fields as $add_field ) {
1203
-			if ( isset( $notification[ $add_field ] ) ) {
1204
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1203
+			if ( isset( $notification[$add_field] ) ) {
1204
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1205 1205
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1206
-				$new_notification['post_content'][ $add_field ] = 0;
1206
+				$new_notification['post_content'][$add_field] = 0;
1207 1207
             } else {
1208
-				$new_notification['post_content'][ $add_field ] = '';
1208
+				$new_notification['post_content'][$add_field] = '';
1209 1209
             }
1210 1210
             unset( $add_field );
1211 1211
         }
@@ -1229,26 +1229,26 @@  discard block
 block discarded – undo
1229 1229
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1230 1230
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1231 1231
 				if ( is_numeric( $email_key ) ) {
1232
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1232
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1233 1233
 				}
1234
-				unset( $email_key, $val);
1234
+				unset( $email_key, $val );
1235 1235
 			}
1236 1236
 		}
1237 1237
 	}
1238 1238
 
1239 1239
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1240
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1240
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1241 1241
             // migrate autoresponder
1242 1242
 
1243
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1244
-            if ( strpos($email_field, '|') ) {
1243
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1244
+            if ( strpos( $email_field, '|' ) ) {
1245 1245
                 // data from entries field
1246
-                $email_field = explode('|', $email_field);
1247
-                if ( isset($email_field[1]) ) {
1246
+                $email_field = explode( '|', $email_field );
1247
+                if ( isset( $email_field[1] ) ) {
1248 1248
                     $email_field = $email_field[1];
1249 1249
                 }
1250 1250
             }
1251
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1251
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1252 1252
 				$email_field = '[' . $email_field . ']';
1253 1253
             }
1254 1254
 
@@ -1256,16 +1256,16 @@  discard block
 block discarded – undo
1256 1256
             $new_notification2 = array(
1257 1257
                 'post_content'  => array(
1258 1258
                     'email_message' => $notification['ar_email_message'],
1259
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1259
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1260 1260
                     'email_to'      => $email_field,
1261
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1261
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1262 1262
                     'inc_user_info' => 0,
1263 1263
                 ),
1264 1264
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1265 1265
             );
1266 1266
 
1267
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1268
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1267
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1268
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1269 1269
 
1270 1270
 			if ( ! empty( $reply_to ) ) {
1271 1271
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +683 added lines, -683 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54 54
 			$values['field_options']['label'] = 'none';
55
-        } else if ( 'url' == $type ) {
56
-            $values['name'] = __( 'Website', 'formidable' );
57
-        }
55
+		} else if ( 'url' == $type ) {
56
+			$values['name'] = __( 'Website', 'formidable' );
57
+		}
58 58
 
59 59
 		$fields = FrmField::field_selection();
60
-        $fields = array_merge($fields, FrmField::pro_field_selection());
60
+		$fields = array_merge($fields, FrmField::pro_field_selection());
61 61
 
62
-        if ( isset( $fields[ $type ] ) ) {
63
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
64
-        }
62
+		if ( isset( $fields[ $type ] ) ) {
63
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
64
+		}
65 65
 
66
-        unset($fields);
66
+		unset($fields);
67 67
 
68
-        return $values;
69
-    }
68
+		return $values;
69
+	}
70 70
 
71 71
 	public static function get_html_id( $field, $plus = '' ) {
72 72
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
73
-    }
73
+	}
74 74
 
75
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
75
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
76 76
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
77 77
 		$defaults = array(
78 78
 			'name'          => $record->name,
@@ -85,86 +85,86 @@  discard block
 block discarded – undo
85 85
 		);
86 86
 
87 87
 		if ( $doing_ajax ) {
88
-            $values = $values + $defaults;
89
-            $values['form_name'] = '';
88
+			$values = $values + $defaults;
89
+			$values['form_name'] = '';
90 90
 		} else {
91 91
 			foreach ( $defaults as $var => $default ) {
92
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
-                unset($var, $default);
94
-            }
92
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
+				unset($var, $default);
94
+			}
95 95
 
96 96
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
97
-        }
97
+		}
98 98
 
99 99
 		unset( $defaults );
100 100
 
101
-        $values['options'] = $record->options;
102
-        $values['field_options'] = $record->field_options;
101
+		$values['options'] = $record->options;
102
+		$values['field_options'] = $record->field_options;
103 103
 
104
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
104
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
105 105
 
106 106
 		if ( $values['type'] == 'captcha' ) {
107
-            $frm_settings = FrmAppHelper::get_settings();
108
-            $defaults['invalid'] = $frm_settings->re_msg;
109
-        }
107
+			$frm_settings = FrmAppHelper::get_settings();
108
+			$defaults['invalid'] = $frm_settings->re_msg;
109
+		}
110 110
 
111 111
 		foreach ( $defaults as $opt => $default ) {
112
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
-            unset($opt, $default);
114
-        }
112
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
+			unset($opt, $default);
114
+		}
115 115
 
116
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
117 117
 
118 118
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
119
-    }
119
+	}
120 120
 
121
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
122
-        $field_options = array(
123
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
124
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
125
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
121
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
122
+		$field_options = array(
123
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
124
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
125
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
126 126
 			'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light',
127
-        );
127
+		);
128 128
 
129 129
 		if ( $limit ) {
130
-            return $field_options;
130
+			return $field_options;
131 131
 		}
132 132
 
133
-        global $wpdb;
133
+		global $wpdb;
134 134
 
135
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
135
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
136 136
 
137 137
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
138 138
 
139
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
140 140
 
141
-        $frm_settings = FrmAppHelper::get_settings();
142
-        return array(
143
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
141
+		$frm_settings = FrmAppHelper::get_settings();
142
+		return array(
143
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
144 144
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
145 145
 			'field_order' => $field_count + 1, 'required' => false,
146
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
147
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
146
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
147
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
148 148
 			'field_options' => $field_options,
149
-        );
150
-    }
149
+		);
150
+	}
151 151
 
152
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
153
-        global $wpdb;
152
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
153
+		global $wpdb;
154 154
 
155 155
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
156
-        $values['form_id'] = $form_id;
157
-        $values['options'] = maybe_serialize($field->options);
158
-        $values['default_value'] = maybe_serialize($field->default_value);
159
-
160
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
-            $values[ $col ] = $field->{$col};
162
-        }
163
-    }
164
-
165
-    /**
166
-     * @since 2.0
167
-     */
156
+		$values['form_id'] = $form_id;
157
+		$values['options'] = maybe_serialize($field->options);
158
+		$values['default_value'] = maybe_serialize($field->default_value);
159
+
160
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
+			$values[ $col ] = $field->{$col};
162
+		}
163
+	}
164
+
165
+	/**
166
+	 * @since 2.0
167
+	 */
168 168
 	public static function get_error_msg( $field, $error ) {
169 169
 		$frm_settings = FrmAppHelper::get_settings();
170 170
 		$default_settings = $frm_settings->default_options();
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	public static function get_default_html( $type = 'text' ) {
194 194
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
195 195
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
196
-            $for = '';
196
+			$for = '';
197 197
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
198
-                $for = 'for="field_[key]"';
199
-            }
198
+				$for = 'for="field_[key]"';
199
+			}
200 200
 
201
-            $default_html = <<<DEFAULT_HTML
201
+			$default_html = <<<DEFAULT_HTML
202 202
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
203 203
     <label $for class="frm_primary_label">[field_name]
204 204
         <span class="frm_required">[required_label]</span>
@@ -208,81 +208,81 @@  discard block
 block discarded – undo
208 208
     [if error]<div class="frm_error">[error]</div>[/if error]
209 209
 </div>
210 210
 DEFAULT_HTML;
211
-        } else {
211
+		} else {
212 212
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
213
-        }
213
+		}
214 214
 
215
-        return apply_filters('frm_custom_html', $default_html, $type);
216
-    }
215
+		return apply_filters('frm_custom_html', $default_html, $type);
216
+	}
217 217
 
218 218
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
219
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
220 220
 
221
-        $defaults = array(
221
+		$defaults = array(
222 222
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
223 223
 			'field_id'      => $field['id'],
224
-            'field_plus_id' => '',
225
-            'section_id'    => '',
226
-        );
227
-        $args = wp_parse_args($args, $defaults);
228
-        $field_name = $args['field_name'];
229
-        $field_id = $args['field_id'];
230
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
224
+			'field_plus_id' => '',
225
+			'section_id'    => '',
226
+		);
227
+		$args = wp_parse_args($args, $defaults);
228
+		$field_name = $args['field_name'];
229
+		$field_id = $args['field_id'];
230
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
231 231
 
232
-        if ( FrmField::is_multiple_select($field) ) {
233
-            $field_name .= '[]';
234
-        }
232
+		if ( FrmField::is_multiple_select($field) ) {
233
+			$field_name .= '[]';
234
+		}
235 235
 
236
-        //replace [id]
237
-        $html = str_replace('[id]', $field_id, $html);
236
+		//replace [id]
237
+		$html = str_replace('[id]', $field_id, $html);
238 238
 
239
-        // Remove the for attribute for captcha
240
-        if ( $field['type'] == 'captcha' ) {
241
-            $html = str_replace(' for="field_[key]"', '', $html);
242
-        }
239
+		// Remove the for attribute for captcha
240
+		if ( $field['type'] == 'captcha' ) {
241
+			$html = str_replace(' for="field_[key]"', '', $html);
242
+		}
243 243
 
244
-        // set the label for
245
-        $html = str_replace('field_[key]', $html_id, $html);
244
+		// set the label for
245
+		$html = str_replace('field_[key]', $html_id, $html);
246 246
 
247
-        //replace [key]
248
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+		//replace [key]
248
+		$html = str_replace('[key]', $field['field_key'], $html);
249 249
 
250
-        //replace [description] and [required_label] and [error]
250
+		//replace [description] and [required_label] and [error]
251 251
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
252
-        if ( ! is_array( $errors ) ) {
253
-            $errors = array();
254
-        }
252
+		if ( ! is_array( $errors ) ) {
253
+			$errors = array();
254
+		}
255 255
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
256 256
 
257
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258
-        if ( $field['type'] == 'divider' ) {
259
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
260
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261
-            } else {
262
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
263
-            }
264
-        }
257
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258
+		if ( $field['type'] == 'divider' ) {
259
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
260
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261
+			} else {
262
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
263
+			}
264
+		}
265 265
 
266 266
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
267
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
268
-        }
267
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
268
+		}
269 269
 
270
-        //replace [required_class]
270
+		//replace [required_class]
271 271
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
272
-        $html = str_replace('[required_class]', $required_class, $html);
272
+		$html = str_replace('[required_class]', $required_class, $html);
273 273
 
274
-        //replace [label_position]
274
+		//replace [label_position]
275 275
 		$field['label'] = self::label_position( $field['label'], $field, $form );
276 276
 		self::add_class_to_label( $field, $html );
277 277
 
278
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287 287
 		if ( $form ) {
288 288
 			$form = (array) $form;
@@ -296,57 +296,57 @@  discard block
 block discarded – undo
296 296
 
297 297
 		self::process_wp_shortcodes( $html );
298 298
 
299
-        //replace [input]
300
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
301
-        global $frm_vars;
302
-        $frm_settings = FrmAppHelper::get_settings();
299
+		//replace [input]
300
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
301
+		global $frm_vars;
302
+		$frm_settings = FrmAppHelper::get_settings();
303 303
 
304
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
305
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
304
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
305
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
306 306
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
307 307
 
308
-            $replace_with = '';
308
+			$replace_with = '';
309 309
 
310
-            if ( $tag == 'input' ) {
311
-                if ( isset($atts['opt']) ) {
312
-                    $atts['opt']--;
313
-                }
310
+			if ( $tag == 'input' ) {
311
+				if ( isset($atts['opt']) ) {
312
+					$atts['opt']--;
313
+				}
314 314
 
315
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
-                if ( isset($atts['class']) ) {
317
-                    unset($atts['class']);
318
-                }
315
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
+				if ( isset($atts['class']) ) {
317
+					unset($atts['class']);
318
+				}
319 319
 
320
-                $field['shortcodes'] = $atts;
321
-                ob_start();
320
+				$field['shortcodes'] = $atts;
321
+				ob_start();
322 322
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
323
-                $replace_with = ob_get_contents();
324
-                ob_end_clean();
325
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
327
-            }
323
+				$replace_with = ob_get_contents();
324
+				ob_end_clean();
325
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
327
+			}
328 328
 
329
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
330
-        }
329
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
330
+		}
331 331
 
332
-        $html .= "\n";
332
+		$html .= "\n";
333 333
 
334
-        //Return html if conf_field to prevent loop
335
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
-            return $html;
337
-        }
334
+		//Return html if conf_field to prevent loop
335
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
+			return $html;
337
+		}
338 338
 
339
-        //If field is in repeating section
340
-        if ( $args['section_id'] ) {
341
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
342
-        } else {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
-        }
339
+		//If field is in repeating section
340
+		if ( $args['section_id'] ) {
341
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
342
+		} else {
343
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
+		}
345 345
 
346 346
 		self::remove_collapse_shortcode( $html );
347 347
 
348
-        return $html;
349
-    }
348
+		return $html;
349
+	}
350 350
 
351 351
 	/**
352 352
 	 * Get the class to use for the label position
@@ -457,46 +457,46 @@  discard block
 block discarded – undo
457 457
 		return $classes;
458 458
 	}
459 459
 
460
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
461
-        if ( $no_vars ) {
460
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
461
+		if ( $no_vars ) {
462 462
 			$html = str_replace( '[if ' . $code . ']', '', $html );
463 463
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
464
-        } else {
464
+		} else {
465 465
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
466
-        }
466
+		}
467 467
 
468 468
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
469
-    }
469
+	}
470 470
 
471 471
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
472 472
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
473
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
474
-            $args['conditional_check'] = true;
475
-        }
476
-
477
-        $prefix = '';
478
-        if ( $args['conditional_check'] ) {
479
-            if ( $args['conditional'] ) {
480
-                $prefix = 'if ';
481
-            } else if ( $args['foreach'] ) {
482
-                $prefix = 'foreach ';
483
-            }
484
-        }
485
-
486
-        $with_tags = $args['conditional_check'] ? 3 : 2;
487
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
488
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
489
-            $tag = str_replace(']', '', $tag);
490
-            $tags = explode(' ', $tag);
491
-            if ( is_array($tags) ) {
492
-                $tag = $tags[0];
493
-            }
494
-        } else {
495
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
496
-        }
497
-
498
-        return $tag;
499
-    }
473
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
474
+			$args['conditional_check'] = true;
475
+		}
476
+
477
+		$prefix = '';
478
+		if ( $args['conditional_check'] ) {
479
+			if ( $args['conditional'] ) {
480
+				$prefix = 'if ';
481
+			} else if ( $args['foreach'] ) {
482
+				$prefix = 'foreach ';
483
+			}
484
+		}
485
+
486
+		$with_tags = $args['conditional_check'] ? 3 : 2;
487
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
488
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
489
+			$tag = str_replace(']', '', $tag);
490
+			$tags = explode(' ', $tag);
491
+			if ( is_array($tags) ) {
492
+				$tag = $tags[0];
493
+			}
494
+		} else {
495
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
496
+		}
497
+
498
+		return $tag;
499
+	}
500 500
 
501 501
 	/**
502 502
 	 * Remove [collapse_this] if it's still included after all processing
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 		}
535 535
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
536 536
 
537
-        wp_register_script( 'recaptcha-api', $api_js_url, array( 'formidable' ), true );
538
-        wp_enqueue_script( 'recaptcha-api' );
537
+		wp_register_script( 'recaptcha-api', $api_js_url, array( 'formidable' ), true );
538
+		wp_enqueue_script( 'recaptcha-api' );
539 539
 
540 540
 		// for reverse compatibility
541 541
 		$field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size'];
@@ -548,68 +548,68 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 ?>></div>
550 550
 <?php
551
-    }
551
+	}
552 552
 
553 553
 	public static function show_single_option( $field ) {
554
-        $field_name = $field['name'];
555
-        $html_id = self::get_html_id($field);
556
-        foreach ( $field['options'] as $opt_key => $opt ) {
557
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
558
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
554
+		$field_name = $field['name'];
555
+		$html_id = self::get_html_id($field);
556
+		foreach ( $field['options'] as $opt_key => $opt ) {
557
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
558
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
559 559
 
560
-            // If this is an "Other" option, get the HTML for it
560
+			// If this is an "Other" option, get the HTML for it
561 561
 			if ( self::is_other_opt( $opt_key ) ) {
562
-                // Get string for Other text field, if needed
562
+				// Get string for Other text field, if needed
563 563
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
564 564
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
565
-            } else {
565
+			} else {
566 566
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
567
-            }
568
-        }
569
-    }
567
+			}
568
+		}
569
+	}
570 570
 
571 571
 	public static function get_term_link( $tax_id ) {
572
-        $tax = get_taxonomy($tax_id);
573
-        if ( ! $tax ) {
574
-            return;
575
-        }
572
+		$tax = get_taxonomy($tax_id);
573
+		if ( ! $tax ) {
574
+			return;
575
+		}
576 576
 
577
-        $link = sprintf(
578
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
577
+		$link = sprintf(
578
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
579 579
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
580
-        );
581
-        unset($tax);
580
+		);
581
+		unset($tax);
582 582
 
583
-        return $link;
584
-    }
583
+		return $link;
584
+	}
585 585
 
586 586
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
587 587
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
588 588
 		$observed_value = self::get_value_for_comparision( $observed_value );
589 589
 
590
-        if ( is_array($observed_value) ) {
591
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
592
-        }
593
-
594
-        $m = false;
595
-        if ( $cond == '==' ) {
596
-            $m = $observed_value == $hide_opt;
597
-        } else if ( $cond == '!=' ) {
598
-            $m = $observed_value != $hide_opt;
599
-        } else if ( $cond == '>' ) {
600
-            $m = $observed_value > $hide_opt;
601
-        } else if ( $cond == '<' ) {
602
-            $m = $observed_value < $hide_opt;
603
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
604
-            $m = stripos($observed_value, $hide_opt);
605
-            if ( $cond == 'not LIKE' ) {
606
-                $m = ( $m === false ) ? true : false;
607
-            } else {
608
-                $m = ( $m === false ) ? false : true;
609
-            }
610
-        }
611
-        return $m;
612
-    }
590
+		if ( is_array($observed_value) ) {
591
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
592
+		}
593
+
594
+		$m = false;
595
+		if ( $cond == '==' ) {
596
+			$m = $observed_value == $hide_opt;
597
+		} else if ( $cond == '!=' ) {
598
+			$m = $observed_value != $hide_opt;
599
+		} else if ( $cond == '>' ) {
600
+			$m = $observed_value > $hide_opt;
601
+		} else if ( $cond == '<' ) {
602
+			$m = $observed_value < $hide_opt;
603
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
604
+			$m = stripos($observed_value, $hide_opt);
605
+			if ( $cond == 'not LIKE' ) {
606
+				$m = ( $m === false ) ? true : false;
607
+			} else {
608
+				$m = ( $m === false ) ? false : true;
609
+			}
610
+		}
611
+		return $m;
612
+	}
613 613
 
614 614
 	/**
615 615
 	 * Trim and sanitize the values
@@ -625,174 +625,174 @@  discard block
 block discarded – undo
625 625
 	}
626 626
 
627 627
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
628
-        $m = false;
629
-        if ( $cond == '==' ) {
630
-            if ( is_array($hide_opt) ) {
631
-                $m = array_intersect($hide_opt, $observed_value);
632
-                $m = empty($m) ? false : true;
633
-            } else {
634
-                $m = in_array($hide_opt, $observed_value);
635
-            }
636
-        } else if ( $cond == '!=' ) {
637
-            $m = ! in_array($hide_opt, $observed_value);
638
-        } else if ( $cond == '>' ) {
639
-            $min = min($observed_value);
640
-            $m = $min > $hide_opt;
641
-        } else if ( $cond == '<' ) {
642
-            $max = max($observed_value);
643
-            $m = $max < $hide_opt;
644
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
645
-            foreach ( $observed_value as $ob ) {
646
-                $m = strpos($ob, $hide_opt);
647
-                if ( $m !== false ) {
648
-                    $m = true;
649
-                    break;
650
-                }
651
-            }
652
-
653
-            if ( $cond == 'not LIKE' ) {
654
-                $m = ( $m === false ) ? true : false;
655
-            }
656
-        }
657
-
658
-        return $m;
659
-    }
660
-
661
-    /**
662
-     * Replace a few basic shortcodes and field ids
663
-     * @since 2.0
664
-     * @return string
665
-     */
628
+		$m = false;
629
+		if ( $cond == '==' ) {
630
+			if ( is_array($hide_opt) ) {
631
+				$m = array_intersect($hide_opt, $observed_value);
632
+				$m = empty($m) ? false : true;
633
+			} else {
634
+				$m = in_array($hide_opt, $observed_value);
635
+			}
636
+		} else if ( $cond == '!=' ) {
637
+			$m = ! in_array($hide_opt, $observed_value);
638
+		} else if ( $cond == '>' ) {
639
+			$min = min($observed_value);
640
+			$m = $min > $hide_opt;
641
+		} else if ( $cond == '<' ) {
642
+			$max = max($observed_value);
643
+			$m = $max < $hide_opt;
644
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
645
+			foreach ( $observed_value as $ob ) {
646
+				$m = strpos($ob, $hide_opt);
647
+				if ( $m !== false ) {
648
+					$m = true;
649
+					break;
650
+				}
651
+			}
652
+
653
+			if ( $cond == 'not LIKE' ) {
654
+				$m = ( $m === false ) ? true : false;
655
+			}
656
+		}
657
+
658
+		return $m;
659
+	}
660
+
661
+	/**
662
+	 * Replace a few basic shortcodes and field ids
663
+	 * @since 2.0
664
+	 * @return string
665
+	 */
666 666
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
667
-        if ( strpos($value, '[sitename]') !== false ) {
668
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
669
-            $value = str_replace('[sitename]', $new_value, $value);
670
-        }
667
+		if ( strpos($value, '[sitename]') !== false ) {
668
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
669
+			$value = str_replace('[sitename]', $new_value, $value);
670
+		}
671 671
 
672
-        $value = apply_filters('frm_content', $value, $form, $entry);
673
-        $value = do_shortcode($value);
672
+		$value = apply_filters('frm_content', $value, $form, $entry);
673
+		$value = do_shortcode($value);
674 674
 
675
-        return $value;
676
-    }
675
+		return $value;
676
+	}
677 677
 
678 678
 	public static function get_shortcodes( $content, $form_id ) {
679
-        if ( FrmAppHelper::pro_is_installed() ) {
680
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
681
-        }
679
+		if ( FrmAppHelper::pro_is_installed() ) {
680
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
681
+		}
682 682
 
683
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
683
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
684 684
 
685
-        $tagregexp = self::allowed_shortcodes($fields);
685
+		$tagregexp = self::allowed_shortcodes($fields);
686 686
 
687
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
687
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
688 688
 
689
-        return $matches;
690
-    }
689
+		return $matches;
690
+	}
691 691
 
692 692
 	public static function allowed_shortcodes( $fields = array() ) {
693
-        $tagregexp = array(
694
-            'editlink', 'id', 'key', 'ip',
695
-            'siteurl', 'sitename', 'admin_email',
696
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
693
+		$tagregexp = array(
694
+			'editlink', 'id', 'key', 'ip',
695
+			'siteurl', 'sitename', 'admin_email',
696
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
697 697
 			'parent[-|_]id',
698
-        );
698
+		);
699 699
 
700
-        foreach ( $fields as $field ) {
701
-            $tagregexp[] = $field->id;
702
-            $tagregexp[] = $field->field_key;
703
-        }
700
+		foreach ( $fields as $field ) {
701
+			$tagregexp[] = $field->id;
702
+			$tagregexp[] = $field->field_key;
703
+		}
704 704
 
705
-        $tagregexp = implode('|', $tagregexp);
706
-        return $tagregexp;
707
-    }
705
+		$tagregexp = implode('|', $tagregexp);
706
+		return $tagregexp;
707
+	}
708 708
 
709 709
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
710
-        $shortcode_values = array(
711
-           'id'     => $entry->id,
712
-           'key'    => $entry->item_key,
713
-           'ip'     => $entry->ip,
714
-        );
710
+		$shortcode_values = array(
711
+		   'id'     => $entry->id,
712
+		   'key'    => $entry->item_key,
713
+		   'ip'     => $entry->ip,
714
+		);
715 715
 
716
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
716
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
717 717
 			if ( empty( $tag ) ) {
718 718
 				continue;
719 719
 			}
720 720
 
721
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
721
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
722 722
 
723
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
723
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
724 724
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
725
-                $tags = explode(' ', $tag);
726
-                if ( is_array($tags) ) {
727
-                    $tag = $tags[0];
728
-                }
729
-            } else {
730
-                $tag = $shortcodes[2][ $short_key ];
731
-            }
732
-
733
-            switch ( $tag ) {
734
-                case 'id':
735
-                case 'key':
736
-                case 'ip':
737
-                    $replace_with = $shortcode_values[ $tag ];
738
-                break;
739
-
740
-                case 'user_agent':
741
-                case 'user-agent':
742
-                    $entry->description = maybe_unserialize($entry->description);
725
+				$tags = explode(' ', $tag);
726
+				if ( is_array($tags) ) {
727
+					$tag = $tags[0];
728
+				}
729
+			} else {
730
+				$tag = $shortcodes[2][ $short_key ];
731
+			}
732
+
733
+			switch ( $tag ) {
734
+				case 'id':
735
+				case 'key':
736
+				case 'ip':
737
+					$replace_with = $shortcode_values[ $tag ];
738
+				break;
739
+
740
+				case 'user_agent':
741
+				case 'user-agent':
742
+					$entry->description = maybe_unserialize($entry->description);
743 743
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
744
-                break;
745
-
746
-                case 'created_at':
747
-                case 'created-at':
748
-                case 'updated_at':
749
-                case 'updated-at':
750
-                    if ( isset($atts['format']) ) {
751
-                        $time_format = ' ';
752
-                    } else {
753
-                        $atts['format'] = get_option('date_format');
754
-                        $time_format = '';
755
-                    }
756
-
757
-                    $this_tag = str_replace('-', '_', $tag);
758
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
759
-                    unset($this_tag);
760
-                break;
761
-
762
-                case 'created_by':
763
-                case 'created-by':
764
-                case 'updated_by':
765
-                case 'updated-by':
766
-                    $this_tag = str_replace('-', '_', $tag);
744
+				break;
745
+
746
+				case 'created_at':
747
+				case 'created-at':
748
+				case 'updated_at':
749
+				case 'updated-at':
750
+					if ( isset($atts['format']) ) {
751
+						$time_format = ' ';
752
+					} else {
753
+						$atts['format'] = get_option('date_format');
754
+						$time_format = '';
755
+					}
756
+
757
+					$this_tag = str_replace('-', '_', $tag);
758
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
759
+					unset($this_tag);
760
+				break;
761
+
762
+				case 'created_by':
763
+				case 'created-by':
764
+				case 'updated_by':
765
+				case 'updated-by':
766
+					$this_tag = str_replace('-', '_', $tag);
767 767
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
768
-                    unset($this_tag);
769
-                break;
770
-
771
-                case 'admin_email':
772
-                case 'siteurl':
773
-                case 'frmurl':
774
-                case 'sitename':
775
-                case 'get':
776
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
777
-                break;
778
-
779
-                default:
780
-                    $field = FrmField::getOne( $tag );
781
-                    if ( ! $field ) {
782
-                        break;
783
-                    }
784
-
785
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
786
-
787
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
788
-
789
-                    $atts['entry_id'] = $entry->id;
790
-                    $atts['entry_key'] = $entry->item_key;
791
-
792
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
793
-                        $replace_with = $field->name;
794
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
795
-                        $replace_with = $field->description;
768
+					unset($this_tag);
769
+				break;
770
+
771
+				case 'admin_email':
772
+				case 'siteurl':
773
+				case 'frmurl':
774
+				case 'sitename':
775
+				case 'get':
776
+					$replace_with = self::dynamic_default_values( $tag, $atts );
777
+				break;
778
+
779
+				default:
780
+					$field = FrmField::getOne( $tag );
781
+					if ( ! $field ) {
782
+						break;
783
+					}
784
+
785
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
786
+
787
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
788
+
789
+					$atts['entry_id'] = $entry->id;
790
+					$atts['entry_key'] = $entry->item_key;
791
+
792
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
793
+						$replace_with = $field->name;
794
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
795
+						$replace_with = $field->description;
796 796
 					} else {
797 797
 						$string_value = $replace_with;
798 798
 						if ( is_array( $replace_with ) ) {
@@ -806,82 +806,82 @@  discard block
 block discarded – undo
806 806
 						}
807 807
 					}
808 808
 
809
-                    unset($field);
810
-                break;
811
-            }
809
+					unset($field);
810
+				break;
811
+			}
812 812
 
813
-            if ( isset($replace_with) ) {
814
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
815
-            }
813
+			if ( isset($replace_with) ) {
814
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
815
+			}
816 816
 
817
-            unset($atts, $conditional, $replace_with);
817
+			unset($atts, $conditional, $replace_with);
818 818
 		}
819 819
 
820 820
 		return $content;
821
-    }
822
-
823
-    /**
824
-     * Get the value to replace a few standard shortcodes
825
-     *
826
-     * @since 2.0
827
-     * @return string
828
-     */
829
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
830
-        $new_value = '';
831
-        switch ( $tag ) {
832
-            case 'admin_email':
833
-                $new_value = get_option('admin_email');
834
-                break;
835
-            case 'siteurl':
836
-                $new_value = FrmAppHelper::site_url();
837
-                break;
838
-            case 'frmurl':
839
-                $new_value = FrmAppHelper::plugin_url();
840
-                break;
841
-            case 'sitename':
842
-                $new_value = FrmAppHelper::site_name();
843
-                break;
844
-            case 'get':
845
-                $new_value = self::process_get_shortcode( $atts, $return_array );
846
-                break;
847
-        }
848
-
849
-        return $new_value;
850
-    }
851
-
852
-    /**
853
-     * Process the [get] shortcode
854
-     *
855
-     * @since 2.0
856
-     * @return string|array
857
-     */
858
-    public static function process_get_shortcode( $atts, $return_array = false ) {
859
-        if ( ! isset($atts['param']) ) {
860
-            return '';
861
-        }
862
-
863
-        if ( strpos($atts['param'], '&#91;') ) {
864
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
866
-        }
821
+	}
822
+
823
+	/**
824
+	 * Get the value to replace a few standard shortcodes
825
+	 *
826
+	 * @since 2.0
827
+	 * @return string
828
+	 */
829
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
830
+		$new_value = '';
831
+		switch ( $tag ) {
832
+			case 'admin_email':
833
+				$new_value = get_option('admin_email');
834
+				break;
835
+			case 'siteurl':
836
+				$new_value = FrmAppHelper::site_url();
837
+				break;
838
+			case 'frmurl':
839
+				$new_value = FrmAppHelper::plugin_url();
840
+				break;
841
+			case 'sitename':
842
+				$new_value = FrmAppHelper::site_name();
843
+				break;
844
+			case 'get':
845
+				$new_value = self::process_get_shortcode( $atts, $return_array );
846
+				break;
847
+		}
848
+
849
+		return $new_value;
850
+	}
851
+
852
+	/**
853
+	 * Process the [get] shortcode
854
+	 *
855
+	 * @since 2.0
856
+	 * @return string|array
857
+	 */
858
+	public static function process_get_shortcode( $atts, $return_array = false ) {
859
+		if ( ! isset($atts['param']) ) {
860
+			return '';
861
+		}
862
+
863
+		if ( strpos($atts['param'], '&#91;') ) {
864
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
866
+		}
867 867
 
868 868
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
869
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
869
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870 870
 
871
-        if ( $new_value == '' ) {
872
-            if ( ! isset($atts['prev_val']) ) {
873
-                $atts['prev_val'] = '';
874
-            }
871
+		if ( $new_value == '' ) {
872
+			if ( ! isset($atts['prev_val']) ) {
873
+				$atts['prev_val'] = '';
874
+			}
875 875
 
876
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
877
-        }
876
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
877
+		}
878 878
 
879
-        if ( is_array($new_value) && ! $return_array ) {
880
-            $new_value = implode(', ', $new_value);
881
-        }
879
+		if ( is_array($new_value) && ! $return_array ) {
880
+			$new_value = implode(', ', $new_value);
881
+		}
882 882
 
883
-        return $new_value;
884
-    }
883
+		return $new_value;
884
+	}
885 885
 
886 886
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
887 887
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
890 890
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
891 891
 
892
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
893
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
894
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
895
-                if ( is_array($replace_with) ) {
896
-                    $replace_with = implode("\n", $replace_with);
897
-                }
898
-                $replace_with = wpautop($replace_with);
899
-            }
892
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
893
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
894
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
895
+				if ( is_array($replace_with) ) {
896
+					$replace_with = implode("\n", $replace_with);
897
+				}
898
+				$replace_with = wpautop($replace_with);
899
+			}
900 900
 			unset( $autop );
901 901
 		} else if ( is_array( $replace_with ) ) {
902 902
 			if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) {
@@ -910,37 +910,37 @@  discard block
 block discarded – undo
910 910
 	}
911 911
 
912 912
 	public static function get_field_types( $type ) {
913
-        $single_input = array(
914
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
915
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
916
-            'user_id', 'tag', 'password',
917
-        );
913
+		$single_input = array(
914
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
915
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
916
+			'user_id', 'tag', 'password',
917
+		);
918 918
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
919 919
 		$other_type = array( 'html', 'break' );
920 920
 
921 921
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
922 922
 
923
-        $field_types = array();
924
-        if ( in_array($type, $single_input) ) {
925
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
926
-        } else if ( in_array($type, $multiple_input) ) {
927
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
928
-        } else if ( in_array($type, $other_type) ) {
929
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
923
+		$field_types = array();
924
+		if ( in_array($type, $single_input) ) {
925
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
926
+		} else if ( in_array($type, $multiple_input) ) {
927
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
928
+		} else if ( in_array($type, $other_type) ) {
929
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
930 930
 		} else if ( isset( $field_selection[ $type ] ) ) {
931
-            $field_types[ $type ] = $field_selection[ $type ];
932
-        }
931
+			$field_types[ $type ] = $field_selection[ $type ];
932
+		}
933 933
 
934 934
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
935
-        return $field_types;
936
-    }
935
+		return $field_types;
936
+	}
937 937
 
938
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
939
-        foreach ( $inputs as $input ) {
940
-            $field_types[ $input ] = $fields[ $input ];
941
-            unset($input);
942
-        }
943
-    }
938
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
939
+		foreach ( $inputs as $input ) {
940
+			$field_types[ $input ] = $fields[ $input ];
941
+			unset($input);
942
+		}
943
+	}
944 944
 
945 945
 	/**
946 946
 	 * Check if current field option is an "other" option
@@ -954,14 +954,14 @@  discard block
 block discarded – undo
954 954
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
955 955
 	}
956 956
 
957
-    /**
958
-    * Get value that belongs in "Other" text box
959
-    *
960
-    * @since 2.0.6
961
-    *
962
-    * @param array $args
963
-    */
964
-    public static function get_other_val( $args ) {
957
+	/**
958
+	 * Get value that belongs in "Other" text box
959
+	 *
960
+	 * @since 2.0.6
961
+	 *
962
+	 * @param array $args
963
+	 */
964
+	public static function get_other_val( $args ) {
965 965
 		$defaults = array(
966 966
 			'opt_key' => 0, 'field' => array(),
967 967
 			'parent' => false, 'pointer' => false,
@@ -1037,20 +1037,20 @@  discard block
 block discarded – undo
1037 1037
 		}
1038 1038
 
1039 1039
 		return $other_val;
1040
-    }
1041
-
1042
-    /**
1043
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1044
-    * Intended for front-end use
1045
-    *
1046
-    * @since 2.0.6
1047
-    *
1048
-    * @param array $args should include field, opt_key and field name
1049
-    * @param boolean $other_opt
1050
-    * @param string $checked
1051
-    * @return string $other_val
1052
-    */
1053
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1040
+	}
1041
+
1042
+	/**
1043
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1044
+	 * Intended for front-end use
1045
+	 *
1046
+	 * @since 2.0.6
1047
+	 *
1048
+	 * @param array $args should include field, opt_key and field name
1049
+	 * @param boolean $other_opt
1050
+	 * @param string $checked
1051
+	 * @return string $other_val
1052
+	 */
1053
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1054 1054
 		//Check if this is an "Other" option
1055 1055
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1056 1056
 			return;
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
 			$checked = 'checked="checked" ';
1067 1067
 		}
1068 1068
 
1069
-        return $other_args;
1070
-    }
1069
+		return $other_args;
1070
+	}
1071 1071
 
1072 1072
 	/**
1073 1073
 	 * @param array $args
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
 	 * @since 2.0.6
1118 1118
 	 */
1119 1119
 	public static function include_other_input( $args ) {
1120
-        if ( ! $args['other_opt'] ) {
1121
-        	return;
1120
+		if ( ! $args['other_opt'] ) {
1121
+			return;
1122 1122
 		}
1123 1123
 
1124 1124
 		$classes = array( 'frm_other_input' );
@@ -1139,15 +1139,15 @@  discard block
 block discarded – undo
1139 1139
 	}
1140 1140
 
1141 1141
 	/**
1142
-	* Get the HTML id for an "Other" text field
1143
-	* Note: This does not affect fields in repeating sections
1144
-	*
1145
-	* @since 2.0.08
1146
-	* @param string $type - field type
1147
-	* @param string $html_id
1148
-	* @param string|boolean $opt_key
1149
-	* @return string $other_id
1150
-	*/
1142
+	 * Get the HTML id for an "Other" text field
1143
+	 * Note: This does not affect fields in repeating sections
1144
+	 *
1145
+	 * @since 2.0.08
1146
+	 * @param string $type - field type
1147
+	 * @param string $html_id
1148
+	 * @param string|boolean $opt_key
1149
+	 * @return string $other_id
1150
+	 */
1151 1151
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1152 1152
 		$other_id = $html_id;
1153 1153
 
@@ -1205,10 +1205,10 @@  discard block
 block discarded – undo
1205 1205
 	}
1206 1206
 
1207 1207
 	public static function switch_field_ids( $val ) {
1208
-        global $frm_duplicate_ids;
1209
-        $replace = array();
1210
-        $replace_with = array();
1211
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1208
+		global $frm_duplicate_ids;
1209
+		$replace = array();
1210
+		$replace_with = array();
1211
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1212 1212
 			$replace[] = '[if ' . $old . ']';
1213 1213
 			$replace_with[] = '[if ' . $new . ']';
1214 1214
 			$replace[] = '[if ' . $old . ' ';
@@ -1223,153 +1223,153 @@  discard block
 block discarded – undo
1223 1223
 			$replace_with[] = '[' . $new . ']';
1224 1224
 			$replace[] = '[' . $old . ' ';
1225 1225
 			$replace_with[] = '[' . $new . ' ';
1226
-            unset($old, $new);
1227
-        }
1226
+			unset($old, $new);
1227
+		}
1228 1228
 		if ( is_array( $val ) ) {
1229 1229
 			foreach ( $val as $k => $v ) {
1230
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1231
-                unset($k, $v);
1232
-            }
1233
-        } else {
1234
-            $val = str_replace($replace, $replace_with, $val);
1235
-        }
1236
-
1237
-        return $val;
1238
-    }
1239
-
1240
-    public static function get_us_states() {
1241
-        return apply_filters( 'frm_us_states', array(
1242
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1243
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1244
-            'DC' => 'District of Columbia',
1245
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1246
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1247
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1248
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1249
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1250
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1251
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1252
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1253
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1254
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1255
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1256
-        ) );
1257
-    }
1258
-
1259
-    public static function get_countries() {
1260
-        return apply_filters( 'frm_countries', array(
1261
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1262
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1263
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1264
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1265
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1266
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1267
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1268
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1269
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1270
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1271
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1272
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1273
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1274
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1275
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1276
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1277
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1278
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1279
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1280
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1281
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1282
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1283
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1284
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1285
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1286
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1287
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1288
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1289
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1290
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1291
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1292
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1293
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1294
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1295
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1296
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1297
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1298
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1299
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1300
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1301
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1302
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1303
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1304
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1305
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1306
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1307
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1308
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1309
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1310
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1311
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1312
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1313
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1314
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1315
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1316
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1317
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1318
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1319
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1320
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1321
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1322
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1323
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1324
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1325
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1326
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1327
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1328
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1329
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1330
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1331
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1332
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1333
-            __( 'Zimbabwe', 'formidable' ),
1334
-        ) );
1335
-    }
1230
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1231
+				unset($k, $v);
1232
+			}
1233
+		} else {
1234
+			$val = str_replace($replace, $replace_with, $val);
1235
+		}
1236
+
1237
+		return $val;
1238
+	}
1239
+
1240
+	public static function get_us_states() {
1241
+		return apply_filters( 'frm_us_states', array(
1242
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1243
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1244
+			'DC' => 'District of Columbia',
1245
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1246
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1247
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1248
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1249
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1250
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1251
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1252
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1253
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1254
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1255
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1256
+		) );
1257
+	}
1258
+
1259
+	public static function get_countries() {
1260
+		return apply_filters( 'frm_countries', array(
1261
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1262
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1263
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1264
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1265
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1266
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1267
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1268
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1269
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1270
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1271
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1272
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1273
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1274
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1275
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1276
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1277
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1278
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1279
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1280
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1281
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1282
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1283
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1284
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1285
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1286
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1287
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1288
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1289
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1290
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1291
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1292
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1293
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1294
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1295
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1296
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1297
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1298
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1299
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1300
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1301
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1302
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1303
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1304
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1305
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1306
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1307
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1308
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1309
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1310
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1311
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1312
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1313
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1314
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1315
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1316
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1317
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1318
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1319
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1320
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1321
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1322
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1323
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1324
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1325
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1326
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1327
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1328
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1329
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1330
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1331
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1332
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1333
+			__( 'Zimbabwe', 'formidable' ),
1334
+		) );
1335
+	}
1336 1336
 
1337 1337
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1338 1338
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1339 1339
 
1340
-        $states = FrmFieldsHelper::get_us_states();
1341
-        $state_abv = array_keys($states);
1342
-        sort($state_abv);
1340
+		$states = FrmFieldsHelper::get_us_states();
1341
+		$state_abv = array_keys($states);
1342
+		sort($state_abv);
1343 1343
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1344 1344
 
1345
-        $states = array_values($states);
1346
-        sort($states);
1345
+		$states = array_values($states);
1346
+		sort($states);
1347 1347
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1348
-        unset($state_abv, $states);
1348
+		unset($state_abv, $states);
1349 1349
 
1350 1350
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1351
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1352
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1353
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1354
-        );
1351
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1352
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1353
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1354
+		);
1355 1355
 
1356 1356
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1357
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1358
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1359
-        );
1357
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1358
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1359
+		);
1360 1360
 
1361 1361
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1362
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1363
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1364
-        );
1362
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1363
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1364
+		);
1365 1365
 
1366 1366
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1367
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1368
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1369
-        );
1367
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1368
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1369
+		);
1370 1370
 
1371 1371
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1372
-    }
1372
+	}
1373 1373
 
1374 1374
 	/**
1375 1375
 	 * Display a field value selector
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
 	 * @param int $selector_field_id
1380 1380
 	 * @param array $selector_args
1381 1381
 	 */
1382
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1383
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1384
-	    $field_value_selector->display();
1385
-    }
1382
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1383
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1384
+		$field_value_selector->display();
1385
+	}
1386 1386
 
1387 1387
 	/**
1388 1388
 	 * Convert a field object to a flat array
@@ -1435,10 +1435,10 @@  discard block
 block discarded – undo
1435 1435
 		return FrmField::is_required( $field );
1436 1436
 	}
1437 1437
 
1438
-    public static function maybe_get_field( &$field ) {
1438
+	public static function maybe_get_field( &$field ) {
1439 1439
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1440 1440
 		FrmField::maybe_get_field( $field );
1441
-    }
1441
+	}
1442 1442
 
1443 1443
 	public static function dropdown_categories( $args ) {
1444 1444
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
         }
58 58
 
59 59
 		$fields = FrmField::field_selection();
60
-        $fields = array_merge($fields, FrmField::pro_field_selection());
60
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
61 61
 
62
-        if ( isset( $fields[ $type ] ) ) {
63
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
62
+        if ( isset( $fields[$type] ) ) {
63
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
64 64
         }
65 65
 
66
-        unset($fields);
66
+        unset( $fields );
67 67
 
68 68
         return $values;
69 69
     }
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             $values['form_name'] = '';
90 90
 		} else {
91 91
 			foreach ( $defaults as $var => $default ) {
92
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
-                unset($var, $default);
92
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
93
+                unset( $var, $default );
94 94
             }
95 95
 
96 96
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $values['options'] = $record->options;
102 102
         $values['field_options'] = $record->field_options;
103 103
 
104
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
104
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
105 105
 
106 106
 		if ( $values['type'] == 'captcha' ) {
107 107
             $frm_settings = FrmAppHelper::get_settings();
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
 		foreach ( $defaults as $opt => $default ) {
112
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
113
-            unset($opt, $default);
112
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
113
+            unset( $opt, $default );
114 114
         }
115 115
 
116
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
117 117
 
118 118
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
119 119
     }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
         global $wpdb;
134 134
 
135
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
135
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
136 136
 
137 137
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
138 138
 
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 
155 155
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
156 156
         $values['form_id'] = $form_id;
157
-        $values['options'] = maybe_serialize($field->options);
158
-        $values['default_value'] = maybe_serialize($field->default_value);
157
+        $values['options'] = maybe_serialize( $field->options );
158
+        $values['default_value'] = maybe_serialize( $field->default_value );
159 159
 
160 160
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
161
-            $values[ $col ] = $field->{$col};
161
+            $values[$col] = $field->{$col};
162 162
         }
163 163
     }
164 164
 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
174 174
 		$defaults = array(
175
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
176
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
175
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
176
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
177 177
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
178 178
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
179 179
 		);
180 180
 
181 181
 		$msg = FrmField::get_option( $field, $error );
182
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
182
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
183 183
 		$msg = do_shortcode( $msg );
184 184
 		return $msg;
185 185
 	}
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 </div>
210 210
 DEFAULT_HTML;
211 211
         } else {
212
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
213 213
         }
214 214
 
215
-        return apply_filters('frm_custom_html', $default_html, $type);
215
+        return apply_filters( 'frm_custom_html', $default_html, $type );
216 216
     }
217 217
 
218 218
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
219
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
220 220
 
221 221
         $defaults = array(
222 222
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -224,42 +224,42 @@  discard block
 block discarded – undo
224 224
             'field_plus_id' => '',
225 225
             'section_id'    => '',
226 226
         );
227
-        $args = wp_parse_args($args, $defaults);
227
+        $args = wp_parse_args( $args, $defaults );
228 228
         $field_name = $args['field_name'];
229 229
         $field_id = $args['field_id'];
230
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
230
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
231 231
 
232
-        if ( FrmField::is_multiple_select($field) ) {
232
+        if ( FrmField::is_multiple_select( $field ) ) {
233 233
             $field_name .= '[]';
234 234
         }
235 235
 
236 236
         //replace [id]
237
-        $html = str_replace('[id]', $field_id, $html);
237
+        $html = str_replace( '[id]', $field_id, $html );
238 238
 
239 239
         // Remove the for attribute for captcha
240 240
         if ( $field['type'] == 'captcha' ) {
241
-            $html = str_replace(' for="field_[key]"', '', $html);
241
+            $html = str_replace( ' for="field_[key]"', '', $html );
242 242
         }
243 243
 
244 244
         // set the label for
245
-        $html = str_replace('field_[key]', $html_id, $html);
245
+        $html = str_replace( 'field_[key]', $html_id, $html );
246 246
 
247 247
         //replace [key]
248
-        $html = str_replace('[key]', $field['field_key'], $html);
248
+        $html = str_replace( '[key]', $field['field_key'], $html );
249 249
 
250 250
         //replace [description] and [required_label] and [error]
251 251
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
252 252
         if ( ! is_array( $errors ) ) {
253 253
             $errors = array();
254 254
         }
255
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
256 256
 
257 257
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
258 258
         if ( $field['type'] == 'divider' ) {
259 259
             if ( FrmField::is_option_true( $field, 'description' ) ) {
260 260
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
261 261
             } else {
262
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
263 263
             }
264 264
         }
265 265
 
@@ -269,52 +269,52 @@  discard block
 block discarded – undo
269 269
 
270 270
         //replace [required_class]
271 271
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
272
-        $html = str_replace('[required_class]', $required_class, $html);
272
+        $html = str_replace( '[required_class]', $required_class, $html );
273 273
 
274 274
         //replace [label_position]
275 275
 		$field['label'] = self::label_position( $field['label'], $field, $form );
276 276
 		self::add_class_to_label( $field, $html );
277 277
 
278 278
         //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+        $html = str_replace( '[field_name]', $field['name'], $html );
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
 		if ( $form ) {
288 288
 			$form = (array) $form;
289 289
 
290 290
 			//replace [form_key]
291
-			$html = str_replace('[form_key]', $form['form_key'], $html);
291
+			$html = str_replace( '[form_key]', $form['form_key'], $html );
292 292
 
293 293
 			//replace [form_name]
294
-			$html = str_replace('[form_name]', $form['name'], $html);
294
+			$html = str_replace( '[form_name]', $form['name'], $html );
295 295
 		}
296 296
 
297 297
 		self::process_wp_shortcodes( $html );
298 298
 
299 299
         //replace [input]
300
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
300
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
301 301
         global $frm_vars;
302 302
         $frm_settings = FrmAppHelper::get_settings();
303 303
 
304 304
         foreach ( $shortcodes[0] as $short_key => $tag ) {
305
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
305
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
306 306
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
307 307
 
308 308
             $replace_with = '';
309 309
 
310 310
             if ( $tag == 'input' ) {
311
-                if ( isset($atts['opt']) ) {
312
-                    $atts['opt']--;
311
+                if ( isset( $atts['opt'] ) ) {
312
+                    $atts['opt'] --;
313 313
                 }
314 314
 
315
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
316
-                if ( isset($atts['class']) ) {
317
-                    unset($atts['class']);
315
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
316
+                if ( isset( $atts['class'] ) ) {
317
+                    unset( $atts['class'] );
318 318
                 }
319 319
 
320 320
                 $field['shortcodes'] = $atts;
@@ -323,24 +323,24 @@  discard block
 block discarded – undo
323 323
                 $replace_with = ob_get_contents();
324 324
                 ob_end_clean();
325 325
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
326
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
326
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
327 327
             }
328 328
 
329
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
329
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
330 330
         }
331 331
 
332 332
         $html .= "\n";
333 333
 
334 334
         //Return html if conf_field to prevent loop
335
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
335
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
336 336
             return $html;
337 337
         }
338 338
 
339 339
         //If field is in repeating section
340 340
         if ( $args['section_id'] ) {
341
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
341
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
342 342
         } else {
343
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
343
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
344 344
         }
345 345
 
346 346
 		self::remove_collapse_shortcode( $html );
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
440 440
 		// Add error class
441
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
441
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
442 442
 
443 443
 		// Add label position class
444 444
 		$classes .= ' frm_' . $field['label'] . '_container';
445 445
 
446 446
 		// Add CSS layout classes
447 447
 		if ( ! empty( $field['classes'] ) ) {
448
-			if ( ! strpos( $html, 'frm_form_field ') ) {
448
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
449 449
 				$classes .= ' frm_form_field';
450 450
 			}
451 451
 			$classes .= ' ' . $field['classes'];
@@ -484,15 +484,15 @@  discard block
 block discarded – undo
484 484
         }
485 485
 
486 486
         $with_tags = $args['conditional_check'] ? 3 : 2;
487
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
488
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
489
-            $tag = str_replace(']', '', $tag);
490
-            $tags = explode(' ', $tag);
491
-            if ( is_array($tags) ) {
487
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
488
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
489
+            $tag = str_replace( ']', '', $tag );
490
+            $tags = explode( ' ', $tag );
491
+            if ( is_array( $tags ) ) {
492 492
                 $tag = $tags[0];
493 493
             }
494 494
         } else {
495
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
495
+            $tag = $shortcodes[$with_tags - 1][$short_key];
496 496
         }
497 497
 
498 498
         return $tag;
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
 
553 553
 	public static function show_single_option( $field ) {
554 554
         $field_name = $field['name'];
555
-        $html_id = self::get_html_id($field);
555
+        $html_id = self::get_html_id( $field );
556 556
         foreach ( $field['options'] as $opt_key => $opt ) {
557
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
558
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
557
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
558
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
559 559
 
560 560
             // If this is an "Other" option, get the HTML for it
561 561
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     }
570 570
 
571 571
 	public static function get_term_link( $tax_id ) {
572
-        $tax = get_taxonomy($tax_id);
572
+        $tax = get_taxonomy( $tax_id );
573 573
         if ( ! $tax ) {
574 574
             return;
575 575
         }
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
579 579
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
580 580
         );
581
-        unset($tax);
581
+        unset( $tax );
582 582
 
583 583
         return $link;
584 584
     }
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
588 588
 		$observed_value = self::get_value_for_comparision( $observed_value );
589 589
 
590
-        if ( is_array($observed_value) ) {
591
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
590
+        if ( is_array( $observed_value ) ) {
591
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
592 592
         }
593 593
 
594 594
         $m = false;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         } else if ( $cond == '<' ) {
602 602
             $m = $observed_value < $hide_opt;
603 603
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
604
-            $m = stripos($observed_value, $hide_opt);
604
+            $m = stripos( $observed_value, $hide_opt );
605 605
             if ( $cond == 'not LIKE' ) {
606 606
                 $m = ( $m === false ) ? true : false;
607 607
             } else {
@@ -627,23 +627,23 @@  discard block
 block discarded – undo
627 627
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
628 628
         $m = false;
629 629
         if ( $cond == '==' ) {
630
-            if ( is_array($hide_opt) ) {
631
-                $m = array_intersect($hide_opt, $observed_value);
632
-                $m = empty($m) ? false : true;
630
+            if ( is_array( $hide_opt ) ) {
631
+                $m = array_intersect( $hide_opt, $observed_value );
632
+                $m = empty( $m ) ? false : true;
633 633
             } else {
634
-                $m = in_array($hide_opt, $observed_value);
634
+                $m = in_array( $hide_opt, $observed_value );
635 635
             }
636 636
         } else if ( $cond == '!=' ) {
637
-            $m = ! in_array($hide_opt, $observed_value);
637
+            $m = ! in_array( $hide_opt, $observed_value );
638 638
         } else if ( $cond == '>' ) {
639
-            $min = min($observed_value);
639
+            $min = min( $observed_value );
640 640
             $m = $min > $hide_opt;
641 641
         } else if ( $cond == '<' ) {
642
-            $max = max($observed_value);
642
+            $max = max( $observed_value );
643 643
             $m = $max < $hide_opt;
644 644
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
645 645
             foreach ( $observed_value as $ob ) {
646
-                $m = strpos($ob, $hide_opt);
646
+                $m = strpos( $ob, $hide_opt );
647 647
                 if ( $m !== false ) {
648 648
                     $m = true;
649 649
                     break;
@@ -664,27 +664,27 @@  discard block
 block discarded – undo
664 664
      * @return string
665 665
      */
666 666
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
667
-        if ( strpos($value, '[sitename]') !== false ) {
667
+        if ( strpos( $value, '[sitename]' ) !== false ) {
668 668
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
669
-            $value = str_replace('[sitename]', $new_value, $value);
669
+            $value = str_replace( '[sitename]', $new_value, $value );
670 670
         }
671 671
 
672
-        $value = apply_filters('frm_content', $value, $form, $entry);
673
-        $value = do_shortcode($value);
672
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
673
+        $value = do_shortcode( $value );
674 674
 
675 675
         return $value;
676 676
     }
677 677
 
678 678
 	public static function get_shortcodes( $content, $form_id ) {
679 679
         if ( FrmAppHelper::pro_is_installed() ) {
680
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
680
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
681 681
         }
682 682
 
683 683
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
684 684
 
685
-        $tagregexp = self::allowed_shortcodes($fields);
685
+        $tagregexp = self::allowed_shortcodes( $fields );
686 686
 
687
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
687
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
688 688
 
689 689
         return $matches;
690 690
     }
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
             $tagregexp[] = $field->field_key;
703 703
         }
704 704
 
705
-        $tagregexp = implode('|', $tagregexp);
705
+        $tagregexp = implode( '|', $tagregexp );
706 706
         return $tagregexp;
707 707
     }
708 708
 
@@ -718,28 +718,28 @@  discard block
 block discarded – undo
718 718
 				continue;
719 719
 			}
720 720
 
721
-            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
721
+            $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
722 722
 
723
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
724
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
725
-                $tags = explode(' ', $tag);
726
-                if ( is_array($tags) ) {
723
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
724
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
725
+                $tags = explode( ' ', $tag );
726
+                if ( is_array( $tags ) ) {
727 727
                     $tag = $tags[0];
728 728
                 }
729 729
             } else {
730
-                $tag = $shortcodes[2][ $short_key ];
730
+                $tag = $shortcodes[2][$short_key];
731 731
             }
732 732
 
733 733
             switch ( $tag ) {
734 734
                 case 'id':
735 735
                 case 'key':
736 736
                 case 'ip':
737
-                    $replace_with = $shortcode_values[ $tag ];
737
+                    $replace_with = $shortcode_values[$tag];
738 738
                 break;
739 739
 
740 740
                 case 'user_agent':
741 741
                 case 'user-agent':
742
-                    $entry->description = maybe_unserialize($entry->description);
742
+                    $entry->description = maybe_unserialize( $entry->description );
743 743
 					$replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] );
744 744
                 break;
745 745
 
@@ -747,25 +747,25 @@  discard block
 block discarded – undo
747 747
                 case 'created-at':
748 748
                 case 'updated_at':
749 749
                 case 'updated-at':
750
-                    if ( isset($atts['format']) ) {
750
+                    if ( isset( $atts['format'] ) ) {
751 751
                         $time_format = ' ';
752 752
                     } else {
753
-                        $atts['format'] = get_option('date_format');
753
+                        $atts['format'] = get_option( 'date_format' );
754 754
                         $time_format = '';
755 755
                     }
756 756
 
757
-                    $this_tag = str_replace('-', '_', $tag);
758
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
759
-                    unset($this_tag);
757
+                    $this_tag = str_replace( '-', '_', $tag );
758
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
759
+                    unset( $this_tag );
760 760
                 break;
761 761
 
762 762
                 case 'created_by':
763 763
                 case 'created-by':
764 764
                 case 'updated_by':
765 765
                 case 'updated-by':
766
-                    $this_tag = str_replace('-', '_', $tag);
766
+                    $this_tag = str_replace( '-', '_', $tag );
767 767
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
768
-                    unset($this_tag);
768
+                    unset( $this_tag );
769 769
                 break;
770 770
 
771 771
                 case 'admin_email':
@@ -782,16 +782,16 @@  discard block
 block discarded – undo
782 782
                         break;
783 783
                     }
784 784
 
785
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
785
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
786 786
 
787 787
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
788 788
 
789 789
                     $atts['entry_id'] = $entry->id;
790 790
                     $atts['entry_key'] = $entry->item_key;
791 791
 
792
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
792
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
793 793
                         $replace_with = $field->name;
794
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
794
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
795 795
                         $replace_with = $field->description;
796 796
 					} else {
797 797
 						$string_value = $replace_with;
@@ -806,15 +806,15 @@  discard block
 block discarded – undo
806 806
 						}
807 807
 					}
808 808
 
809
-                    unset($field);
809
+                    unset( $field );
810 810
                 break;
811 811
             }
812 812
 
813
-            if ( isset($replace_with) ) {
814
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
813
+            if ( isset( $replace_with ) ) {
814
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
815 815
             }
816 816
 
817
-            unset($atts, $conditional, $replace_with);
817
+            unset( $atts, $conditional, $replace_with );
818 818
 		}
819 819
 
820 820
 		return $content;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
         $new_value = '';
831 831
         switch ( $tag ) {
832 832
             case 'admin_email':
833
-                $new_value = get_option('admin_email');
833
+                $new_value = get_option( 'admin_email' );
834 834
                 break;
835 835
             case 'siteurl':
836 836
                 $new_value = FrmAppHelper::site_url();
@@ -856,28 +856,28 @@  discard block
 block discarded – undo
856 856
      * @return string|array
857 857
      */
858 858
     public static function process_get_shortcode( $atts, $return_array = false ) {
859
-        if ( ! isset($atts['param']) ) {
859
+        if ( ! isset( $atts['param'] ) ) {
860 860
             return '';
861 861
         }
862 862
 
863
-        if ( strpos($atts['param'], '&#91;') ) {
864
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
863
+        if ( strpos( $atts['param'], '&#91;' ) ) {
864
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
865
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
866 866
         }
867 867
 
868 868
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
869 869
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870 870
 
871 871
         if ( $new_value == '' ) {
872
-            if ( ! isset($atts['prev_val']) ) {
872
+            if ( ! isset( $atts['prev_val'] ) ) {
873 873
                 $atts['prev_val'] = '';
874 874
             }
875 875
 
876
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
876
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
877 877
         }
878 878
 
879
-        if ( is_array($new_value) && ! $return_array ) {
880
-            $new_value = implode(', ', $new_value);
879
+        if ( is_array( $new_value ) && ! $return_array ) {
880
+            $new_value = implode( ', ', $new_value );
881 881
         }
882 882
 
883 883
         return $new_value;
@@ -890,17 +890,17 @@  discard block
 block discarded – undo
890 890
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
891 891
 
892 892
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
893
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
894
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
895
-                if ( is_array($replace_with) ) {
896
-                    $replace_with = implode("\n", $replace_with);
893
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
894
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
895
+                if ( is_array( $replace_with ) ) {
896
+                    $replace_with = implode( "\n", $replace_with );
897 897
                 }
898
-                $replace_with = wpautop($replace_with);
898
+                $replace_with = wpautop( $replace_with );
899 899
             }
900 900
 			unset( $autop );
901 901
 		} else if ( is_array( $replace_with ) ) {
902
-			if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) {
903
-				$replace_with = $replace_with[ $atts['show'] ];
902
+			if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[$atts['show']] ) ) {
903
+				$replace_with = $replace_with[$atts['show']];
904 904
 			} else {
905 905
 				$replace_with = implode( $sep, $replace_with );
906 906
 			}
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
922 922
 
923 923
         $field_types = array();
924
-        if ( in_array($type, $single_input) ) {
924
+        if ( in_array( $type, $single_input ) ) {
925 925
             self::field_types_for_input( $single_input, $field_selection, $field_types );
926
-        } else if ( in_array($type, $multiple_input) ) {
926
+        } else if ( in_array( $type, $multiple_input ) ) {
927 927
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
928
-        } else if ( in_array($type, $other_type) ) {
928
+        } else if ( in_array( $type, $other_type ) ) {
929 929
             self::field_types_for_input( $other_type, $field_selection, $field_types );
930
-		} else if ( isset( $field_selection[ $type ] ) ) {
931
-            $field_types[ $type ] = $field_selection[ $type ];
930
+		} else if ( isset( $field_selection[$type] ) ) {
931
+            $field_types[$type] = $field_selection[$type];
932 932
         }
933 933
 
934 934
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 
938 938
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
939 939
         foreach ( $inputs as $input ) {
940
-            $field_types[ $input ] = $fields[ $input ];
941
-            unset($input);
940
+            $field_types[$input] = $fields[$input];
941
+            unset( $input );
942 942
         }
943 943
     }
944 944
 
@@ -983,21 +983,21 @@  discard block
 block discarded – undo
983 983
 		// Check posted vals before checking saved values
984 984
 
985 985
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
986
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
986
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
987 987
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
988
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
988
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
989 989
 			} else {
990
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
990
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
991 991
 			}
992 992
 			return $other_val;
993 993
 
994
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
994
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
995 995
 			// For normal fields
996 996
 
997 997
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
998
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
998
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
999 999
 			} else {
1000
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
1000
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
1001 1001
 			}
1002 1002
 			return $other_val;
1003 1003
 		}
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1007 1007
 			// Check if there is an "other" val in saved value and make sure the
1008 1008
 			// "other" val is not equal to the Other checkbox option
1009
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1010
-				$other_val = $field['value'][ $opt_key ];
1009
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1010
+				$other_val = $field['value'][$opt_key];
1011 1011
 			}
1012 1012
 		} else {
1013 1013
 			/**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 				// Multi-select dropdowns - key is not preserved
1020 1020
 				if ( is_array( $field['value'] ) ) {
1021 1021
 					$o_key = array_search( $temp_val, $field['value'] );
1022
-					if ( isset( $field['value'][ $o_key ] ) ) {
1023
-						unset( $field['value'][ $o_key ], $o_key );
1022
+					if ( isset( $field['value'][$o_key] ) ) {
1023
+						unset( $field['value'][$o_key], $o_key );
1024 1024
 					}
1025 1025
 				} else if ( $temp_val == $field['value'] ) {
1026 1026
 					// For radio and regular dropdowns
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 	private static function set_other_name( $args, &$other_args ) {
1078 1078
 		//Set up name for other field
1079 1079
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1080
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1080
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1081 1081
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1082 1082
 
1083 1083
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		// Count should only be greater than 3 if inside of a repeating section
1105 1105
 		if ( count( $temp_array ) > 3 ) {
1106 1106
 			$parent = str_replace( ']', '', $temp_array[1] );
1107
-			$pointer = str_replace( ']', '', $temp_array[2]);
1107
+			$pointer = str_replace( ']', '', $temp_array[2] );
1108 1108
 		}
1109 1109
 
1110 1110
 		// Get text for "other" text field
@@ -1223,15 +1223,15 @@  discard block
 block discarded – undo
1223 1223
 			$replace_with[] = '[' . $new . ']';
1224 1224
 			$replace[] = '[' . $old . ' ';
1225 1225
 			$replace_with[] = '[' . $new . ' ';
1226
-            unset($old, $new);
1226
+            unset( $old, $new );
1227 1227
         }
1228 1228
 		if ( is_array( $val ) ) {
1229 1229
 			foreach ( $val as $k => $v ) {
1230
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1231
-                unset($k, $v);
1230
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1231
+                unset( $k, $v );
1232 1232
             }
1233 1233
         } else {
1234
-            $val = str_replace($replace, $replace_with, $val);
1234
+            $val = str_replace( $replace, $replace_with, $val );
1235 1235
         }
1236 1236
 
1237 1237
         return $val;
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
             'DC' => 'District of Columbia',
1245 1245
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1246 1246
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1247
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1247
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1248 1248
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1249 1249
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1250 1250
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1335,35 +1335,35 @@  discard block
 block discarded – undo
1335 1335
     }
1336 1336
 
1337 1337
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1338
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1338
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1339 1339
 
1340 1340
         $states = FrmFieldsHelper::get_us_states();
1341
-        $state_abv = array_keys($states);
1342
-        sort($state_abv);
1343
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1341
+        $state_abv = array_keys( $states );
1342
+        sort( $state_abv );
1343
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1344 1344
 
1345
-        $states = array_values($states);
1346
-        sort($states);
1347
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1348
-        unset($state_abv, $states);
1345
+        $states = array_values( $states );
1346
+        sort( $states );
1347
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1348
+        unset( $state_abv, $states );
1349 1349
 
1350
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1350
+		$prepop[__( 'Age', 'formidable' )] = array(
1351 1351
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1352 1352
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1353 1353
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1354 1354
         );
1355 1355
 
1356
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1356
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1357 1357
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1358 1358
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1359 1359
         );
1360 1360
 
1361
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1361
+		$prepop[__( 'Importance', 'formidable' )] = array(
1362 1362
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1363 1363
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1364 1364
         );
1365 1365
 
1366
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1366
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1367 1367
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1368 1368
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1369 1369
         );
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 1 patch
Indentation   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,35 +24,35 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
64
-            $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
63
+			$values = FrmFormsHelper::setup_new_vars($values);
64
+			$id = FrmForm::create( $values );
65
+			$form = FrmForm::getOne($id);
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
69 69
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
70 70
 
71
-            $values['id'] = $id;
71
+			$values['id'] = $id;
72 72
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
73
-        }
74
-    }
73
+		}
74
+	}
75 75
 
76 76
 	/**
77 77
 	 * Create the default email action
@@ -80,87 +80,87 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param object $form
82 82
 	 */
83
-    private static function create_default_email_action( $form ) {
84
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
83
+	private static function create_default_email_action( $form ) {
84
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
85 85
 
86
-	    if ( $create_email ) {
87
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
88
-		    $action_control->create( $form->id );
89
-	    }
90
-    }
86
+		if ( $create_email ) {
87
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
88
+			$action_control->create( $form->id );
89
+		}
90
+	}
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+		FrmAppHelper::permission_check('frm_edit_forms');
94 94
 
95
-        global $frm_vars;
96
-        if ( empty( $values ) ) {
97
-            $values = $_POST;
98
-        }
95
+		global $frm_vars;
96
+		if ( empty( $values ) ) {
97
+			$values = $_POST;
98
+		}
99 99
 
100
-        //Set radio button and checkbox meta equal to "other" value
101
-        if ( FrmAppHelper::pro_is_installed() ) {
102
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
103
-        }
100
+		//Set radio button and checkbox meta equal to "other" value
101
+		if ( FrmAppHelper::pro_is_installed() ) {
102
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
103
+		}
104 104
 
105 105
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
-            $frm_settings = FrmAppHelper::get_settings();
109
-            $errors = array( 'form' => $frm_settings->admin_permission );
110
-        } else {
111
-            $errors = FrmForm::validate($values);
112
-        }
107
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
+			$frm_settings = FrmAppHelper::get_settings();
109
+			$errors = array( 'form' => $frm_settings->admin_permission );
110
+		} else {
111
+			$errors = FrmForm::validate($values);
112
+		}
113 113
 
114
-        if ( count($errors) > 0 ) {
115
-            $hide_preview = true;
114
+		if ( count($errors) > 0 ) {
115
+			$hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117
-            $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
117
+			$form = FrmForm::getOne( $id );
118
+			$fields = FrmField::get_all_for_form($id);
119 119
 
120
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
120
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
121 121
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
122 122
 
123 123
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
124
-        } else {
125
-            FrmForm::update( $id, $values, true );
124
+		} else {
125
+			FrmForm::update( $id, $values, true );
126 126
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
127 127
 			die( FrmAppHelper::js_redirect( $url ) );
128
-        }
129
-    }
128
+		}
129
+	}
130 130
 
131
-    public static function edit( $values = false ) {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function edit( $values = false ) {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
-        return self::get_edit_vars($id);
136
-    }
135
+		return self::get_edit_vars($id);
136
+	}
137 137
 
138
-    public static function settings( $id = false, $message = '' ) {
139
-        FrmAppHelper::permission_check('frm_edit_forms');
138
+	public static function settings( $id = false, $message = '' ) {
139
+		FrmAppHelper::permission_check('frm_edit_forms');
140 140
 
141
-        if ( ! $id || ! is_numeric($id) ) {
141
+		if ( ! $id || ! is_numeric($id) ) {
142 142
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-        }
143
+		}
144 144
 		return self::get_settings_vars( $id, array(), $message );
145
-    }
145
+	}
146 146
 
147
-    public static function update_settings() {
148
-        FrmAppHelper::permission_check('frm_edit_forms');
147
+	public static function update_settings() {
148
+		FrmAppHelper::permission_check('frm_edit_forms');
149 149
 
150 150
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
151 151
 
152
-        $errors = FrmForm::validate($_POST);
153
-        if ( count($errors) > 0 ) {
154
-            return self::get_settings_vars($id, $errors);
155
-        }
152
+		$errors = FrmForm::validate($_POST);
153
+		if ( count($errors) > 0 ) {
154
+			return self::get_settings_vars($id, $errors);
155
+		}
156 156
 
157
-        do_action('frm_before_update_form_settings', $id);
157
+		do_action('frm_before_update_form_settings', $id);
158 158
 
159 159
 		FrmForm::update( $id, $_POST );
160 160
 
161
-        $message = __( 'Settings Successfully Updated', 'formidable' );
161
+		$message = __( 'Settings Successfully Updated', 'formidable' );
162 162
 		return self::get_settings_vars( $id, array(), $message );
163
-    }
163
+	}
164 164
 
165 165
 	public static function edit_key() {
166 166
 		$values = self::edit_in_place_value( 'form_key' );
@@ -190,43 +190,43 @@  discard block
 block discarded – undo
190 190
 
191 191
 	public static function update( $values = array() ) {
192 192
 		if ( empty( $values ) ) {
193
-            $values = $_POST;
194
-        }
193
+			$values = $_POST;
194
+		}
195 195
 
196
-        //Set radio button and checkbox meta equal to "other" value
197
-        if ( FrmAppHelper::pro_is_installed() ) {
198
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
199
-        }
196
+		//Set radio button and checkbox meta equal to "other" value
197
+		if ( FrmAppHelper::pro_is_installed() ) {
198
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
199
+		}
200 200
 
201
-        $errors = FrmForm::validate( $values );
202
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
-        if ( $permission_error !== false ) {
204
-            $errors['form'] = $permission_error;
205
-        }
201
+		$errors = FrmForm::validate( $values );
202
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
+		if ( $permission_error !== false ) {
204
+			$errors['form'] = $permission_error;
205
+		}
206 206
 
207 207
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
208 208
 
209 209
 		if ( count( $errors ) > 0 ) {
210
-            return self::get_edit_vars( $id, $errors );
210
+			return self::get_edit_vars( $id, $errors );
211 211
 		} else {
212
-            FrmForm::update( $id, $values );
213
-            $message = __( 'Form was Successfully Updated', 'formidable' );
214
-            if ( defined( 'DOING_AJAX' ) ) {
212
+			FrmForm::update( $id, $values );
213
+			$message = __( 'Form was Successfully Updated', 'formidable' );
214
+			if ( defined( 'DOING_AJAX' ) ) {
215 215
 				wp_die( $message );
216
-            }
216
+			}
217 217
 			return self::get_edit_vars( $id, array(), $message );
218
-        }
219
-    }
218
+		}
219
+	}
220 220
 
221
-    public static function bulk_create_template( $ids ) {
222
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
221
+	public static function bulk_create_template( $ids ) {
222
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 
224
-        foreach ( $ids as $id ) {
225
-            FrmForm::duplicate( $id, true, true );
226
-        }
224
+		foreach ( $ids as $id ) {
225
+			FrmForm::duplicate( $id, true, true );
226
+		}
227 227
 
228
-        return __( 'Form template was Successfully Created', 'formidable' );
229
-    }
228
+		return __( 'Form template was Successfully Created', 'formidable' );
229
+	}
230 230
 
231 231
 	/**
232 232
 	 * Redirect to the url for creating from a template
@@ -248,45 +248,45 @@  discard block
 block discarded – undo
248 248
 		wp_die();
249 249
 	}
250 250
 
251
-    public static function duplicate() {
252
-        FrmAppHelper::permission_check('frm_edit_forms');
251
+	public static function duplicate() {
252
+		FrmAppHelper::permission_check('frm_edit_forms');
253 253
 
254 254
 		$params = FrmForm::list_page_params();
255
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
-        if ( $form ) {
255
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
+		if ( $form ) {
258 258
 			return self::get_edit_vars( $form, array(), $message, true );
259
-        } else {
260
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
-        }
262
-    }
259
+		} else {
260
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
+		}
262
+	}
263 263
 
264
-    public static function page_preview() {
264
+	public static function page_preview() {
265 265
 		$params = FrmForm::list_page_params();
266
-        if ( ! $params['form'] ) {
267
-            return;
268
-        }
269
-
270
-        $form = FrmForm::getOne( $params['form'] );
271
-        if ( ! $form ) {
272
-            return;
273
-        }
274
-        return self::show_form( $form->id, '', true, true );
275
-    }
276
-
277
-    public static function preview() {
278
-        do_action( 'frm_wp' );
279
-
280
-        global $frm_vars;
281
-        $frm_vars['preview'] = true;
282
-
283
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
-            global $wp;
285
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
266
+		if ( ! $params['form'] ) {
267
+			return;
268
+		}
269
+
270
+		$form = FrmForm::getOne( $params['form'] );
271
+		if ( ! $form ) {
272
+			return;
273
+		}
274
+		return self::show_form( $form->id, '', true, true );
275
+	}
276
+
277
+	public static function preview() {
278
+		do_action( 'frm_wp' );
279
+
280
+		global $frm_vars;
281
+		$frm_vars['preview'] = true;
282
+
283
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
+			global $wp;
285
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
286 286
 			include_once( $root . '/wp-config.php' );
287
-            $wp->init();
288
-            $wp->register_globals();
289
-        }
287
+			$wp->init();
288
+			$wp->register_globals();
289
+		}
290 290
 
291 291
 		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
292 292
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
299 299
 		if ( empty( $form ) ) {
300 300
 			$form = FrmForm::getAll( array(), '', 1 );
301
-        }
301
+		}
302 302
 
303 303
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
304
-        wp_die();
305
-    }
304
+		wp_die();
305
+	}
306 306
 
307 307
 	public static function register_pro_scripts() {
308 308
 		_deprecated_function( __FUNCTION__, '2.03', 'FrmProEntriesController::register_scripts' );
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 	}
313 313
 
314
-    public static function untrash() {
314
+	public static function untrash() {
315 315
 		self::change_form_status( 'untrash' );
316
-    }
316
+	}
317 317
 
318 318
 	public static function bulk_untrash( $ids ) {
319
-        FrmAppHelper::permission_check('frm_edit_forms');
319
+		FrmAppHelper::permission_check('frm_edit_forms');
320 320
 
321
-        $count = FrmForm::set_status( $ids, 'published' );
321
+		$count = FrmForm::set_status( $ids, 'published' );
322 322
 
323
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
-        return $message;
325
-    }
323
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
+		return $message;
325
+	}
326 326
 
327
-    public static function trash() {
327
+	public static function trash() {
328 328
 		self::change_form_status( 'trash' );
329
-    }
329
+	}
330 330
 
331 331
 	/**
332 332
 	 * @param string $status
@@ -364,68 +364,68 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 
366 366
 	public static function bulk_trash( $ids ) {
367
-        FrmAppHelper::permission_check('frm_delete_forms');
367
+		FrmAppHelper::permission_check('frm_delete_forms');
368 368
 
369
-        $count = 0;
370
-        foreach ( $ids as $id ) {
371
-            if ( FrmForm::trash( $id ) ) {
372
-                $count++;
373
-            }
374
-        }
369
+		$count = 0;
370
+		foreach ( $ids as $id ) {
371
+			if ( FrmForm::trash( $id ) ) {
372
+				$count++;
373
+			}
374
+		}
375 375
 
376
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
376
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
377 377
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
378 378
 
379
-        return $message;
380
-    }
379
+		return $message;
380
+	}
381 381
 
382
-    public static function destroy() {
383
-        FrmAppHelper::permission_check('frm_delete_forms');
382
+	public static function destroy() {
383
+		FrmAppHelper::permission_check('frm_delete_forms');
384 384
 
385 385
 		$params = FrmForm::list_page_params();
386 386
 
387
-        //check nonce url
388
-        check_admin_referer('destroy_form_' . $params['id']);
387
+		//check nonce url
388
+		check_admin_referer('destroy_form_' . $params['id']);
389 389
 
390
-        $count = 0;
391
-        if ( FrmForm::destroy( $params['id'] ) ) {
392
-            $count++;
393
-        }
390
+		$count = 0;
391
+		if ( FrmForm::destroy( $params['id'] ) ) {
392
+			$count++;
393
+		}
394 394
 
395
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
395
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
396 396
 
397 397
 		self::display_forms_list( $params, $message );
398
-    }
398
+	}
399 399
 
400 400
 	public static function bulk_destroy( $ids ) {
401
-        FrmAppHelper::permission_check('frm_delete_forms');
401
+		FrmAppHelper::permission_check('frm_delete_forms');
402 402
 
403
-        $count = 0;
404
-        foreach ( $ids as $id ) {
405
-            $d = FrmForm::destroy( $id );
406
-            if ( $d ) {
407
-                $count++;
408
-            }
409
-        }
403
+		$count = 0;
404
+		foreach ( $ids as $id ) {
405
+			$d = FrmForm::destroy( $id );
406
+			if ( $d ) {
407
+				$count++;
408
+			}
409
+		}
410 410
 
411
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
411
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412 412
 
413
-        return $message;
414
-    }
413
+		return $message;
414
+	}
415 415
 
416
-    private static function delete_all() {
417
-        //check nonce url
418
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
419
-        if ( $permission_error !== false ) {
416
+	private static function delete_all() {
417
+		//check nonce url
418
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
419
+		if ( $permission_error !== false ) {
420 420
 			self::display_forms_list( array(), '', array( $permission_error ) );
421
-            return;
422
-        }
421
+			return;
422
+		}
423 423
 
424 424
 		$count = FrmForm::scheduled_delete( time() );
425
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
425
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
426 426
 
427 427
 		self::display_forms_list( array(), $message );
428
-    }
428
+	}
429 429
 
430 430
 	public static function scheduled_delete( $delete_timestamp = '' ) {
431 431
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 	}
434 434
 
435 435
 	/**
436
-	* Inserts Formidable button
437
-	* Hook exists since 2.5.0
438
-	*
439
-	* @since 2.0.15
440
-	*/
436
+	 * Inserts Formidable button
437
+	 * Hook exists since 2.5.0
438
+	 *
439
+	 * @since 2.0.15
440
+	 */
441 441
 	public static function insert_form_button() {
442 442
 		if ( current_user_can('frm_view_forms') ) {
443 443
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -448,49 +448,49 @@  discard block
 block discarded – undo
448 448
 		}
449 449
 	}
450 450
 
451
-    public static function insert_form_popup() {
451
+	public static function insert_form_popup() {
452 452
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
453 453
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
454
-            return;
455
-        }
454
+			return;
455
+		}
456 456
 
457
-        FrmAppHelper::load_admin_wide_js();
457
+		FrmAppHelper::load_admin_wide_js();
458 458
 
459
-        $shortcodes = array(
459
+		$shortcodes = array(
460 460
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
461
-        );
461
+		);
462 462
 
463
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
463
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
464 464
 
465 465
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
466
-    }
466
+	}
467 467
 
468
-    public static function get_shortcode_opts() {
468
+	public static function get_shortcode_opts() {
469 469
 		FrmAppHelper::permission_check('frm_view_forms');
470
-        check_ajax_referer( 'frm_ajax', 'nonce' );
470
+		check_ajax_referer( 'frm_ajax', 'nonce' );
471 471
 
472 472
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
473
-        if ( empty($shortcode) ) {
474
-            wp_die();
475
-        }
473
+		if ( empty($shortcode) ) {
474
+			wp_die();
475
+		}
476 476
 
477 477
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
478 478
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
479 479
 
480
-        $form_id = '';
481
-        $opts = array();
480
+		$form_id = '';
481
+		$opts = array();
482 482
 		switch ( $shortcode ) {
483
-            case 'formidable':
484
-                $opts = array(
483
+			case 'formidable':
484
+				$opts = array(
485 485
 					'form_id'       => 'id',
486
-                    //'key' => ',
486
+					//'key' => ',
487 487
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
488 488
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
489 489
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
490
-                );
491
-            break;
492
-        }
493
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
490
+				);
491
+			break;
492
+		}
493
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
494 494
 
495 495
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
496 496
 			// allow other shortcodes to use the required form id option
@@ -500,61 +500,61 @@  discard block
 block discarded – undo
500 500
 
501 501
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
502 502
 
503
-        echo '</div>';
503
+		echo '</div>';
504 504
 
505
-        wp_die();
506
-    }
505
+		wp_die();
506
+	}
507 507
 
508 508
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
509
-        FrmAppHelper::permission_check( 'frm_view_forms' );
509
+		FrmAppHelper::permission_check( 'frm_view_forms' );
510 510
 		if ( ! empty( $deprecated_errors ) ) {
511 511
 			$errors = $deprecated_errors;
512 512
 			_deprecated_argument( 'errors', '2.0.8' );
513 513
 		}
514 514
 
515
-        global $wpdb, $frm_vars;
515
+		global $wpdb, $frm_vars;
516 516
 
517 517
 		if ( empty( $params ) ) {
518 518
 			$params = FrmForm::list_page_params();
519
-        }
519
+		}
520 520
 
521
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
521
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
522 522
 
523
-        $pagenum = $wp_list_table->get_pagenum();
523
+		$pagenum = $wp_list_table->get_pagenum();
524 524
 
525
-        $wp_list_table->prepare_items();
525
+		$wp_list_table->prepare_items();
526 526
 
527
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
528
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
527
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
528
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
529 529
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
530
-            die();
531
-        }
530
+			die();
531
+		}
532 532
 
533 533
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
534
-    }
534
+	}
535 535
 
536 536
 	public static function get_columns( $columns ) {
537
-	    $columns['cb'] = '<input type="checkbox" />';
538
-	    $columns['id'] = 'ID';
537
+		$columns['cb'] = '<input type="checkbox" />';
538
+		$columns['id'] = 'ID';
539 539
 
540
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
540
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
541 541
 
542
-        if ( 'template' == $type ) {
543
-            $columns['name']        = __( 'Template Name', 'formidable' );
544
-            $columns['type']        = __( 'Type', 'formidable' );
545
-            $columns['form_key']    = __( 'Key', 'formidable' );
546
-        } else {
547
-            $columns['name']        = __( 'Form Title', 'formidable' );
548
-            $columns['entries']     = __( 'Entries', 'formidable' );
549
-            $columns['form_key']    = __( 'Key', 'formidable' );
550
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
551
-        }
542
+		if ( 'template' == $type ) {
543
+			$columns['name']        = __( 'Template Name', 'formidable' );
544
+			$columns['type']        = __( 'Type', 'formidable' );
545
+			$columns['form_key']    = __( 'Key', 'formidable' );
546
+		} else {
547
+			$columns['name']        = __( 'Form Title', 'formidable' );
548
+			$columns['entries']     = __( 'Entries', 'formidable' );
549
+			$columns['form_key']    = __( 'Key', 'formidable' );
550
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
551
+		}
552 552
 
553
-        $columns['created_at'] = __( 'Date', 'formidable' );
553
+		$columns['created_at'] = __( 'Date', 'formidable' );
554 554
 
555 555
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
556 556
 
557
-        return $columns;
557
+		return $columns;
558 558
 	}
559 559
 
560 560
 	public static function get_sortable_columns() {
@@ -579,83 +579,83 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	public static function save_per_page( $save, $option, $value ) {
582
-        if ( $option == 'formidable_page_formidable_per_page' ) {
583
-            $save = (int) $value;
584
-        }
585
-        return $save;
586
-    }
582
+		if ( $option == 'formidable_page_formidable_per_page' ) {
583
+			$save = (int) $value;
584
+		}
585
+		return $save;
586
+	}
587 587
 
588 588
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
589
-        global $frm_vars;
589
+		global $frm_vars;
590 590
 
591
-        $form = FrmForm::getOne( $id );
592
-        if ( ! $form ) {
593
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
-        }
591
+		$form = FrmForm::getOne( $id );
592
+		if ( ! $form ) {
593
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
+		}
595 595
 
596
-        if ( $form->parent_form_id ) {
596
+		if ( $form->parent_form_id ) {
597 597
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
598
-        }
598
+		}
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+		$fields = FrmField::get_all_for_form($form->id);
602 602
 
603
-        // Automatically add end section fields if they don't exist (2.0 migration)
604
-        $reset_fields = false;
605
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
603
+		// Automatically add end section fields if they don't exist (2.0 migration)
604
+		$reset_fields = false;
605
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
606 606
 
607
-        if ( $reset_fields ) {
608
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
-        }
607
+		if ( $reset_fields ) {
608
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
+		}
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+		unset($end_section_values, $last_order, $open, $reset_fields);
612 612
 
613 613
 		$args = array( 'parent_form_id' => $form->id );
614
-        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
614
+		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
615 615
 
616
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
-        if ( $form->is_template && $message == $edit_message ) {
618
-            $message = __( 'Template was Successfully Updated', 'formidable' );
619
-        }
616
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
+		if ( $form->is_template && $message == $edit_message ) {
618
+			$message = __( 'Template was Successfully Updated', 'formidable' );
619
+		}
620 620
 
621 621
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
622 622
 
623
-        if ( $form->default_template ) {
624
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
625
-        } else if ( defined('DOING_AJAX') ) {
626
-            wp_die();
627
-        } else if ( $create_link ) {
623
+		if ( $form->default_template ) {
624
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
625
+		} else if ( defined('DOING_AJAX') ) {
626
+			wp_die();
627
+		} else if ( $create_link ) {
628 628
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
629
-        } else {
629
+		} else {
630 630
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
631
-        }
632
-    }
631
+		}
632
+	}
633 633
 
634 634
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
635 635
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
636 636
 
637
-        global $frm_vars;
637
+		global $frm_vars;
638 638
 
639
-        $form = FrmForm::getOne( $id );
639
+		$form = FrmForm::getOne( $id );
640 640
 
641
-        $fields = FrmField::get_all_for_form($id);
642
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
641
+		$fields = FrmField::get_all_for_form($id);
642
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
643 643
 
644
-        if ( isset($values['default_template']) && $values['default_template'] ) {
645
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
646
-        }
644
+		if ( isset($values['default_template']) && $values['default_template'] ) {
645
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
646
+		}
647 647
 
648 648
 		self::clean_submit_html( $values );
649 649
 
650
-        $action_controls = FrmFormActionsController::get_form_actions();
650
+		$action_controls = FrmFormActionsController::get_form_actions();
651 651
 
652
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
652
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
654 654
 
655
-        $styles = apply_filters('frm_get_style_opts', array());
655
+		$styles = apply_filters('frm_get_style_opts', array());
656 656
 
657 657
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
658
-    }
658
+	}
659 659
 
660 660
 	/**
661 661
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -670,11 +670,11 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 	}
672 672
 
673
-    public static function mb_tags_box( $form_id, $class = '' ) {
674
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
675
-        $linked_forms = array();
676
-        $col = 'one';
677
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
673
+	public static function mb_tags_box( $form_id, $class = '' ) {
674
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
675
+		$linked_forms = array();
676
+		$col = 'one';
677
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
678 678
 
679 679
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
680 680
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
683 683
 
684 684
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
685
-    }
685
+	}
686 686
 
687 687
 	/**
688 688
 	 * Get an array of the options to display in the advanced tab
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			''          => '',
724 724
 			'siteurl'   => __( 'Site URL', 'formidable' ),
725 725
 			'sitename'  => __( 'Site Name', 'formidable' ),
726
-        );
726
+		);
727 727
 
728 728
 		if ( ! FrmAppHelper::pro_is_installed() ) {
729 729
 			unset( $entry_shortcodes['post_id'] );
@@ -751,39 +751,39 @@  discard block
 block discarded – undo
751 751
 		return $entry_shortcodes;
752 752
 	}
753 753
 
754
-    // Insert the form class setting into the form
754
+	// Insert the form class setting into the form
755 755
 	public static function form_classes( $form ) {
756
-        if ( isset($form->options['form_class']) ) {
756
+		if ( isset($form->options['form_class']) ) {
757 757
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
758
-        }
759
-    }
758
+		}
759
+	}
760 760
 
761
-    public static function get_email_html() {
761
+	public static function get_email_html() {
762 762
 		FrmAppHelper::permission_check('frm_view_forms');
763
-        check_ajax_referer( 'frm_ajax', 'nonce' );
763
+		check_ajax_referer( 'frm_ajax', 'nonce' );
764 764
 		echo FrmEntriesController::show_entry_shortcode( array(
765 765
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
766
-	        'default_email' => true,
766
+			'default_email' => true,
767 767
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
768
-	    ) );
769
-	    wp_die();
768
+		) );
769
+		wp_die();
770 770
 	}
771 771
 
772
-    public static function filter_content( $content, $form, $entry = false ) {
772
+	public static function filter_content( $content, $form, $entry = false ) {
773 773
 		self::get_entry_by_param( $entry );
774
-        if ( ! $entry ) {
775
-            return $content;
776
-        }
774
+		if ( ! $entry ) {
775
+			return $content;
776
+		}
777 777
 
778
-        if ( is_object( $form ) ) {
779
-            $form = $form->id;
780
-        }
778
+		if ( is_object( $form ) ) {
779
+			$form = $form->id;
780
+		}
781 781
 
782
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
783
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
782
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
783
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
784 784
 
785
-        return $content;
786
-    }
785
+		return $content;
786
+	}
787 787
 
788 788
 	private static function get_entry_by_param( &$entry ) {
789 789
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -795,282 +795,282 @@  discard block
 block discarded – undo
795 795
 		}
796 796
 	}
797 797
 
798
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
799
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
800
-    }
798
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
799
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
800
+	}
801 801
 
802
-    public static function process_bulk_form_actions( $errors ) {
803
-        if ( ! $_REQUEST ) {
804
-            return $errors;
805
-        }
802
+	public static function process_bulk_form_actions( $errors ) {
803
+		if ( ! $_REQUEST ) {
804
+			return $errors;
805
+		}
806 806
 
807 807
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
808
-        if ( $bulkaction == -1 ) {
808
+		if ( $bulkaction == -1 ) {
809 809
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
810
-        }
810
+		}
811 811
 
812
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
813
-            FrmAppHelper::remove_get_action();
812
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
813
+			FrmAppHelper::remove_get_action();
814 814
 
815
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
816
-        }
815
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
816
+		}
817 817
 
818 818
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
819
-        if ( empty( $ids ) ) {
820
-            $errors[] = __( 'No forms were specified', 'formidable' );
821
-            return $errors;
822
-        }
823
-
824
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
825
-        if ( $permission_error !== false ) {
826
-            $errors[] = $permission_error;
827
-            return $errors;
828
-        }
829
-
830
-        if ( ! is_array( $ids ) ) {
831
-            $ids = explode( ',', $ids );
832
-        }
833
-
834
-        switch ( $bulkaction ) {
835
-            case 'delete':
836
-                $message = self::bulk_destroy( $ids );
837
-            break;
838
-            case 'trash':
839
-                $message = self::bulk_trash( $ids );
840
-            break;
841
-            case 'untrash':
842
-                $message = self::bulk_untrash( $ids );
843
-            break;
844
-            case 'create_template':
845
-                $message = self::bulk_create_template( $ids );
846
-            break;
847
-        }
848
-
849
-        if ( isset( $message ) && ! empty( $message ) ) {
819
+		if ( empty( $ids ) ) {
820
+			$errors[] = __( 'No forms were specified', 'formidable' );
821
+			return $errors;
822
+		}
823
+
824
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
825
+		if ( $permission_error !== false ) {
826
+			$errors[] = $permission_error;
827
+			return $errors;
828
+		}
829
+
830
+		if ( ! is_array( $ids ) ) {
831
+			$ids = explode( ',', $ids );
832
+		}
833
+
834
+		switch ( $bulkaction ) {
835
+			case 'delete':
836
+				$message = self::bulk_destroy( $ids );
837
+			break;
838
+			case 'trash':
839
+				$message = self::bulk_trash( $ids );
840
+			break;
841
+			case 'untrash':
842
+				$message = self::bulk_untrash( $ids );
843
+			break;
844
+			case 'create_template':
845
+				$message = self::bulk_create_template( $ids );
846
+			break;
847
+		}
848
+
849
+		if ( isset( $message ) && ! empty( $message ) ) {
850 850
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>';
851
-        }
851
+		}
852 852
 
853
-        return $errors;
854
-    }
853
+		return $errors;
854
+	}
855 855
 
856
-    public static function add_default_templates( $path, $default = true, $template = true ) {
857
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
856
+	public static function add_default_templates( $path, $default = true, $template = true ) {
857
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
858 858
 
859
-        $path = untrailingslashit(trim($path));
859
+		$path = untrailingslashit(trim($path));
860 860
 		$templates = glob( $path . '/*.php' );
861 861
 
862 862
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
863 863
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
864 864
 			$template_query = array( 'form_key' => $filename );
865
-            if ( $template ) {
866
-                $template_query['is_template'] = 1;
867
-            }
868
-            if ( $default ) {
869
-                $template_query['default_template'] = 1;
870
-            }
865
+			if ( $template ) {
866
+				$template_query['is_template'] = 1;
867
+			}
868
+			if ( $default ) {
869
+				$template_query['default_template'] = 1;
870
+			}
871 871
 			$form = FrmForm::getAll( $template_query, '', 1 );
872 872
 
873
-            $values = FrmFormsHelper::setup_new_vars();
874
-            $values['form_key'] = $filename;
875
-            $values['is_template'] = $template;
876
-            $values['status'] = 'published';
877
-            if ( $default ) {
878
-                $values['default_template'] = 1;
879
-            }
880
-
881
-            include( $templates[ $i ] );
882
-
883
-            //get updated form
884
-            if ( isset($form) && ! empty($form) ) {
885
-                $old_id = $form->id;
886
-                $form = FrmForm::getOne($form->id);
887
-            } else {
888
-                $old_id = false;
873
+			$values = FrmFormsHelper::setup_new_vars();
874
+			$values['form_key'] = $filename;
875
+			$values['is_template'] = $template;
876
+			$values['status'] = 'published';
877
+			if ( $default ) {
878
+				$values['default_template'] = 1;
879
+			}
880
+
881
+			include( $templates[ $i ] );
882
+
883
+			//get updated form
884
+			if ( isset($form) && ! empty($form) ) {
885
+				$old_id = $form->id;
886
+				$form = FrmForm::getOne($form->id);
887
+			} else {
888
+				$old_id = false;
889 889
 				$form = FrmForm::getAll( $template_query, '', 1 );
890
-            }
890
+			}
891 891
 
892
-            if ( $form ) {
892
+			if ( $form ) {
893 893
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
894
-            }
895
-        }
896
-    }
894
+			}
895
+		}
896
+	}
897 897
 
898
-    public static function route() {
899
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
900
-        $vars = array();
898
+	public static function route() {
899
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
900
+		$vars = array();
901 901
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
902 902
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
903 903
 
904
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
905
-            $json_vars = json_decode($json_vars, true);
906
-            if ( empty($json_vars) ) {
907
-                // json decoding failed so we should return an error message
904
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
905
+			$json_vars = json_decode($json_vars, true);
906
+			if ( empty($json_vars) ) {
907
+				// json decoding failed so we should return an error message
908 908
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
909
-                if ( 'edit' == $action ) {
910
-                    $action = 'update';
911
-                }
912
-
913
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
914
-            } else {
915
-                $vars = FrmAppHelper::json_to_array($json_vars);
916
-                $action = $vars[ $action ];
909
+				if ( 'edit' == $action ) {
910
+					$action = 'update';
911
+				}
912
+
913
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
914
+			} else {
915
+				$vars = FrmAppHelper::json_to_array($json_vars);
916
+				$action = $vars[ $action ];
917 917
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
918 918
 				$_REQUEST = array_merge( $_REQUEST, $vars );
919 919
 				$_POST = array_merge( $_POST, $_REQUEST );
920
-            }
921
-        } else {
920
+			}
921
+		} else {
922 922
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
923
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
924
-                // override the action for this page
925
-    			$action = 'delete_all';
926
-            }
927
-        }
923
+			if ( isset( $_REQUEST['delete_all'] ) ) {
924
+				// override the action for this page
925
+				$action = 'delete_all';
926
+			}
927
+		}
928 928
 
929 929
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
930
-        FrmAppHelper::trigger_hook_load( 'form' );
931
-
932
-        switch ( $action ) {
933
-            case 'new':
934
-                return self::new_form($vars);
935
-            case 'create':
936
-            case 'edit':
937
-            case 'update':
938
-            case 'duplicate':
939
-            case 'trash':
940
-            case 'untrash':
941
-            case 'destroy':
942
-            case 'delete_all':
943
-            case 'settings':
944
-            case 'update_settings':
930
+		FrmAppHelper::trigger_hook_load( 'form' );
931
+
932
+		switch ( $action ) {
933
+			case 'new':
934
+				return self::new_form($vars);
935
+			case 'create':
936
+			case 'edit':
937
+			case 'update':
938
+			case 'duplicate':
939
+			case 'trash':
940
+			case 'untrash':
941
+			case 'destroy':
942
+			case 'delete_all':
943
+			case 'settings':
944
+			case 'update_settings':
945 945
 				return self::$action( $vars );
946
-            default:
946
+			default:
947 947
 				do_action( 'frm_form_action_' . $action );
948 948
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
949
-                    return;
950
-                }
949
+					return;
950
+				}
951 951
 
952 952
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
953
-                if ( $action == -1 ) {
953
+				if ( $action == -1 ) {
954 954
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
955
-                }
955
+				}
956 956
 
957
-                if ( strpos($action, 'bulk_') === 0 ) {
958
-                    FrmAppHelper::remove_get_action();
959
-                    return self::list_form();
960
-                }
957
+				if ( strpos($action, 'bulk_') === 0 ) {
958
+					FrmAppHelper::remove_get_action();
959
+					return self::list_form();
960
+				}
961 961
 
962
-                return self::display_forms_list();
963
-        }
964
-    }
962
+				return self::display_forms_list();
963
+		}
964
+	}
965 965
 
966
-    public static function json_error( $errors ) {
967
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
968
-        return $errors;
969
-    }
966
+	public static function json_error( $errors ) {
967
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
968
+		return $errors;
969
+	}
970 970
 
971 971
 
972
-    /* FRONT-END FORMS */
973
-    public static function admin_bar_css() {
972
+	/* FRONT-END FORMS */
973
+	public static function admin_bar_css() {
974 974
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
975
-            return;
976
-        }
975
+			return;
976
+		}
977 977
 
978 978
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
979 979
 		FrmAppHelper::load_font_style();
980 980
 	}
981 981
 
982 982
 	public static function admin_bar_configure() {
983
-        global $frm_vars;
984
-        if ( empty($frm_vars['forms_loaded']) ) {
985
-            return;
986
-        }
987
-
988
-        $actions = array();
989
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
990
-            if ( is_object($form) ) {
991
-                $actions[ $form->id ] = $form->name;
992
-            }
993
-            unset($form);
994
-        }
995
-
996
-        if ( empty($actions) ) {
997
-            return;
998
-        }
999
-
1000
-        asort($actions);
1001
-
1002
-        global $wp_admin_bar;
1003
-
1004
-        if ( count($actions) == 1 ) {
1005
-            $wp_admin_bar->add_menu( array(
1006
-                'title' => 'Edit Form',
983
+		global $frm_vars;
984
+		if ( empty($frm_vars['forms_loaded']) ) {
985
+			return;
986
+		}
987
+
988
+		$actions = array();
989
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
990
+			if ( is_object($form) ) {
991
+				$actions[ $form->id ] = $form->name;
992
+			}
993
+			unset($form);
994
+		}
995
+
996
+		if ( empty($actions) ) {
997
+			return;
998
+		}
999
+
1000
+		asort($actions);
1001
+
1002
+		global $wp_admin_bar;
1003
+
1004
+		if ( count($actions) == 1 ) {
1005
+			$wp_admin_bar->add_menu( array(
1006
+				'title' => 'Edit Form',
1007 1007
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
1008
-                'id'    => 'frm-forms',
1009
-            ) );
1010
-        } else {
1011
-            $wp_admin_bar->add_menu( array(
1012
-        		'id'    => 'frm-forms',
1013
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
1008
+				'id'    => 'frm-forms',
1009
+			) );
1010
+		} else {
1011
+			$wp_admin_bar->add_menu( array(
1012
+				'id'    => 'frm-forms',
1013
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
1014 1014
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
1015
-        		'meta'  => array(
1015
+				'meta'  => array(
1016 1016
 					'title' => __( 'Edit Forms', 'formidable' ),
1017
-        		),
1018
-        	) );
1017
+				),
1018
+			) );
1019 1019
 
1020
-        	foreach ( $actions as $form_id => $name ) {
1020
+			foreach ( $actions as $form_id => $name ) {
1021 1021
 
1022
-        		$wp_admin_bar->add_menu( array(
1023
-        			'parent'    => 'frm-forms',
1022
+				$wp_admin_bar->add_menu( array(
1023
+					'parent'    => 'frm-forms',
1024 1024
 					'id'        => 'edit_form_' . $form_id,
1025
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1025
+					'title'     => empty($name) ? __( '(no title)') : $name,
1026 1026
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1027
-        		) );
1028
-        	}
1029
-        }
1030
-    }
1027
+				) );
1028
+			}
1029
+		}
1030
+	}
1031 1031
 
1032
-    //formidable shortcode
1032
+	//formidable shortcode
1033 1033
 	public static function get_form_shortcode( $atts ) {
1034
-        global $frm_vars;
1035
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1036
-            $sc = '[formidable';
1034
+		global $frm_vars;
1035
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1036
+			$sc = '[formidable';
1037 1037
 			if ( ! empty( $atts ) ) {
1038 1038
 				foreach ( $atts as $k => $v ) {
1039 1039
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1040 1040
 				}
1041 1041
 			}
1042 1042
 			return $sc . ']';
1043
-        }
1044
-
1045
-        $shortcode_atts = shortcode_atts( array(
1046
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1047
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1048
-            'exclude_fields' => array(), 'minimize' => false,
1049
-        ), $atts);
1050
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1051
-
1052
-        return self::show_form(
1053
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1054
-            $shortcode_atts['description'], $atts
1055
-        );
1056
-    }
1057
-
1058
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1059
-        if ( empty( $id ) ) {
1060
-            $id = $key;
1061
-        }
1062
-
1063
-        $form = self::maybe_get_form_to_show( $id );
1064
-        if ( ! $form ) {
1065
-            return __( 'Please select a valid form', 'formidable' );
1066
-        }
1043
+		}
1044
+
1045
+		$shortcode_atts = shortcode_atts( array(
1046
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1047
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1048
+			'exclude_fields' => array(), 'minimize' => false,
1049
+		), $atts);
1050
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1051
+
1052
+		return self::show_form(
1053
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1054
+			$shortcode_atts['description'], $atts
1055
+		);
1056
+	}
1057
+
1058
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1059
+		if ( empty( $id ) ) {
1060
+			$id = $key;
1061
+		}
1062
+
1063
+		$form = self::maybe_get_form_to_show( $id );
1064
+		if ( ! $form ) {
1065
+			return __( 'Please select a valid form', 'formidable' );
1066
+		}
1067 1067
 
1068 1068
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1069
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1069
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1070 1070
 
1071
-        $form = apply_filters( 'frm_pre_display_form', $form );
1071
+		$form = apply_filters( 'frm_pre_display_form', $form );
1072 1072
 
1073
-        $frm_settings = FrmAppHelper::get_settings();
1073
+		$frm_settings = FrmAppHelper::get_settings();
1074 1074
 
1075 1075
 		if ( self::is_viewable_draft_form( $form ) ) {
1076 1076
 			// don't show a draft form on a page
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 		}
1092 1092
 
1093 1093
 		return $form;
1094
-    }
1094
+	}
1095 1095
 
1096 1096
 	private static function maybe_get_form_to_show( $id ) {
1097 1097
 		$form = false;
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1121 1121
 	}
1122 1122
 
1123
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1124
-        ob_start();
1123
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1124
+		ob_start();
1125 1125
 
1126
-        self::get_form_contents( $form, $title, $description, $atts );
1126
+		self::get_form_contents( $form, $title, $description, $atts );
1127 1127
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1128 1128
 
1129
-        $contents = ob_get_contents();
1130
-        ob_end_clean();
1129
+		$contents = ob_get_contents();
1130
+		ob_end_clean();
1131 1131
 
1132 1132
 		self::maybe_minimize_form( $atts, $contents );
1133 1133
 
1134
-        return $contents;
1135
-    }
1134
+		return $contents;
1135
+	}
1136 1136
 
1137 1137
 	public static function enqueue_scripts( $params ) {
1138 1138
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1328,10 +1328,10 @@  discard block
 block discarded – undo
1328 1328
 	}
1329 1329
 
1330 1330
 	public static function defer_script_loading( $tag, $handle ) {
1331
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1332
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1331
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1332
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1333 1333
 		}
1334
-	    return $tag;
1334
+		return $tag;
1335 1335
 	}
1336 1336
 
1337 1337
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.