Completed
Push — master ( a84b5d...065334 )
by Jamie
03:44
created
classes/views/frm-settings/license_box.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1
-<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>">
1
+<div class="general_settings metabox-holder tabs-panel frm_license_box <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>">
2 2
 <?php if ( ! is_multisite() || is_super_admin() ) { ?>
3 3
     <div class="postbox">
4 4
         <div class="inside">
5
-			<p class="alignright"><?php printf( __( '%1$sClick here%2$s to get it now', 'formidable' ), '<a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com' ) ) . '">', '</a>' ) ?> &#187;</p>
5
+			<p class="alignright"><?php printf( __( '%1$sClick here%2$s to get it now', 'formidable' ), '<a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com' ) ) . '">', '</a>' ) ?> &#187;</p>
6 6
 			<p><?php _e( 'Ready to take your forms to the next level?<br/>Formidable Forms will help you create views, manage data, and get reports.', 'formidable' ) ?></p>
7 7
 
8 8
 			<p>Already signed up? <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/knowledgebase/install-formidable-forms/' ) ) ?>" target="_blank"><?php _e( 'Click here', 'formidable' ) ?></a> to get installation instructions and download the pro version.</p>
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +360 added lines, -360 removed lines patch added patch discarded remove patch
@@ -2,200 +2,200 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11
-            $frm_settings = FrmAppHelper::get_settings();
11
+			$frm_settings = FrmAppHelper::get_settings();
12 12
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars, $wpdb;
68
+		global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
71
+		$columns[ $form_id .'_id' ] = 'ID';
72 72
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74
-        if ( ! $form_id ) {
75
-            return $columns;
76
-        }
74
+		if ( ! $form_id ) {
75
+			return $columns;
76
+		}
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79 79
 
80
-        foreach ( $form_cols as $form_col ) {
80
+		foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
-                continue;
83
-            }
82
+				continue;
83
+			}
84 84
 
85
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86 86
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87 87
 
88
-                if ( $sub_form_cols ) {
89
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
88
+				if ( $sub_form_cols ) {
89
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
92
-                            continue;
93
-                        }
91
+							unset( $sub_form_cols[ $k ] );
92
+							continue;
93
+						}
94 94
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
96
-                    }
97
-                }
98
-                unset($sub_form_cols);
99
-            } else {
100
-                $col_id = $form_col->field_key;
101
-                if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
103
-                }
104
-
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
111
-
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
115
-
116
-        $frm_vars['cols'] = $columns;
95
+						unset($sub_form_col);
96
+					}
97
+				}
98
+				unset($sub_form_cols);
99
+			} else {
100
+				$col_id = $form_col->field_key;
101
+				if ( $form_col->form_id != $form_id ) {
102
+					$col_id .= '-_-form'. $form_col->form_id;
103
+				}
104
+
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
+					$columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
+				}
108
+				$columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
+			}
110
+		}
111
+
112
+		$columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
+		$columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
+		$columns[ $form_id .'_ip' ] = 'IP';
115
+
116
+		$frm_vars['cols'] = $columns;
117 117
 
118 118
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
119 119
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
120 120
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
121
-        }
121
+		}
122 122
 
123
-        return $columns;
124
-    }
123
+		return $columns;
124
+	}
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127
-        $frm_settings = FrmAppHelper::get_settings();
128
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
129
-            return $check;
130
-        }
127
+		$frm_settings = FrmAppHelper::get_settings();
128
+		if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
129
+			return $check;
130
+		}
131 131
 
132 132
 		if ( empty( $prev_value ) ) {
133 133
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
134 134
 		}
135 135
 
136
-        global $frm_vars;
137
-        //add a check so we don't create a loop
138
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
136
+		global $frm_vars;
137
+		//add a check so we don't create a loop
138
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
139 139
 
140
-        return $check;
141
-    }
140
+		return $check;
141
+	}
142 142
 
143
-    //add hidden columns back from other forms
143
+	//add hidden columns back from other forms
144 144
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
145
-        $frm_settings = FrmAppHelper::get_settings();
146
-
147
-        $sanitized = sanitize_title($frm_settings->menu);
148
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
149
-            return;
150
-        }
151
-
152
-        global $frm_vars;
153
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
154
-            return; //don't continue if there's no previous value
155
-        }
156
-
157
-        foreach ( $meta_value as $mk => $mv ) {
158
-            //remove blank values
159
-            if ( empty( $mv )  ) {
160
-                unset( $meta_value[ $mk ] );
161
-            }
162
-        }
163
-
164
-        $cur_form_prefix = reset($meta_value);
165
-        $cur_form_prefix = explode('_', $cur_form_prefix);
166
-        $cur_form_prefix = $cur_form_prefix[0];
167
-        $save = false;
168
-
169
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
145
+		$frm_settings = FrmAppHelper::get_settings();
146
+
147
+		$sanitized = sanitize_title($frm_settings->menu);
148
+		if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
149
+			return;
150
+		}
151
+
152
+		global $frm_vars;
153
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
154
+			return; //don't continue if there's no previous value
155
+		}
156
+
157
+		foreach ( $meta_value as $mk => $mv ) {
158
+			//remove blank values
159
+			if ( empty( $mv )  ) {
160
+				unset( $meta_value[ $mk ] );
161
+			}
162
+		}
163
+
164
+		$cur_form_prefix = reset($meta_value);
165
+		$cur_form_prefix = explode('_', $cur_form_prefix);
166
+		$cur_form_prefix = $cur_form_prefix[0];
167
+		$save = false;
168
+
169
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
170 170
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
171
-                //don't add blank cols or process included cols
172
-                continue;
173
-            }
171
+				//don't add blank cols or process included cols
172
+				continue;
173
+			}
174 174
 
175 175
 			$form_prefix = explode( '_', $prev_hidden );
176
-            $form_prefix = $form_prefix[0];
177
-            if ( $form_prefix == $cur_form_prefix ) {
178
-                //don't add back columns that are meant to be hidden
179
-                continue;
180
-            }
176
+			$form_prefix = $form_prefix[0];
177
+			if ( $form_prefix == $cur_form_prefix ) {
178
+				//don't add back columns that are meant to be hidden
179
+				continue;
180
+			}
181 181
 
182
-            $meta_value[] = $prev_hidden;
183
-            $save = true;
184
-            unset($form_prefix);
185
-        }
182
+			$meta_value[] = $prev_hidden;
183
+			$save = true;
184
+			unset($form_prefix);
185
+		}
186 186
 
187 187
 		if ( $save ) {
188
-            $user = wp_get_current_user();
189
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
190
-        }
191
-    }
188
+			$user = wp_get_current_user();
189
+			update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
190
+		}
191
+	}
192 192
 
193 193
 	public static function save_per_page( $save, $option, $value ) {
194
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
195
-            $save = (int) $value;
196
-        }
197
-        return $save;
198
-    }
194
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
195
+			$save = (int) $value;
196
+		}
197
+		return $save;
198
+	}
199 199
 
200 200
 	public static function sortable_columns() {
201 201
 		$form_id = FrmForm::get_current_form_id();
@@ -221,226 +221,226 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	public static function hidden_columns( $result ) {
224
-        global $frm_vars;
224
+		global $frm_vars;
225 225
 
226 226
 		$form_id = FrmForm::get_current_form_id();
227 227
 
228
-        $return = false;
229
-        foreach ( (array) $result as $r ) {
230
-            if ( ! empty( $r ) ) {
231
-                $form_prefix = explode( '_', $r );
232
-                $form_prefix = $form_prefix[0];
228
+		$return = false;
229
+		foreach ( (array) $result as $r ) {
230
+			if ( ! empty( $r ) ) {
231
+				$form_prefix = explode( '_', $r );
232
+				$form_prefix = $form_prefix[0];
233 233
 
234
-                if ( (int) $form_prefix == (int) $form_id ) {
235
-                    $return = true;
236
-                    break;
237
-                }
234
+				if ( (int) $form_prefix == (int) $form_id ) {
235
+					$return = true;
236
+					break;
237
+				}
238 238
 
239
-                unset($form_prefix);
240
-            }
241
-        }
239
+				unset($form_prefix);
240
+			}
241
+		}
242 242
 
243
-        if ( $return ) {
243
+		if ( $return ) {
244 244
 			return $result;
245 245
 		}
246 246
 
247
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
248
-        $max_columns = 8;
249
-        if ( $i <= $max_columns ) {
247
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
248
+		$max_columns = 8;
249
+		if ( $i <= $max_columns ) {
250 250
 			return $result;
251 251
 		}
252 252
 
253
-        global $frm_vars;
254
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
255
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
256
-        }
253
+		global $frm_vars;
254
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
255
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
256
+		}
257 257
 
258
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
259
-            $result = $frm_vars['current_form']->options['hidden_cols'];
260
-        } else {
261
-            $cols = $frm_vars['cols'];
262
-            $cols = array_reverse($cols, true);
258
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
259
+			$result = $frm_vars['current_form']->options['hidden_cols'];
260
+		} else {
261
+			$cols = $frm_vars['cols'];
262
+			$cols = array_reverse($cols, true);
263 263
 
264
-            $result[] = $form_id .'_id';
265
-            $i--;
264
+			$result[] = $form_id .'_id';
265
+			$i--;
266 266
 
267
-            $result[] = $form_id .'_item_key';
268
-            $i--;
267
+			$result[] = $form_id .'_item_key';
268
+			$i--;
269 269
 
270 270
 			foreach ( $cols as $col_key => $col ) {
271
-                if ( $i > $max_columns ) {
271
+				if ( $i > $max_columns ) {
272 272
 					$result[] = $col_key;
273 273
 				}
274
-                //remove some columns by default
275
-                $i--;
276
-                unset($col_key, $col);
277
-            }
278
-        }
274
+				//remove some columns by default
275
+				$i--;
276
+				unset($col_key, $col);
277
+			}
278
+		}
279 279
 
280
-        return $result;
281
-    }
280
+		return $result;
281
+	}
282 282
 
283 283
 	public static function display_list( $message = '', $errors = array() ) {
284
-        global $wpdb, $frm_vars;
284
+		global $wpdb, $frm_vars;
285 285
 
286 286
 		$form = FrmForm::get_current_form();
287 287
 		$params = FrmForm::get_admin_params( $form );
288 288
 
289
-        if ( $form ) {
290
-            $params['form'] = $form->id;
291
-            $frm_vars['current_form'] = $form;
289
+		if ( $form ) {
290
+			$params['form'] = $form->id;
291
+			$frm_vars['current_form'] = $form;
292 292
 
293
-	        if ( 'trash' == $form->status ) {
294
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
295
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
296
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
297
-	            unset( $time_to_delete, $delete_timestamp );
298
-	        }
293
+			if ( 'trash' == $form->status ) {
294
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
295
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
296
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
297
+				unset( $time_to_delete, $delete_timestamp );
298
+			}
299 299
 		}
300 300
 
301
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
301
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
302 302
 
303
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
303
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
304 304
 
305
-        $pagenum = $wp_list_table->get_pagenum();
305
+		$pagenum = $wp_list_table->get_pagenum();
306 306
 
307
-        $wp_list_table->prepare_items();
307
+		$wp_list_table->prepare_items();
308 308
 
309
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
310
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
309
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
310
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
311 311
 			$url = add_query_arg( 'paged', $total_pages );
312
-            if ( headers_sent() ) {
313
-                echo FrmAppHelper::js_redirect($url);
314
-            } else {
315
-                wp_redirect( esc_url_raw( $url ) );
316
-            }
317
-            die();
318
-        }
319
-
320
-        if ( empty($message) && isset($_GET['import-message']) ) {
321
-            $message = __( 'Your import is complete', 'formidable' );
322
-        }
323
-
324
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
325
-    }
326
-
327
-    /* Back End CRUD */
312
+			if ( headers_sent() ) {
313
+				echo FrmAppHelper::js_redirect($url);
314
+			} else {
315
+				wp_redirect( esc_url_raw( $url ) );
316
+			}
317
+			die();
318
+		}
319
+
320
+		if ( empty($message) && isset($_GET['import-message']) ) {
321
+			$message = __( 'Your import is complete', 'formidable' );
322
+		}
323
+
324
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
325
+	}
326
+
327
+	/* Back End CRUD */
328 328
 	public static function show( $id = 0 ) {
329
-        FrmAppHelper::permission_check('frm_view_entries');
329
+		FrmAppHelper::permission_check('frm_view_entries');
330 330
 
331
-        if ( ! $id ) {
331
+		if ( ! $id ) {
332 332
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
333 333
 
334
-            if ( ! $id ) {
334
+			if ( ! $id ) {
335 335
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
336
-            }
337
-        }
336
+			}
337
+		}
338 338
 
339
-        $entry = FrmEntry::getOne($id, true);
339
+		$entry = FrmEntry::getOne($id, true);
340 340
 
341
-        $data = maybe_unserialize($entry->description);
341
+		$data = maybe_unserialize($entry->description);
342 342
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
343 343
 			$data = array( 'referrer' => $data );
344 344
 		}
345 345
 
346 346
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
347
-        $to_emails = array();
347
+		$to_emails = array();
348 348
 
349
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
350
-    }
349
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
350
+	}
351 351
 
352
-    public static function destroy() {
353
-        FrmAppHelper::permission_check('frm_delete_entries');
352
+	public static function destroy() {
353
+		FrmAppHelper::permission_check('frm_delete_entries');
354 354
 
355 355
 		$params = FrmForm::get_admin_params();
356 356
 
357
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
358
-            //unlink entry from post
359
-            global $wpdb;
357
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
358
+			//unlink entry from post
359
+			global $wpdb;
360 360
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
361
-        }
361
+		}
362 362
 
363
-        $message = '';
364
-        if ( FrmEntry::destroy( $params['id'] ) ) {
365
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
366
-        }
363
+		$message = '';
364
+		if ( FrmEntry::destroy( $params['id'] ) ) {
365
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
366
+		}
367 367
 
368
-        self::display_list( $message );
369
-    }
368
+		self::display_list( $message );
369
+	}
370 370
 
371
-    public static function destroy_all() {
372
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
373
-            $frm_settings = FrmAppHelper::get_settings();
374
-            wp_die( $frm_settings->admin_permission );
375
-        }
371
+	public static function destroy_all() {
372
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
373
+			$frm_settings = FrmAppHelper::get_settings();
374
+			wp_die( $frm_settings->admin_permission );
375
+		}
376 376
 
377
-        global $wpdb;
377
+		global $wpdb;
378 378
 		$params = FrmForm::get_admin_params();
379
-        $message = '';
380
-        $errors = array();
381
-        $form_id = (int) $params['form'];
379
+		$message = '';
380
+		$errors = array();
381
+		$form_id = (int) $params['form'];
382 382
 
383
-        if ( $form_id ) {
384
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
383
+		if ( $form_id ) {
384
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
385 385
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
386 386
 
387
-            if ( $action ) {
388
-                // this action takes a while, so only trigger it if there are posts to delete
389
-                foreach ( $entry_ids as $entry_id ) {
390
-                    do_action( 'frm_before_destroy_entry', $entry_id );
391
-                    unset( $entry_id );
392
-                }
393
-            }
394
-
395
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
396
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
397
-            if ( $results ) {
398
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
399
-            }
400
-        } else {
401
-            $errors = __( 'No entries were specified', 'formidable' );
402
-        }
403
-
404
-        self::display_list( $message, $errors );
405
-    }
406
-
407
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
408
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
409
-        return FrmFormsController::show_form( $id, $key, $title, $description );
410
-    }
411
-
412
-    public static function get_form( $filename, $form, $title, $description ) {
413
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
414
-        return FrmFormsController::get_form( $form, $title, $description );
415
-    }
416
-
417
-    public static function process_entry( $errors = '', $ajax = false ) {
387
+			if ( $action ) {
388
+				// this action takes a while, so only trigger it if there are posts to delete
389
+				foreach ( $entry_ids as $entry_id ) {
390
+					do_action( 'frm_before_destroy_entry', $entry_id );
391
+					unset( $entry_id );
392
+				}
393
+			}
394
+
395
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
396
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
397
+			if ( $results ) {
398
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
399
+			}
400
+		} else {
401
+			$errors = __( 'No entries were specified', 'formidable' );
402
+		}
403
+
404
+		self::display_list( $message, $errors );
405
+	}
406
+
407
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
408
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
409
+		return FrmFormsController::show_form( $id, $key, $title, $description );
410
+	}
411
+
412
+	public static function get_form( $filename, $form, $title, $description ) {
413
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
414
+		return FrmFormsController::get_form( $form, $title, $description );
415
+	}
416
+
417
+	public static function process_entry( $errors = '', $ajax = false ) {
418 418
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
419 419
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
420
-            return;
421
-        }
420
+			return;
421
+		}
422 422
 
423
-        global $frm_vars;
423
+		global $frm_vars;
424 424
 
425 425
 		$form = FrmForm::getOne( $form_id );
426
-        if ( ! $form ) {
427
-            return;
428
-        }
426
+		if ( ! $form ) {
427
+			return;
428
+		}
429 429
 
430 430
 		$params = FrmForm::get_params( $form );
431 431
 
432
-        if ( ! isset( $frm_vars['form_params'] ) ) {
433
-            $frm_vars['form_params'] = array();
434
-        }
432
+		if ( ! isset( $frm_vars['form_params'] ) ) {
433
+			$frm_vars['form_params'] = array();
434
+		}
435 435
 		$frm_vars['form_params'][ $form->id ] = $params;
436 436
 
437 437
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
438
-            return;
439
-        }
438
+			return;
439
+		}
440 440
 
441
-        if ( $errors == '' ) {
441
+		if ( $errors == '' ) {
442 442
 			$errors = FrmEntryValidate::validate( $_POST );
443
-        }
443
+		}
444 444
 
445 445
 		/**
446 446
 		 * Use this filter to add trigger actions and add errors after
@@ -451,102 +451,102 @@  discard block
 block discarded – undo
451 451
 
452 452
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
453 453
 
454
-        if ( empty( $errors ) ) {
454
+		if ( empty( $errors ) ) {
455 455
 			$_POST['frm_skip_cookie'] = 1;
456
-            if ( $params['action'] == 'create' ) {
456
+			if ( $params['action'] == 'create' ) {
457 457
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
458 458
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
459
-                }
460
-            }
459
+				}
460
+			}
461 461
 
462
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
462
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
463 463
 			unset( $_POST['frm_skip_cookie'] );
464
-        }
465
-    }
466
-
467
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
468
-        self::_delete_entry( $atts['id'], $form );
469
-        return $url;
470
-    }
471
-
472
-    //Delete entry if not redirected
473
-    public static function delete_entry_after_save( $atts ) {
474
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
475
-    }
476
-
477
-    private static function _delete_entry( $entry_id, $form ) {
478
-        if ( ! $form ) {
479
-            return;
480
-        }
481
-
482
-        $form->options = maybe_unserialize( $form->options );
483
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
484
-            FrmEntry::destroy( $entry_id );
485
-        }
486
-    }
464
+		}
465
+	}
466
+
467
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
468
+		self::_delete_entry( $atts['id'], $form );
469
+		return $url;
470
+	}
471
+
472
+	//Delete entry if not redirected
473
+	public static function delete_entry_after_save( $atts ) {
474
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
475
+	}
476
+
477
+	private static function _delete_entry( $entry_id, $form ) {
478
+		if ( ! $form ) {
479
+			return;
480
+		}
481
+
482
+		$form->options = maybe_unserialize( $form->options );
483
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
484
+			FrmEntry::destroy( $entry_id );
485
+		}
486
+	}
487 487
 
488 488
 	public static function show_entry_shortcode( $atts ) {
489 489
 		return FrmEntryFormat::show_entry( $atts );
490 490
 	}
491 491
 
492
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
493
-        $field = FrmField::getOne($meta->field_id);
494
-        if ( ! $field ) {
495
-            return $value;
496
-        }
492
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
493
+		$field = FrmField::getOne($meta->field_id);
494
+		if ( ! $field ) {
495
+			return $value;
496
+		}
497 497
 
498
-        $value = self::filter_display_value($value, $field, $atts);
499
-        return $value;
500
-    }
498
+		$value = self::filter_display_value($value, $field, $atts);
499
+		return $value;
500
+	}
501 501
 
502 502
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
503
-        $plain_text = add_filter('frm_plain_text_email', true);
503
+		$plain_text = add_filter('frm_plain_text_email', true);
504 504
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
505 505
 
506
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
507
-            return $value;
508
-        }
506
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
507
+			return $value;
508
+		}
509 509
 
510
-        return self::filter_display_value($value, $field, $atts);
511
-    }
510
+		return self::filter_display_value($value, $field, $atts);
511
+	}
512 512
 
513
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
514
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
513
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
514
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
515 515
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
516
-            return $value;
517
-        }
518
-
519
-        $f_values = $f_labels = array();
520
-
521
-        foreach ( $field->options as $opt_key => $opt ) {
522
-            if ( ! is_array($opt) ) {
523
-                continue;
524
-            }
525
-
526
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
527
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
528
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
529
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
530
-            }
531
-            unset($opt_key, $opt);
532
-        }
533
-
534
-        if ( ! empty($f_values) ) {
535
-            foreach ( (array) $value as $v_key => $val ) {
536
-                if ( in_array($val, $f_values) ) {
537
-                    $opt = array_search($val, $f_values);
538
-                    if ( is_array($value) ) {
539
-                        $value[ $v_key ] = $f_labels[ $opt ];
540
-                    } else {
541
-                        $value = $f_labels[ $opt ];
542
-                    }
543
-                }
544
-                unset($v_key, $val);
545
-            }
546
-        }
547
-
548
-        return $value;
549
-    }
516
+			return $value;
517
+		}
518
+
519
+		$f_values = $f_labels = array();
520
+
521
+		foreach ( $field->options as $opt_key => $opt ) {
522
+			if ( ! is_array($opt) ) {
523
+				continue;
524
+			}
525
+
526
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
527
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
528
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
529
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
530
+			}
531
+			unset($opt_key, $opt);
532
+		}
533
+
534
+		if ( ! empty($f_values) ) {
535
+			foreach ( (array) $value as $v_key => $val ) {
536
+				if ( in_array($val, $f_values) ) {
537
+					$opt = array_search($val, $f_values);
538
+					if ( is_array($value) ) {
539
+						$value[ $v_key ] = $f_labels[ $opt ];
540
+					} else {
541
+						$value = $f_labels[ $opt ];
542
+					}
543
+				}
544
+				unset($v_key, $val);
545
+			}
546
+		}
547
+
548
+		return $value;
549
+	}
550 550
 
551 551
 	public static function get_params( $form = null ) {
552 552
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
 	}
555 555
 
556 556
 	public static function entry_sidebar( $entry ) {
557
-        $data = maybe_unserialize($entry->description);
558
-        $date_format = get_option('date_format');
559
-        $time_format = get_option('time_format');
557
+		$data = maybe_unserialize($entry->description);
558
+		$date_format = get_option('date_format');
559
+		$time_format = get_option('time_format');
560 560
 		if ( isset( $data['browser'] ) ) {
561 561
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
562 562
 		}
563 563
 
564
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
565
-    }
564
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
565
+	}
566 566
 }
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
             $frm_settings = FrmAppHelper::get_settings();
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
         $screen->add_help_tab( array(
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55
-			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
55
+			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61
-			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
61
+			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62 62
     	);
63 63
 
64 64
         return $help;
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
         global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+        $columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
         if ( ! $form_id ) {
75 75
             return $columns;
76 76
         }
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
79 79
 
80 80
         foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
                 if ( $sub_form_cols ) {
89 89
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
91
+                            unset( $sub_form_cols[$k] );
92 92
                             continue;
93 93
                         }
94
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
94
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
+                        unset( $sub_form_col );
96 96
                     }
97 97
                 }
98
-                unset($sub_form_cols);
98
+                unset( $sub_form_cols );
99 99
             } else {
100 100
                 $col_id = $form_col->field_key;
101 101
                 if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
102
+                    $col_id .= '-_-form' . $form_col->form_id;
103 103
                 }
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
105
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
106
+                    $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
107 107
                 }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+                $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
109 109
             }
110 110
         }
111 111
 
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
112
+        $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
113
+        $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
114
+        $columns[$form_id . '_ip'] = 'IP';
115 115
 
116 116
         $frm_vars['cols'] = $columns;
117 117
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
         $frm_settings = FrmAppHelper::get_settings();
128
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128
+        if ( $meta_key != 'manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
129 129
             return $check;
130 130
         }
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
         global $frm_vars;
137 137
         //add a check so we don't create a loop
138
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
138
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
139 139
 
140 140
         return $check;
141 141
     }
@@ -144,25 +144,25 @@  discard block
 block discarded – undo
144 144
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
145 145
         $frm_settings = FrmAppHelper::get_settings();
146 146
 
147
-        $sanitized = sanitize_title($frm_settings->menu);
148
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
147
+        $sanitized = sanitize_title( $frm_settings->menu );
148
+        if ( $meta_key != 'manage' . $sanitized . '_page_formidable-entriescolumnshidden' ) {
149 149
             return;
150 150
         }
151 151
 
152 152
         global $frm_vars;
153
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
154 154
             return; //don't continue if there's no previous value
155 155
         }
156 156
 
157 157
         foreach ( $meta_value as $mk => $mv ) {
158 158
             //remove blank values
159
-            if ( empty( $mv )  ) {
160
-                unset( $meta_value[ $mk ] );
159
+            if ( empty( $mv ) ) {
160
+                unset( $meta_value[$mk] );
161 161
             }
162 162
         }
163 163
 
164
-        $cur_form_prefix = reset($meta_value);
165
-        $cur_form_prefix = explode('_', $cur_form_prefix);
164
+        $cur_form_prefix = reset( $meta_value );
165
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
166 166
         $cur_form_prefix = $cur_form_prefix[0];
167 167
         $save = false;
168 168
 
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 
182 182
             $meta_value[] = $prev_hidden;
183 183
             $save = true;
184
-            unset($form_prefix);
184
+            unset( $form_prefix );
185 185
         }
186 186
 
187 187
 		if ( $save ) {
188 188
             $user = wp_get_current_user();
189
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
+            update_user_option( $user->ID, 'manage' . $sanitized . '_page_formidable-entriescolumnshidden', $meta_value, true );
190 190
         }
191 191
     }
192 192
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		foreach ( $fields as $field ) {
214 214
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
215 215
 				// Can't sort on checkboxes because they are stored serialized, or post fields
216
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
216
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
217 217
 			}
218 218
 		}
219 219
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                     break;
237 237
                 }
238 238
 
239
-                unset($form_prefix);
239
+                unset( $form_prefix );
240 240
             }
241 241
         }
242 242
 
@@ -244,36 +244,36 @@  discard block
 block discarded – undo
244 244
 			return $result;
245 245
 		}
246 246
 
247
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
247
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
248 248
         $max_columns = 8;
249 249
         if ( $i <= $max_columns ) {
250 250
 			return $result;
251 251
 		}
252 252
 
253 253
         global $frm_vars;
254
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
255
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
254
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
255
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
256 256
         }
257 257
 
258
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
258
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
259 259
             $result = $frm_vars['current_form']->options['hidden_cols'];
260 260
         } else {
261 261
             $cols = $frm_vars['cols'];
262
-            $cols = array_reverse($cols, true);
262
+            $cols = array_reverse( $cols, true );
263 263
 
264
-            $result[] = $form_id .'_id';
265
-            $i--;
264
+            $result[] = $form_id . '_id';
265
+            $i --;
266 266
 
267
-            $result[] = $form_id .'_item_key';
268
-            $i--;
267
+            $result[] = $form_id . '_item_key';
268
+            $i --;
269 269
 
270 270
 			foreach ( $cols as $col_key => $col ) {
271 271
                 if ( $i > $max_columns ) {
272 272
 					$result[] = $col_key;
273 273
 				}
274 274
                 //remove some columns by default
275
-                $i--;
276
-                unset($col_key, $col);
275
+                $i --;
276
+                unset( $col_key, $col );
277 277
             }
278 278
         }
279 279
 
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
311 311
 			$url = add_query_arg( 'paged', $total_pages );
312 312
             if ( headers_sent() ) {
313
-                echo FrmAppHelper::js_redirect($url);
313
+                echo FrmAppHelper::js_redirect( $url );
314 314
             } else {
315 315
                 wp_redirect( esc_url_raw( $url ) );
316 316
             }
317 317
             die();
318 318
         }
319 319
 
320
-        if ( empty($message) && isset($_GET['import-message']) ) {
320
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
321 321
             $message = __( 'Your import is complete', 'formidable' );
322 322
         }
323 323
 
324
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
324
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
325 325
     }
326 326
 
327 327
     /* Back End CRUD */
328 328
 	public static function show( $id = 0 ) {
329
-        FrmAppHelper::permission_check('frm_view_entries');
329
+        FrmAppHelper::permission_check( 'frm_view_entries' );
330 330
 
331 331
         if ( ! $id ) {
332 332
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
             }
337 337
         }
338 338
 
339
-        $entry = FrmEntry::getOne($id, true);
339
+        $entry = FrmEntry::getOne( $id, true );
340 340
 
341
-        $data = maybe_unserialize($entry->description);
341
+        $data = maybe_unserialize( $entry->description );
342 342
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
343 343
 			$data = array( 'referrer' => $data );
344 344
 		}
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
347 347
         $to_emails = array();
348 348
 
349
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
349
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
350 350
     }
351 351
 
352 352
     public static function destroy() {
353
-        FrmAppHelper::permission_check('frm_delete_entries');
353
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
354 354
 
355 355
 		$params = FrmForm::get_admin_params();
356 356
 
357
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
357
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
358 358
             //unlink entry from post
359 359
             global $wpdb;
360
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
360
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
361 361
         }
362 362
 
363 363
         $message = '';
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
         if ( ! isset( $frm_vars['form_params'] ) ) {
433 433
             $frm_vars['form_params'] = array();
434 434
         }
435
-		$frm_vars['form_params'][ $form->id ] = $params;
435
+		$frm_vars['form_params'][$form->id] = $params;
436 436
 
437
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
437
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
438 438
             return;
439 439
         }
440 440
 
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 		 */
450 450
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
451 451
 
452
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
452
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
453 453
 
454 454
         if ( empty( $errors ) ) {
455 455
 			$_POST['frm_skip_cookie'] = 1;
456 456
             if ( $params['action'] == 'create' ) {
457
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
458
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
457
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
458
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
459 459
                 }
460 460
             }
461 461
 
@@ -490,28 +490,28 @@  discard block
 block discarded – undo
490 490
 	}
491 491
 
492 492
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
493
-        $field = FrmField::getOne($meta->field_id);
493
+        $field = FrmField::getOne( $meta->field_id );
494 494
         if ( ! $field ) {
495 495
             return $value;
496 496
         }
497 497
 
498
-        $value = self::filter_display_value($value, $field, $atts);
498
+        $value = self::filter_display_value( $value, $field, $atts );
499 499
         return $value;
500 500
     }
501 501
 
502 502
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
503
-        $plain_text = add_filter('frm_plain_text_email', true);
503
+        $plain_text = add_filter( 'frm_plain_text_email', true );
504 504
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
505 505
 
506
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
506
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
507 507
             return $value;
508 508
         }
509 509
 
510
-        return self::filter_display_value($value, $field, $atts);
510
+        return self::filter_display_value( $value, $field, $atts );
511 511
     }
512 512
 
513 513
     public static function &filter_display_value( $value, $field, $atts = array() ) {
514
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
515 515
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
516 516
             return $value;
517 517
         }
@@ -519,29 +519,29 @@  discard block
 block discarded – undo
519 519
         $f_values = $f_labels = array();
520 520
 
521 521
         foreach ( $field->options as $opt_key => $opt ) {
522
-            if ( ! is_array($opt) ) {
522
+            if ( ! is_array( $opt ) ) {
523 523
                 continue;
524 524
             }
525 525
 
526
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
527
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
528
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
529
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
526
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
527
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
528
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
529
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
530 530
             }
531
-            unset($opt_key, $opt);
531
+            unset( $opt_key, $opt );
532 532
         }
533 533
 
534
-        if ( ! empty($f_values) ) {
534
+        if ( ! empty( $f_values ) ) {
535 535
             foreach ( (array) $value as $v_key => $val ) {
536
-                if ( in_array($val, $f_values) ) {
537
-                    $opt = array_search($val, $f_values);
538
-                    if ( is_array($value) ) {
539
-                        $value[ $v_key ] = $f_labels[ $opt ];
536
+                if ( in_array( $val, $f_values ) ) {
537
+                    $opt = array_search( $val, $f_values );
538
+                    if ( is_array( $value ) ) {
539
+                        $value[$v_key] = $f_labels[$opt];
540 540
                     } else {
541
-                        $value = $f_labels[ $opt ];
541
+                        $value = $f_labels[$opt];
542 542
                     }
543 543
                 }
544
-                unset($v_key, $val);
544
+                unset( $v_key, $val );
545 545
             }
546 546
         }
547 547
 
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
 	}
555 555
 
556 556
 	public static function entry_sidebar( $entry ) {
557
-        $data = maybe_unserialize($entry->description);
558
-        $date_format = get_option('date_format');
559
-        $time_format = get_option('time_format');
557
+        $data = maybe_unserialize( $entry->description );
558
+        $date_format = get_option( 'date_format' );
559
+        $time_format = get_option( 'time_format' );
560 560
 		if ( isset( $data['browser'] ) ) {
561 561
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
562 562
 		}
563 563
 
564
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
565 565
     }
566 566
 }
Please login to merge, or discard this patch.
classes/views/styles/_field-colors.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 				<a href="?page=formidable-styles&page-tab=default#tabs-panel-default-color" class="nav-tab-link" data-type="tabs-panel-default-color"><?php _e( 'Default', 'formidable' ) ?></a>
5 5
 			</li>
6 6
 			<li <?php echo ( 'active-color' == $current_tab ? ' class="tabs"' : '' ); ?>>
7
-				<a href="<?php echo esc_url('?page=formidable-styles&page-tab=active-color#page-active-color') ?>" class="nav-tab-link" data-type="tabs-panel-active-color"><?php _e( 'Active', 'formidable' ) ?></a>
7
+				<a href="<?php echo esc_url( '?page=formidable-styles&page-tab=active-color#page-active-color' ) ?>" class="nav-tab-link" data-type="tabs-panel-active-color"><?php _e( 'Active', 'formidable' ) ?></a>
8 8
 			</li>
9 9
 			<li <?php echo ( 'active-error' == $current_tab ? ' class="tabs"' : '' ); ?>>
10 10
 				<a href="?page=formidable-styles&page-tab=active-error#tabs-panel-active-error" class="nav-tab-link" data-type="tabs-panel-active-error"><?php _e( 'Error', 'formidable' ) ?></a>
@@ -19,34 +19,34 @@  discard block
 block discarded – undo
19 19
 		?>">
20 20
 			<div class="field-group field-group-border clearfix">
21 21
             	<label class="background"><?php _e( 'BG color', 'formidable' ) ?></label>
22
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('bg_color') ) ?>" id="frm_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color'] ) ?>" />
22
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'bg_color' ) ) ?>" id="frm_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color'] ) ?>" />
23 23
             </div>
24 24
             <div class="field-group clearfix">
25 25
             	<label><?php _e( 'Text', 'formidable' ) ?></label>
26
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('text_color') ) ?>" id="frm_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['text_color'] ) ?>" />
26
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'text_color' ) ) ?>" id="frm_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['text_color'] ) ?>" />
27 27
             </div>
28 28
 
29 29
             <div class="field-group field-group-border clearfix">
30 30
             	<label><?php _e( 'Border', 'formidable' ) ?></label>
31
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('border_color') ) ?>" id="frm_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['border_color'] ) ?>" />
31
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_color' ) ) ?>" id="frm_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['border_color'] ) ?>" />
32 32
             </div>
33 33
             <div class="field-group clearfix">
34 34
             	<label><?php _e( 'Thickness', 'formidable' ) ?></label>
35
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_border_width') ) ?>" id="frm_field_border_width" value="<?php echo esc_attr( $style->post_content['field_border_width'] ) ?>" size="4" />
35
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_border_width' ) ) ?>" id="frm_field_border_width" value="<?php echo esc_attr( $style->post_content['field_border_width'] ) ?>" size="4" />
36 36
             </div>
37 37
             <div class="field-group clearfix">
38 38
 				<label><?php _e( 'Style', 'formidable' ) ?></label>
39
-            	<select name="<?php echo esc_attr( $frm_style->get_field_name('field_border_style') ) ?>" id="frm_field_border_style">
40
-            	    <option value="solid" <?php selected($style->post_content['field_border_style'], 'solid') ?>><?php _e( 'solid', 'formidable' ) ?></option>
41
-            		<option value="dotted" <?php selected($style->post_content['field_border_style'], 'dotted') ?>><?php _e( 'dotted', 'formidable' ) ?></option>
42
-            		<option value="dashed" <?php selected($style->post_content['field_border_style'], 'dashed') ?>><?php _e( 'dashed', 'formidable' ) ?></option>
43
-            		<option value="double" <?php selected($style->post_content['field_border_style'], 'double') ?>><?php _e( 'double', 'formidable' ) ?></option>
39
+            	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'field_border_style' ) ) ?>" id="frm_field_border_style">
40
+            	    <option value="solid" <?php selected( $style->post_content['field_border_style'], 'solid' ) ?>><?php _e( 'solid', 'formidable' ) ?></option>
41
+            		<option value="dotted" <?php selected( $style->post_content['field_border_style'], 'dotted' ) ?>><?php _e( 'dotted', 'formidable' ) ?></option>
42
+            		<option value="dashed" <?php selected( $style->post_content['field_border_style'], 'dashed' ) ?>><?php _e( 'dashed', 'formidable' ) ?></option>
43
+            		<option value="double" <?php selected( $style->post_content['field_border_style'], 'double' ) ?>><?php _e( 'double', 'formidable' ) ?></option>
44 44
             	</select>
45 45
             </div>
46 46
             <div class="clear"></div>
47 47
 			<p class="frm_no_bottom_margin">
48 48
 				<label>
49
-					<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('remove_box_shadow') ) ?>" id="frm_remove_box_shadow" value="1" <?php checked($style->post_content['remove_box_shadow'], 1) ?> />
49
+					<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow' ) ) ?>" id="frm_remove_box_shadow" value="1" <?php checked( $style->post_content['remove_box_shadow'], 1 ) ?> />
50 50
 					<?php _e( 'Remove box shadow', 'formidable' ) ?>
51 51
 				</label>
52 52
 			</p>
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 		?>">
58 58
             <div class="field-group field-group-border clearfix">
59 59
             	<label class="background"><?php _e( 'BG color', 'formidable' ) ?></label>
60
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('bg_color_active') ) ?>" id="frm_bg_color_active" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_active'] ) ?>" />
60
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'bg_color_active' ) ) ?>" id="frm_bg_color_active" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_active'] ) ?>" />
61 61
             </div>
62 62
             <div class="field-group clearfix">
63 63
             	<label><?php _e( 'Border', 'formidable' ) ?></label>
64
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('border_color_active') ) ?>" id="frm_border_color_active" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_active'] ) ?>" />
64
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_color_active' ) ) ?>" id="frm_border_color_active" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_active'] ) ?>" />
65 65
             </div>
66 66
 			<div class="clear"></div>
67 67
 			<p class="frm_no_bottom_margin">
68 68
 				<label>
69
-					<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('remove_box_shadow_active') ) ?>" id="frm_remove_box_shadow_active" value="1" <?php checked($style->post_content['remove_box_shadow_active'], 1) ?> />
69
+					<input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'remove_box_shadow_active' ) ) ?>" id="frm_remove_box_shadow_active" value="1" <?php checked( $style->post_content['remove_box_shadow_active'], 1 ) ?> />
70 70
 					<?php _e( 'Remove box shadow', 'formidable' ) ?>
71 71
 				</label>
72 72
 			</p>
@@ -77,28 +77,28 @@  discard block
 block discarded – undo
77 77
 		?>">
78 78
 		    <div class="field-group field-group-border clearfix">
79 79
         	    <label class="background"><?php _e( 'BG color', 'formidable' ) ?></label>
80
-        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('bg_color_error') ) ?>" id="frm_bg_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_error'] ) ?>" />
80
+        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'bg_color_error' ) ) ?>" id="frm_bg_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_error'] ) ?>" />
81 81
             </div>
82 82
             <div class="field-group clearfix">
83 83
         	    <label><?php _e( 'Text', 'formidable' ) ?></label>
84
-        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('text_color_error') ) ?>" id="frm_text_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['text_color_error'] ) ?>" />
84
+        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'text_color_error' ) ) ?>" id="frm_text_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['text_color_error'] ) ?>" />
85 85
             </div>
86 86
 
87 87
             <div class="field-group field-group-border clearfix">
88 88
                 <label><?php _e( 'Border', 'formidable' ) ?></label>
89
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('border_color_error') ) ?>" id="frm_border_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_error'] ) ?>" />
89
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_color_error' ) ) ?>" id="frm_border_color_error" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_error'] ) ?>" />
90 90
             </div>
91 91
             <div class="field-group clearfix">
92 92
             	<label><?php _e( 'Thickness', 'formidable' ) ?></label>
93
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('border_width_error') ) ?>" id="frm_border_width_error" value="<?php echo esc_attr( $style->post_content['border_width_error'] ) ?>" size="4" />
93
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_width_error' ) ) ?>" id="frm_border_width_error" value="<?php echo esc_attr( $style->post_content['border_width_error'] ) ?>" size="4" />
94 94
             </div>
95 95
             <div class="field-group clearfix">
96 96
             	<label><?php _e( 'Style', 'formidable' ) ?></label>
97
-            	<select name="<?php echo esc_attr( $frm_style->get_field_name('border_style_error') ) ?>" id="frm_border_style_error">
98
-            	    <option value="solid" <?php selected($style->post_content['border_style_error'], 'solid') ?>><?php _e( 'solid', 'formidable' ) ?></option>
99
-            		<option value="dotted" <?php selected($style->post_content['border_style_error'], 'dotted') ?>><?php _e( 'dotted', 'formidable' ) ?></option>
100
-            		<option value="dashed" <?php selected($style->post_content['border_style_error'], 'dashed') ?>><?php _e( 'dashed', 'formidable' ) ?></option>
101
-            		<option value="double" <?php selected($style->post_content['border_style_error'], 'double') ?>><?php _e( 'double', 'formidable' ) ?></option>
97
+            	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'border_style_error' ) ) ?>" id="frm_border_style_error">
98
+            	    <option value="solid" <?php selected( $style->post_content['border_style_error'], 'solid' ) ?>><?php _e( 'solid', 'formidable' ) ?></option>
99
+            		<option value="dotted" <?php selected( $style->post_content['border_style_error'], 'dotted' ) ?>><?php _e( 'dotted', 'formidable' ) ?></option>
100
+            		<option value="dashed" <?php selected( $style->post_content['border_style_error'], 'dashed' ) ?>><?php _e( 'dashed', 'formidable' ) ?></option>
101
+            		<option value="double" <?php selected( $style->post_content['border_style_error'], 'double' ) ?>><?php _e( 'double', 'formidable' ) ?></option>
102 102
             	</select>
103 103
             </div>
104 104
 
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 		?>">
111 111
 		    <div class="field-group field-group-border clearfix">
112 112
         	    <label class="background"><?php _e( 'BG color', 'formidable' ) ?></label>
113
-        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('bg_color_disabled') ) ?>" id="frm_bg_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_disabled'] ) ?>" />
113
+        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'bg_color_disabled' ) ) ?>" id="frm_bg_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['bg_color_disabled'] ) ?>" />
114 114
             </div>
115 115
             <div class="field-group clearfix">
116 116
         	    <label><?php _e( 'Text', 'formidable' ) ?></label>
117
-        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('text_color_disabled') ) ?>" id="frm_text_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['text_color_disabled'] ) ?>" />
117
+        	    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'text_color_disabled' ) ) ?>" id="frm_text_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['text_color_disabled'] ) ?>" />
118 118
             </div>
119 119
 
120 120
             <div class="field-group clearfix">
121 121
                 <label><?php _e( 'Border', 'formidable' ) ?></label>
122
-            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('border_color_disabled') ) ?>" id="frm_border_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_disabled'] ) ?>" />
122
+            	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_color_disabled' ) ) ?>" id="frm_border_color_disabled" class="hex" value="<?php echo esc_attr( $style->post_content['border_color_disabled'] ) ?>" />
123 123
             </div>
124 124
             <div class="clear"></div>
125 125
 		</div><!-- /.tabs-panel -->
Please login to merge, or discard this patch.
classes/views/styles/_field-sizes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@
 block discarded – undo
1 1
 <div class="field-group clearfix frm-first-row">
2 2
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_font_size') ) ?>" id="frm_field_font_size" value="<?php echo esc_attr( $style->post_content['field_font_size'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_font_size' ) ) ?>" id="frm_field_font_size" value="<?php echo esc_attr( $style->post_content['field_font_size'] ) ?>" />
4 4
 </div>
5 5
 
6 6
 <div class="field-group clearfix frm-first-row">
7 7
 	<label><?php _e( 'Height', 'formidable' ) ?></label>
8
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_height') ) ?>" id="frm_field_height" value="<?php echo esc_attr( $style->post_content['field_height'] ) ?>" />
8
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_height' ) ) ?>" id="frm_field_height" value="<?php echo esc_attr( $style->post_content['field_height'] ) ?>" />
9 9
 </div>
10 10
 
11 11
 <div class="field-group clearfix frm-first-row">
12 12
 	<label><?php _e( 'Width', 'formidable' ) ?></label>
13
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_width') ) ?>" id="frm_field_width" value="<?php echo esc_attr( $style->post_content['field_width'] ) ?>" />
13
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_width' ) ) ?>" id="frm_field_width" value="<?php echo esc_attr( $style->post_content['field_width'] ) ?>" />
14 14
 </div>
15 15
 
16 16
 <div class="clear"></div>
17 17
 <p class="frm_no_bottom_margin">
18
-    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('auto_width') ) ?>" id="frm_auto_width" value="1" <?php checked( $style->post_content['auto_width'], 1 ) ?> />
18
+    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'auto_width' ) ) ?>" id="frm_auto_width" value="1" <?php checked( $style->post_content['auto_width'], 1 ) ?> />
19 19
 	<?php _e( 'Automatic Width for drop-down fields', 'formidable' ) ?></label>
20 20
 </p>
21 21
 
22 22
 <div class="field-group clearfix">
23 23
 	<label><?php _e( 'Padding', 'formidable' ) ?></label>
24
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_pad') ) ?>" id="frm_field_pad" value="<?php echo esc_attr( $style->post_content['field_pad'] ) ?>" />
24
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_pad' ) ) ?>" id="frm_field_pad" value="<?php echo esc_attr( $style->post_content['field_pad'] ) ?>" />
25 25
 </div>
26 26
 
27 27
 <div class="field-group clearfix">
28 28
 	<label><?php _e( 'Margin', 'formidable' ) ?></label>
29
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('field_margin') ) ?>" id="frm_field_margin" value="<?php echo esc_attr( $style->post_content['field_margin'] ) ?>" />
29
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'field_margin' ) ) ?>" id="frm_field_margin" value="<?php echo esc_attr( $style->post_content['field_margin'] ) ?>" />
30 30
 </div>
31 31
 
32 32
 <div class="field-group clearfix">
33 33
 	<label><?php _e( 'Corners', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Formidable uses CSS3 border-radius for corner rounding, which is not currently supported by Internet Explorer.', 'formidable' ) ?>" ></span></label>
34
-	<input type="text" value="<?php echo esc_attr( $style->post_content['border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('border_radius') ) ?>" id="frm_border_radius" />
34
+	<input type="text" value="<?php echo esc_attr( $style->post_content['border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'border_radius' ) ) ?>" id="frm_border_radius" />
35 35
 </div>
36 36
 
37 37
 <div class="field-group clearfix frm-first-row">
38 38
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
39
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('field_weight') ) ?>" id="frm_field_weight">
39
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'field_weight' ) ) ?>" id="frm_field_weight">
40 40
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
41 41
 			<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['field_weight'], $value ) ?>><?php echo $name ?></option>
42 42
 		<?php } ?>
Please login to merge, or discard this patch.
classes/views/styles/_general.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,80 +1,80 @@
 block discarded – undo
1 1
 <p>
2
-    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('center_form') ) ?>" id="frm_center_form" value="1" <?php checked($style->post_content['center_form'], 1) ?> />
2
+    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'center_form' ) ) ?>" id="frm_center_form" value="1" <?php checked( $style->post_content['center_form'], 1 ) ?> />
3 3
 	    <?php _e( 'Center form on page', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will center your form on the page where it is published if the form width is less than the available width on the page.', 'formidable' ) ?>" ></span>
4 4
 	</label>
5 5
 </p>
6 6
 
7 7
 <div class="field-group clearfix frm-first-row">
8 8
 	<label><?php _e( 'Alignment', 'formidable' ) ?></label>
9
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('form_align') ) ?>" id="frm_form_align">
10
-		<option value="left" <?php selected($style->post_content['form_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
11
-		<option value="right" <?php selected($style->post_content['form_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
12
-		<option value="center" <?php selected($style->post_content['form_align'], 'center') ?>><?php _e( 'center', 'formidable' ) ?></option>
9
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'form_align' ) ) ?>" id="frm_form_align">
10
+		<option value="left" <?php selected( $style->post_content['form_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
11
+		<option value="right" <?php selected( $style->post_content['form_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
12
+		<option value="center" <?php selected( $style->post_content['form_align'], 'center' ) ?>><?php _e( 'center', 'formidable' ) ?></option>
13 13
 	</select>
14 14
 </div>
15 15
 
16 16
 <div class="field-group clearfix frm-first-row">
17 17
 	<label><?php _e( 'Max Width', 'formidable' ) ?></label>
18
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_width') ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/>
18
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_width' ) ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/>
19 19
 </div>
20 20
 
21 21
 <div class="field-group clearfix frm-first-row">
22 22
 	<label><?php _e( 'Background', 'formidable' ) ?></label>
23
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_bg_color') ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" />
23
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_bg_color' ) ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" />
24 24
 </div>
25 25
 
26 26
 <div class="field-group field-group-border clearfix">
27 27
 	<label><?php _e( 'Border', 'formidable' ) ?></label>
28
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset') ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" />
28
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset' ) ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" />
29 29
 </div>
30 30
 
31 31
 <div class="field-group clearfix">
32 32
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
33
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_color') ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" />
33
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_color' ) ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" />
34 34
 </div>
35 35
 
36 36
 <div class="field-group clearfix">
37 37
 	<label><?php _e( 'Padding', 'formidable' ) ?></label>
38
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_padding') ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" />
38
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_padding' ) ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" />
39 39
 </div>
40 40
 
41 41
 <div id="frm_gen_font_box" class="field-group clearfix">
42 42
 	<label><?php _e( 'Font Family', 'formidable' ) ?></label>
43
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font') ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>"  class="frm_full_width" />
43
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font' ) ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>"  class="frm_full_width" />
44 44
 </div>
45 45
 
46 46
 <div class="field-group clearfix frm-half">
47 47
 	<label><?php _e( 'Direction', 'formidable' ) ?></label>
48
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('direction') ) ?>" id="frm_direction">
49
-		<option value="ltr" <?php selected($style->post_content['direction'], 'ltr') ?>><?php _e( 'Left to Right', 'formidable' ) ?></option>
50
-		<option value="rtl" <?php selected($style->post_content['direction'], 'rtl') ?>><?php _e( 'Right to Left', 'formidable' ) ?></option>
48
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'direction' ) ) ?>" id="frm_direction">
49
+		<option value="ltr" <?php selected( $style->post_content['direction'], 'ltr' ) ?>><?php _e( 'Left to Right', 'formidable' ) ?></option>
50
+		<option value="rtl" <?php selected( $style->post_content['direction'], 'rtl' ) ?>><?php _e( 'Right to Left', 'formidable' ) ?></option>
51 51
 	</select>
52 52
 </div>
53 53
 
54 54
 <div class="clear"></div>
55 55
 <div class="field-group clearfix frm-half">
56 56
 	<label><?php _e( 'Title Size', 'formidable' ) ?></label>
57
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" />
57
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" />
58 58
 </div>
59 59
 
60 60
 <div class="field-group clearfix frm-half">
61 61
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
62
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" />
62
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" />
63 63
 </div>
64 64
 
65 65
 <div class="field-group clearfix frm-half">
66 66
 	<label><?php _e( 'Description Size', 'formidable' ) ?></label>
67
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" />
67
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" />
68 68
 </div>
69 69
 
70 70
 <div class="field-group clearfix frm-half">
71 71
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
72
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" />
72
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" />
73 73
 </div>
74 74
 
75 75
 <div class="clear"></div>
76 76
 <p class="frm_no_bottom_margin">
77
-    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('important_style') ) ?>" id="frm_important_style" value="1" <?php checked($style->post_content['important_style'], 1) ?> />
77
+    <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'important_style' ) ) ?>" id="frm_important_style" value="1" <?php checked( $style->post_content['important_style'], 1 ) ?> />
78 78
 	    <?php _e( 'Override theme styling', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will add !important to many of the lines in the Formidable styling to make sure it will be used.', 'formidable' ) ?>" ></span>
79 79
 	</label>
80 80
 </p>
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +596 added lines, -596 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,46 +64,46 @@  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
-                'slug'          => (string) $t->term_slug,
95
-            ));
94
+				'slug'          => (string) $t->term_slug,
95
+			));
96 96
 
97 97
 			if ( $term && is_array( $term ) ) {
98
-                $imported['imported']['terms']++;
98
+				$imported['imported']['terms']++;
99 99
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
100
-            }
100
+			}
101 101
 
102 102
 			unset( $term, $t );
103 103
 		}
104 104
 
105 105
 		return $imported;
106
-    }
106
+	}
107 107
 
108 108
 	/**
109 109
 	 * @since 2.0.8
@@ -128,99 +128,99 @@  discard block
 block discarded – undo
128 128
 		self::put_child_forms_first( $forms );
129 129
 
130 130
 		foreach ( $forms as $item ) {
131
-            $form = array(
132
-                'id'            => (int) $item->id,
133
-                'form_key'      => (string) $item->form_key,
134
-                'name'          => (string) $item->name,
135
-                'description'   => (string) $item->description,
136
-                'options'       => (string) $item->options,
137
-                'logged_in'     => (int) $item->logged_in,
138
-                'is_template'   => (int) $item->is_template,
139
-                'default_template' => (int) $item->default_template,
140
-                'editable'      => (int) $item->editable,
141
-                'status'        => (string) $item->status,
142
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
144
-            );
145
-
146
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
131
+			$form = array(
132
+				'id'            => (int) $item->id,
133
+				'form_key'      => (string) $item->form_key,
134
+				'name'          => (string) $item->name,
135
+				'description'   => (string) $item->description,
136
+				'options'       => (string) $item->options,
137
+				'logged_in'     => (int) $item->logged_in,
138
+				'is_template'   => (int) $item->is_template,
139
+				'default_template' => (int) $item->default_template,
140
+				'editable'      => (int) $item->editable,
141
+				'status'        => (string) $item->status,
142
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
144
+			);
145
+
146
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
147 147
 
148 148
 			self::update_custom_style_setting_on_import( $form );
149 149
 
150
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
150
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
151 151
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
152
-            if ( ! $form['is_template'] ) {
153
-                $edit_query['created_at'] = $form['created_at'];
154
-            }
152
+			if ( ! $form['is_template'] ) {
153
+				$edit_query['created_at'] = $form['created_at'];
154
+			}
155 155
 
156
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
157 157
 
158
-            $this_form = FrmForm::getAll($edit_query, '', 1);
159
-            unset($edit_query);
158
+			$this_form = FrmForm::getAll($edit_query, '', 1);
159
+			unset($edit_query);
160 160
 
161
-            if ( ! empty( $this_form ) ) {
162
-                $old_id = $form_id = $this_form->id;
163
-                FrmForm::update($form_id, $form );
164
-                $imported['updated']['forms']++;
165
-                // Keep track of whether this specific form was updated or not
161
+			if ( ! empty( $this_form ) ) {
162
+				$old_id = $form_id = $this_form->id;
163
+				FrmForm::update($form_id, $form );
164
+				$imported['updated']['forms']++;
165
+				// Keep track of whether this specific form was updated or not
166 166
 				$imported['form_status'][ $form_id ] = 'updated';
167 167
 
168 168
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
169
-                $old_fields = array();
170
-                foreach ( $form_fields as $f ) {
169
+				$old_fields = array();
170
+				foreach ( $form_fields as $f ) {
171 171
 					$old_fields[ $f->id ] = $f;
172 172
 					$old_fields[ $f->field_key ] = $f->id;
173
-                    unset($f);
174
-                }
175
-                $form_fields = $old_fields;
176
-                unset($old_fields);
177
-            } else {
178
-                $old_id = false;
179
-                //form does not exist, so create it
173
+					unset($f);
174
+				}
175
+				$form_fields = $old_fields;
176
+				unset($old_fields);
177
+			} else {
178
+				$old_id = false;
179
+				//form does not exist, so create it
180 180
 				$form_id = FrmForm::create( $form );
181
-                if ( $form_id ) {
182
-                    $imported['imported']['forms']++;
183
-                    // Keep track of whether this specific form was updated or not
181
+				if ( $form_id ) {
182
+					$imported['imported']['forms']++;
183
+					// Keep track of whether this specific form was updated or not
184 184
 					$imported['form_status'][ $form_id ] = 'imported';
185 185
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
186
-                }
187
-            }
186
+				}
187
+			}
188 188
 
189
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
190 190
 
191
-    		// Delete any fields attached to this form that were not included in the template
192
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
191
+			// Delete any fields attached to this form that were not included in the template
192
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
193 193
 				foreach ( $form_fields as $field ) {
194
-                    if ( is_object($field) ) {
195
-                        FrmField::destroy($field->id);
196
-                    }
197
-                    unset($field);
198
-                }
199
-                unset($form_fields);
200
-            }
201
-
202
-		    // Update field ids/keys to new ones
194
+					if ( is_object($field) ) {
195
+						FrmField::destroy($field->id);
196
+					}
197
+					unset($field);
198
+				}
199
+				unset($form_fields);
200
+			}
201
+
202
+			// Update field ids/keys to new ones
203 203
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
204 204
 
205 205
 			$imported['forms'][ (int) $item->id ] = $form_id;
206 206
 
207
-            // Send pre 2.0 form options through function that creates actions
208
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
207
+			// Send pre 2.0 form options through function that creates actions
208
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
209 209
 
210
-		    unset($form, $item);
210
+			unset($form, $item);
211 211
 		}
212 212
 
213 213
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
214 214
 
215 215
 		return $imported;
216
-    }
216
+	}
217 217
 
218 218
 	/**
219
-	* Put child forms first so they will be imported before parents
220
-	*
221
-	* @since 2.0.16
222
-	* @param array $forms
223
-	*/
219
+	 * Put child forms first so they will be imported before parents
220
+	 *
221
+	 * @since 2.0.16
222
+	 * @param array $forms
223
+	 */
224 224
 	private static function put_child_forms_first( &$forms ) {
225 225
 		$child_forms = array();
226 226
 		$regular_forms = array();
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Keep track of all imported child forms
243
-	*
244
-	* @since 2.0.16
245
-	* @param int $form_id
246
-	* @param int $parent_form_id
247
-	* @param array $child_forms
248
-	*/
242
+	 * Keep track of all imported child forms
243
+	 *
244
+	 * @since 2.0.16
245
+	 * @param int $form_id
246
+	 * @param int $parent_form_id
247
+	 * @param array $child_forms
248
+	 */
249 249
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
250 250
 		if ( $parent_form_id ) {
251 251
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 	/**
256
-	* Update the parent_form_id on imported child forms
257
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
258
-	*
259
-	* @since 2.0.6
260
-	* @param array $imported_forms
261
-	* @param array $child_forms
262
-	*/
256
+	 * Update the parent_form_id on imported child forms
257
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
258
+	 *
259
+	 * @since 2.0.6
260
+	 * @param array $imported_forms
261
+	 * @param array $child_forms
262
+	 */
263 263
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
264 264
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
265 265
 
@@ -273,61 +273,61 @@  discard block
 block discarded – undo
273 273
 	}
274 274
 
275 275
 	/**
276
-	* Import all fields for a form
277
-	* @since 2.0.13
278
-	*
279
-	* TODO: Cut down on params
280
-	*/
276
+	 * Import all fields for a form
277
+	 * @since 2.0.13
278
+	 *
279
+	 * TODO: Cut down on params
280
+	 */
281 281
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
282 282
 		foreach ( $xml_fields as $field ) {
283
-		    $f = array(
284
-		        'id'            => (int) $field->id,
285
-		        'field_key'     => (string) $field->field_key,
286
-		        'name'          => (string) $field->name,
287
-		        'description'   => (string) $field->description,
288
-		        'type'          => (string) $field->type,
289
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
-		        'field_order'   => (int) $field->field_order,
291
-		        'form_id'       => (int) $form_id,
292
-		        'required'      => (int) $field->required,
293
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
283
+			$f = array(
284
+				'id'            => (int) $field->id,
285
+				'field_key'     => (string) $field->field_key,
286
+				'name'          => (string) $field->name,
287
+				'description'   => (string) $field->description,
288
+				'type'          => (string) $field->type,
289
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
+				'field_order'   => (int) $field->field_order,
291
+				'form_id'       => (int) $form_id,
292
+				'required'      => (int) $field->required,
293
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
294 294
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
295
-		    );
296
-
297
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
298
-		        'text', 'email', 'url', 'textarea',
299
-		        'number','phone', 'date', 'time',
300
-		        'hidden', 'password', 'tag', 'image',
301
-		    )) ) {
302
-		        if ( count($f['default_value']) === 1 ) {
303
-		            $f['default_value'] = '['. reset($f['default_value']) .']';
304
-		        } else {
305
-		            $f['default_value'] = reset($f['default_value']);
306
-		        }
307
-		    }
308
-
309
-		    $f = apply_filters('frm_duplicated_field', $f);
295
+			);
296
+
297
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
298
+				'text', 'email', 'url', 'textarea',
299
+				'number','phone', 'date', 'time',
300
+				'hidden', 'password', 'tag', 'image',
301
+			)) ) {
302
+				if ( count($f['default_value']) === 1 ) {
303
+					$f['default_value'] = '['. reset($f['default_value']) .']';
304
+				} else {
305
+					$f['default_value'] = reset($f['default_value']);
306
+				}
307
+			}
308
+
309
+			$f = apply_filters('frm_duplicated_field', $f);
310 310
 
311 311
 			self::maybe_update_form_select( $f, $imported );
312 312
 
313
-		    if ( ! empty($this_form) ) {
314
-		        // check for field to edit by field id
313
+			if ( ! empty($this_form) ) {
314
+				// check for field to edit by field id
315 315
 				if ( isset( $form_fields[ $f['id'] ] ) ) {
316
-		            FrmField::update( $f['id'], $f );
317
-		            $imported['updated']['fields']++;
316
+					FrmField::update( $f['id'], $f );
317
+					$imported['updated']['fields']++;
318 318
 
319 319
 					unset( $form_fields[ $f['id'] ] );
320 320
 
321
-		            //unset old field key
321
+					//unset old field key
322 322
 					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
323 323
 						unset( $form_fields[ $f['field_key'] ] );
324 324
 					}
325 325
 				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
326
-		            // check for field to edit by field key
327
-		            unset($f['id']);
326
+					// check for field to edit by field key
327
+					unset($f['id']);
328 328
 
329 329
 					FrmField::update( $form_fields[ $f['field_key'] ], $f );
330
-		            $imported['updated']['fields']++;
330
+					$imported['updated']['fields']++;
331 331
 
332 332
 					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
333 333
 					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
@@ -337,29 +337,29 @@  discard block
 block discarded – undo
337 337
 						continue;
338 338
 					}
339 339
 
340
-		            // if no matching field id or key in this form, create the field
341
-		            $imported['imported']['fields']++;
342
-		        }
340
+					// if no matching field id or key in this form, create the field
341
+					$imported['imported']['fields']++;
342
+				}
343 343
 			} else {
344 344
 				$new_id = FrmField::create( $f );
345 345
 				if ( $new_id == false ) {
346 346
 					continue;
347 347
 				}
348 348
 
349
-	            $imported['imported']['fields']++;
350
-		    }
349
+				$imported['imported']['fields']++;
350
+			}
351 351
 
352 352
 			unset($field, $new_id);
353 353
 		}
354 354
 	}
355 355
 
356 356
 	/**
357
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
358
-	*
359
-	* @since 2.0.16
360
-	* @param array $f
361
-	* @param array $imported
362
-	*/
357
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
358
+	 *
359
+	 * @since 2.0.16
360
+	 * @param array $f
361
+	 * @param array $imported
362
+	 */
363 363
 	private static function maybe_update_form_select( &$f, $imported ) {
364 364
 		if ( ! isset( $imported['forms'] ) ) {
365 365
 			return;
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
 	}
377 377
 
378 378
 	/**
379
-	* Updates the custom style setting on import
380
-	*
381
-	* @since 2.0.19
382
-	* @param array $form
383
-	*
384
-	*/
379
+	 * Updates the custom style setting on import
380
+	 *
381
+	 * @since 2.0.19
382
+	 * @param array $form
383
+	 *
384
+	 */
385 385
 	private static function update_custom_style_setting_on_import( &$form ) {
386 386
 		if ( is_numeric ( $form['options']['custom_style'] ) ) {
387 387
 			// Set to default
@@ -409,16 +409,16 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	public static function import_xml_views( $views, $imported ) {
412
-        $imported['posts'] = array();
413
-        $form_action_type = FrmFormActionsController::$action_post_type;
412
+		$imported['posts'] = array();
413
+		$form_action_type = FrmFormActionsController::$action_post_type;
414 414
 
415
-        $post_types = array(
416
-            'frm_display' => 'views',
417
-            $form_action_type => 'actions',
418
-            'frm_styles'    => 'styles',
419
-        );
415
+		$post_types = array(
416
+			'frm_display' => 'views',
417
+			$form_action_type => 'actions',
418
+			'frm_styles'    => 'styles',
419
+		);
420 420
 
421
-        foreach ( $views as $item ) {
421
+		foreach ( $views as $item ) {
422 422
 			$post = array(
423 423
 				'post_title'    => (string) $item->title,
424 424
 				'post_name'     => (string) $item->post_name,
@@ -437,52 +437,52 @@  discard block
 block discarded – undo
437 437
 				'post_date'     => (string) $item->post_date,
438 438
 				'post_date_gmt' => (string) $item->post_date_gmt,
439 439
 				'ping_status'   => (string) $item->ping_status,
440
-                'postmeta'      => array(),
441
-                'tax_input'     => array(),
440
+				'postmeta'      => array(),
441
+				'tax_input'     => array(),
442 442
 			);
443 443
 
444
-            $old_id = $post['post_id'];
445
-            self::populate_post($post, $item, $imported);
444
+			$old_id = $post['post_id'];
445
+			self::populate_post($post, $item, $imported);
446 446
 
447 447
 			unset($item);
448 448
 
449 449
 			$post_id = false;
450
-            if ( $post['post_type'] == $form_action_type ) {
451
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
450
+			if ( $post['post_type'] == $form_action_type ) {
451
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
452 452
 				if ( $action_control ) {
453 453
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
454 454
 				}
455
-                unset($action_control);
456
-            } else if ( $post['post_type'] == 'frm_styles' ) {
457
-                // Properly encode post content before inserting the post
458
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
459
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
460
-
461
-                // Create/update post now
462
-                $post_id = wp_insert_post( $post );
463
-            } else {
464
-                // Create/update post now
465
-                $post_id = wp_insert_post( $post );
466
-            }
467
-
468
-            if ( ! is_numeric($post_id) ) {
469
-                continue;
470
-            }
471
-
472
-            self::update_postmeta($post, $post_id);
473
-
474
-            $this_type = 'posts';
455
+				unset($action_control);
456
+			} else if ( $post['post_type'] == 'frm_styles' ) {
457
+				// Properly encode post content before inserting the post
458
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
459
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
460
+
461
+				// Create/update post now
462
+				$post_id = wp_insert_post( $post );
463
+			} else {
464
+				// Create/update post now
465
+				$post_id = wp_insert_post( $post );
466
+			}
467
+
468
+			if ( ! is_numeric($post_id) ) {
469
+				continue;
470
+			}
471
+
472
+			self::update_postmeta($post, $post_id);
473
+
474
+			$this_type = 'posts';
475 475
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
476 476
 				$this_type = $post_types[ $post['post_type'] ];
477
-            }
477
+			}
478 478
 
479
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
480
-                $imported['updated'][ $this_type ]++;
481
-            } else {
482
-                $imported['imported'][ $this_type ]++;
483
-            }
479
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
480
+				$imported['updated'][ $this_type ]++;
481
+			} else {
482
+				$imported['imported'][ $this_type ]++;
483
+			}
484 484
 
485
-            unset($post);
485
+			unset($post);
486 486
 
487 487
 			$imported['posts'][ (int) $old_id ] = $post_id;
488 488
 		}
@@ -490,157 +490,157 @@  discard block
 block discarded – undo
490 490
 		self::maybe_update_stylesheet( $imported );
491 491
 
492 492
 		return $imported;
493
-    }
493
+	}
494 494
 
495
-    private static function populate_post( &$post, $item, $imported ) {
495
+	private static function populate_post( &$post, $item, $imported ) {
496 496
 		if ( isset($item->attachment_url) ) {
497 497
 			$post['attachment_url'] = (string) $item->attachment_url;
498 498
 		}
499 499
 
500 500
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
501
-		    // update to new form id
502
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
501
+			// update to new form id
502
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
503 503
 		}
504 504
 
505 505
 		foreach ( $item->postmeta as $meta ) {
506
-		    self::populate_postmeta($post, $meta, $imported);
506
+			self::populate_postmeta($post, $meta, $imported);
507 507
 			unset($meta);
508 508
 		}
509 509
 
510
-        self::populate_taxonomies($post, $item);
510
+		self::populate_taxonomies($post, $item);
511 511
 
512
-        self::maybe_editing_post($post);
513
-    }
512
+		self::maybe_editing_post($post);
513
+	}
514 514
 
515
-    private static function populate_postmeta( &$post, $meta, $imported ) {
516
-        global $frm_duplicate_ids;
515
+	private static function populate_postmeta( &$post, $meta, $imported ) {
516
+		global $frm_duplicate_ids;
517 517
 
518
-	    $m = array(
518
+		$m = array(
519 519
 			'key'   => (string) $meta->meta_key,
520 520
 			'value' => (string) $meta->meta_value,
521 521
 		);
522 522
 
523 523
 		//switch old form and field ids to new ones
524 524
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
525
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
525
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
526 526
 		} else {
527
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
527
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
528 528
 
529
-		    if ( ! empty($frm_duplicate_ids) ) {
529
+			if ( ! empty($frm_duplicate_ids) ) {
530 530
 
531
-		        if ( $m['key'] == 'frm_dyncontent' ) {
532
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
533
-    		    } else if ( $m['key'] == 'frm_options' ) {
531
+				if ( $m['key'] == 'frm_dyncontent' ) {
532
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
533
+				} else if ( $m['key'] == 'frm_options' ) {
534 534
 
535 535
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
536 536
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
537 537
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
538
-    		            }
539
-    		        }
540
-
541
-                    $check_dup_array = array();
542
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
543
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
544
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
545
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
546
-                            $check_dup_array[] = 'order_by';
547
-    		            }
548
-    		        }
549
-
550
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
551
-    		            $check_dup_array[] = 'where';
552
-    		        }
553
-
554
-                    foreach ( $check_dup_array as $check_k ) {
538
+						}
539
+					}
540
+
541
+					$check_dup_array = array();
542
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
543
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
544
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
545
+						} else if ( is_array( $m['value']['order_by'] ) ) {
546
+							$check_dup_array[] = 'order_by';
547
+						}
548
+					}
549
+
550
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
551
+						$check_dup_array[] = 'where';
552
+					}
553
+
554
+					foreach ( $check_dup_array as $check_k ) {
555 555
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
556 556
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
557 557
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
558
-		                    }
559
-		                    unset($mk, $mv);
560
-		                }
561
-                    }
562
-    		    }
563
-		    }
558
+							}
559
+							unset($mk, $mv);
560
+						}
561
+					}
562
+				}
563
+			}
564 564
 		}
565 565
 
566 566
 		if ( ! is_array($m['value']) ) {
567
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
567
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
568 568
 		}
569 569
 
570 570
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
571
-    }
572
-
573
-    /**
574
-     * Add terms to post
575
-     * @param array $post by reference
576
-     * @param object $item The XML object data
577
-     */
578
-    private static function populate_taxonomies( &$post, $item ) {
571
+	}
572
+
573
+	/**
574
+	 * Add terms to post
575
+	 * @param array $post by reference
576
+	 * @param object $item The XML object data
577
+	 */
578
+	private static function populate_taxonomies( &$post, $item ) {
579 579
 		foreach ( $item->category as $c ) {
580 580
 			$att = $c->attributes();
581 581
 			if ( ! isset( $att['nicename'] ) ) {
582
-                continue;
583
-            }
584
-
585
-		    $taxonomy = (string) $att['domain'];
586
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
587
-		        $name = (string) $att['nicename'];
588
-		        $h_term = get_term_by('slug', $name, $taxonomy);
589
-		        if ( $h_term ) {
590
-		            $name = $h_term->term_id;
591
-		        }
592
-		        unset($h_term);
593
-		    } else {
594
-		        $name = (string) $c;
595
-		    }
582
+				continue;
583
+			}
584
+
585
+			$taxonomy = (string) $att['domain'];
586
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
587
+				$name = (string) $att['nicename'];
588
+				$h_term = get_term_by('slug', $name, $taxonomy);
589
+				if ( $h_term ) {
590
+					$name = $h_term->term_id;
591
+				}
592
+				unset($h_term);
593
+			} else {
594
+				$name = (string) $c;
595
+			}
596 596
 
597 597
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
598 598
 				$post['tax_input'][ $taxonomy ] = array();
599 599
 			}
600 600
 
601 601
 			$post['tax_input'][ $taxonomy ][] = $name;
602
-		    unset($name);
602
+			unset($name);
603 603
 		}
604
-    }
604
+	}
605 605
 
606
-    /**
607
-     * Edit post if the key and created time match
608
-     */
609
-    private static function maybe_editing_post( &$post ) {
606
+	/**
607
+	 * Edit post if the key and created time match
608
+	 */
609
+	private static function maybe_editing_post( &$post ) {
610 610
 		$match_by = array(
611
-		    'post_type'     => $post['post_type'],
612
-		    'name'          => $post['post_name'],
613
-		    'post_status'   => $post['post_status'],
614
-		    'posts_per_page' => 1,
611
+			'post_type'     => $post['post_type'],
612
+			'name'          => $post['post_name'],
613
+			'post_status'   => $post['post_status'],
614
+			'posts_per_page' => 1,
615 615
 		);
616 616
 
617 617
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
618
-		    $match_by['include'] = $post['post_id'];
619
-		    unset($match_by['name']);
618
+			$match_by['include'] = $post['post_id'];
619
+			unset($match_by['name']);
620 620
 		}
621 621
 
622 622
 		$editing = get_posts($match_by);
623 623
 
624
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
625
-            // set the id of the post to edit
626
-            $post['ID'] = current($editing)->ID;
627
-        }
628
-    }
624
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
625
+			// set the id of the post to edit
626
+			$post['ID'] = current($editing)->ID;
627
+		}
628
+	}
629 629
 
630
-    private static function update_postmeta( &$post, $post_id ) {
631
-        foreach ( $post['postmeta'] as $k => $v ) {
632
-            if ( '_edit_last' == $k ) {
633
-                $v = FrmAppHelper::get_user_id_param($v);
634
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
635
-                //change the attachment ID
636
-                $v = FrmProXMLHelper::get_file_id($v);
637
-            }
630
+	private static function update_postmeta( &$post, $post_id ) {
631
+		foreach ( $post['postmeta'] as $k => $v ) {
632
+			if ( '_edit_last' == $k ) {
633
+				$v = FrmAppHelper::get_user_id_param($v);
634
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
635
+				//change the attachment ID
636
+				$v = FrmProXMLHelper::get_file_id($v);
637
+			}
638 638
 
639
-            update_post_meta($post_id, $k, $v);
639
+			update_post_meta($post_id, $k, $v);
640 640
 
641
-            unset($k, $v);
642
-        }
643
-    }
641
+			unset($k, $v);
642
+		}
643
+	}
644 644
 
645 645
 	private static function maybe_update_stylesheet( $imported ) {
646 646
 		if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) {
@@ -651,72 +651,72 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 	}
653 653
 
654
-    /**
655
-     * @param string $message
656
-     */
654
+	/**
655
+	 * @param string $message
656
+	 */
657 657
 	public static function parse_message( $result, &$message, &$errors ) {
658
-        if ( is_wp_error($result) ) {
659
-            $errors[] = $result->get_error_message();
660
-        } else if ( ! $result ) {
661
-            return;
662
-        }
663
-
664
-        if ( ! is_array($result) ) {
665
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
666
-            return;
667
-        }
668
-
669
-        $t_strings = array(
670
-            'imported'  => __( 'Imported', 'formidable' ),
671
-            'updated'   => __( 'Updated', 'formidable' ),
672
-        );
673
-
674
-        $message = '<ul>';
675
-        foreach ( $result as $type => $results ) {
658
+		if ( is_wp_error($result) ) {
659
+			$errors[] = $result->get_error_message();
660
+		} else if ( ! $result ) {
661
+			return;
662
+		}
663
+
664
+		if ( ! is_array($result) ) {
665
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
666
+			return;
667
+		}
668
+
669
+		$t_strings = array(
670
+			'imported'  => __( 'Imported', 'formidable' ),
671
+			'updated'   => __( 'Updated', 'formidable' ),
672
+		);
673
+
674
+		$message = '<ul>';
675
+		foreach ( $result as $type => $results ) {
676 676
 			if ( ! isset( $t_strings[ $type ] ) ) {
677
-                // only print imported and updated
678
-                continue;
679
-            }
677
+				// only print imported and updated
678
+				continue;
679
+			}
680 680
 
681
-            $s_message = array();
682
-            foreach ( $results as $k => $m ) {
683
-                self::item_count_message($m, $k, $s_message);
684
-                unset($k, $m);
685
-            }
681
+			$s_message = array();
682
+			foreach ( $results as $k => $m ) {
683
+				self::item_count_message($m, $k, $s_message);
684
+				unset($k, $m);
685
+			}
686 686
 
687
-            if ( ! empty($s_message) ) {
687
+			if ( ! empty($s_message) ) {
688 688
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
689
-                $message .= implode(', ', $s_message);
690
-                $message .= '</li>';
691
-            }
692
-        }
693
-
694
-        if ( $message == '<ul>' ) {
695
-            $message = '';
696
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
697
-        } else {
698
-            $message .= '</ul>';
699
-        }
700
-    }
689
+				$message .= implode(', ', $s_message);
690
+				$message .= '</li>';
691
+			}
692
+		}
693
+
694
+		if ( $message == '<ul>' ) {
695
+			$message = '';
696
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
697
+		} else {
698
+			$message .= '</ul>';
699
+		}
700
+	}
701 701
 
702 702
 	public static function item_count_message( $m, $type, &$s_message ) {
703
-        if ( ! $m ) {
704
-            return;
705
-        }
706
-
707
-        $strings = array(
708
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
709
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
710
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
711
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
712
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
713
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
714
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
715
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
716
-        );
703
+		if ( ! $m ) {
704
+			return;
705
+		}
706
+
707
+		$strings = array(
708
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
709
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
710
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
711
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
712
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
713
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
714
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
715
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
716
+		);
717 717
 
718 718
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
719
-    }
719
+	}
720 720
 
721 721
 	/**
722 722
 	 * Prepare the form options for export
@@ -750,16 +750,16 @@  discard block
 block discarded – undo
750 750
 	}
751 751
 
752 752
 	public static function cdata( $str ) {
753
-	    $str = maybe_unserialize($str);
754
-	    if ( is_array($str) ) {
755
-	        $str = json_encode($str);
753
+		$str = maybe_unserialize($str);
754
+		if ( is_array($str) ) {
755
+			$str = json_encode($str);
756 756
 		} else if ( seems_utf8( $str ) == false ) {
757 757
 			$str = utf8_encode( $str );
758 758
 		}
759 759
 
760
-        if ( is_numeric($str) ) {
761
-            return $str;
762
-        }
760
+		if ( is_numeric($str) ) {
761
+			return $str;
762
+		}
763 763
 
764 764
 		// $str = ent2ncr(esc_html($str));
765 765
 		$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
@@ -767,58 +767,58 @@  discard block
 block discarded – undo
767 767
 		return $str;
768 768
 	}
769 769
 
770
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
771
-        // Get post type
772
-        $post_type = FrmFormActionsController::$action_post_type;
773
-
774
-        // Set up imported index, if not set up yet
775
-        if ( ! isset( $imported['imported']['actions'] ) ) {
776
-            $imported['imported']['actions'] = 0;
777
-        }
778
-
779
-        // Migrate post settings to action
780
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
781
-
782
-        // Migrate email settings to action
783
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
784
-    }
785
-
786
-    /**
787
-    * Migrate post settings to form action
788
-    *
789
-    * @param string $post_type
790
-    */
791
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
792
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
793
-            return;
794
-        }
795
-
796
-        $new_action = array(
797
-            'post_type'     => $post_type,
798
-            'post_excerpt'  => 'wppost',
770
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
771
+		// Get post type
772
+		$post_type = FrmFormActionsController::$action_post_type;
773
+
774
+		// Set up imported index, if not set up yet
775
+		if ( ! isset( $imported['imported']['actions'] ) ) {
776
+			$imported['imported']['actions'] = 0;
777
+		}
778
+
779
+		// Migrate post settings to action
780
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
781
+
782
+		// Migrate email settings to action
783
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
784
+	}
785
+
786
+	/**
787
+	 * Migrate post settings to form action
788
+	 *
789
+	 * @param string $post_type
790
+	 */
791
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
792
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
793
+			return;
794
+		}
795
+
796
+		$new_action = array(
797
+			'post_type'     => $post_type,
798
+			'post_excerpt'  => 'wppost',
799 799
 			'post_title'    => __( 'Create Posts', 'formidable' ),
800
-            'menu_order'    => $form_id,
801
-            'post_status'   => 'publish',
802
-            'post_content'  => array(),
803
-            'post_name'     => $form_id .'_wppost_1',
804
-        );
805
-
806
-        $post_settings = array(
807
-            'post_type', 'post_category', 'post_content',
808
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
800
+			'menu_order'    => $form_id,
801
+			'post_status'   => 'publish',
802
+			'post_content'  => array(),
803
+			'post_name'     => $form_id .'_wppost_1',
804
+		);
805
+
806
+		$post_settings = array(
807
+			'post_type', 'post_category', 'post_content',
808
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
809 809
 			'post_status', 'post_custom_fields', 'post_password',
810
-        );
810
+		);
811 811
 
812
-        foreach ( $post_settings as $post_setting ) {
812
+		foreach ( $post_settings as $post_setting ) {
813 813
 			if ( isset( $form_options[ $post_setting ] ) ) {
814 814
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
815
-            }
816
-            unset($post_setting);
817
-        }
815
+			}
816
+			unset($post_setting);
817
+		}
818 818
 
819 819
 		$new_action['event'] = array( 'create', 'update' );
820 820
 
821
-        if ( $switch ) {
821
+		if ( $switch ) {
822 822
 			// Fields with string or int saved
823 823
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
824 824
 
@@ -826,22 +826,22 @@  discard block
 block discarded – undo
826 826
 			$array_fields = array( 'post_category', 'post_custom_fields' );
827 827
 
828 828
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
829
-        }
830
-        $new_action['post_content'] = json_encode($new_action['post_content']);
829
+		}
830
+		$new_action['post_content'] = json_encode($new_action['post_content']);
831 831
 
832
-        $exists = get_posts( array(
833
-            'name'          => $new_action['post_name'],
834
-            'post_type'     => $new_action['post_type'],
835
-            'post_status'   => $new_action['post_status'],
836
-            'numberposts'   => 1,
837
-        ) );
832
+		$exists = get_posts( array(
833
+			'name'          => $new_action['post_name'],
834
+			'post_type'     => $new_action['post_type'],
835
+			'post_status'   => $new_action['post_status'],
836
+			'numberposts'   => 1,
837
+		) );
838 838
 
839
-        if ( ! $exists ) {
839
+		if ( ! $exists ) {
840 840
 			// this isn't an email, but we need to use a class that will always be included
841 841
 			FrmAppHelper::save_json_post( $new_action );
842
-            $imported['imported']['actions']++;
843
-        }
844
-    }
842
+			$imported['imported']['actions']++;
843
+		}
844
+	}
845 845
 
846 846
 	/**
847 847
 	 * Switch old field IDs for new field IDs in emails and post
@@ -854,211 +854,211 @@  discard block
 block discarded – undo
854 854
 	 * @return string $post_content - new field IDs
855 855
 	 */
856 856
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
857
-        global $frm_duplicate_ids;
857
+		global $frm_duplicate_ids;
858 858
 
859
-        // If there aren't IDs that were switched, end now
860
-        if ( ! $frm_duplicate_ids ) {
861
-            return;
862
-        }
859
+		// If there aren't IDs that were switched, end now
860
+		if ( ! $frm_duplicate_ids ) {
861
+			return;
862
+		}
863 863
 
864
-        // Get old IDs
865
-        $old = array_keys( $frm_duplicate_ids );
864
+		// Get old IDs
865
+		$old = array_keys( $frm_duplicate_ids );
866 866
 
867
-        // Get new IDs
868
-        $new = array_values( $frm_duplicate_ids );
867
+		// Get new IDs
868
+		$new = array_values( $frm_duplicate_ids );
869 869
 
870
-        // Do a str_replace with each item to set the new IDs
871
-        foreach ( $post_content as $key => $setting ) {
872
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
873
-                // Replace old IDs with new IDs
870
+		// Do a str_replace with each item to set the new IDs
871
+		foreach ( $post_content as $key => $setting ) {
872
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
873
+				// Replace old IDs with new IDs
874 874
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
875
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
876
-                foreach ( $setting as $k => $val ) {
877
-                    // Replace old IDs with new IDs
875
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
876
+				foreach ( $setting as $k => $val ) {
877
+					// Replace old IDs with new IDs
878 878
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
879
-                }
880
-            }
881
-            unset( $key, $setting );
882
-        }
883
-        return $post_content;
884
-    }
885
-
886
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
887
-        // No old notifications or autoresponders to carry over
879
+				}
880
+			}
881
+			unset( $key, $setting );
882
+		}
883
+		return $post_content;
884
+	}
885
+
886
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
887
+		// No old notifications or autoresponders to carry over
888 888
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
889
-            return;
890
-        }
889
+			return;
890
+		}
891 891
 
892
-        // Initialize notifications array
893
-        $notifications = array();
892
+		// Initialize notifications array
893
+		$notifications = array();
894 894
 
895
-        // Migrate regular notifications
896
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
895
+		// Migrate regular notifications
896
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
897 897
 
898
-        // Migrate autoresponders
899
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
898
+		// Migrate autoresponders
899
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
900 900
 
901
-        if (  empty( $notifications ) ) {
902
-            return;
903
-        }
901
+		if (  empty( $notifications ) ) {
902
+			return;
903
+		}
904 904
 
905
-        foreach ( $notifications as $new_notification ) {
906
-            $new_notification['post_type']      = $post_type;
907
-            $new_notification['post_excerpt']   = 'email';
905
+		foreach ( $notifications as $new_notification ) {
906
+			$new_notification['post_type']      = $post_type;
907
+			$new_notification['post_excerpt']   = 'email';
908 908
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
909
-            $new_notification['menu_order']     = $form_id;
910
-            $new_notification['post_status']    = 'publish';
909
+			$new_notification['menu_order']     = $form_id;
910
+			$new_notification['post_status']    = 'publish';
911 911
 
912
-            // Switch field IDs and keys, if needed
913
-            if ( $switch ) {
912
+			// Switch field IDs and keys, if needed
913
+			if ( $switch ) {
914 914
 
915 915
 				// Switch field IDs in email conditional logic
916 916
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
917 917
 
918 918
 				// Switch all other field IDs in email
919
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
920
-            }
921
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
922
-
923
-            $exists = get_posts( array(
924
-                'name'          => $new_notification['post_name'],
925
-                'post_type'     => $new_notification['post_type'],
926
-                'post_status'   => $new_notification['post_status'],
927
-                'numberposts'   => 1,
928
-            ) );
929
-
930
-            if ( empty($exists) ) {
919
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
920
+			}
921
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
922
+
923
+			$exists = get_posts( array(
924
+				'name'          => $new_notification['post_name'],
925
+				'post_type'     => $new_notification['post_type'],
926
+				'post_status'   => $new_notification['post_status'],
927
+				'numberposts'   => 1,
928
+			) );
929
+
930
+			if ( empty($exists) ) {
931 931
 				FrmAppHelper::save_json_post( $new_notification );
932
-                $imported['imported']['actions']++;
933
-            }
934
-            unset($new_notification);
935
-        }
936
-    }
937
-
938
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
939
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
940
-            // add old settings into notification array
932
+				$imported['imported']['actions']++;
933
+			}
934
+			unset($new_notification);
935
+		}
936
+	}
937
+
938
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
939
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
940
+			// add old settings into notification array
941 941
 			$form_options['notification'] = array( 0 => $form_options );
942
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
943
-            // make sure it's in the correct format
942
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
943
+			// make sure it's in the correct format
944 944
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
945
-        }
945
+		}
946 946
 
947
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
948
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
947
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
948
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
949 949
 
950
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
950
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
951 951
 
952
-                // Format the email data
953
-                self::format_email_data( $atts, $notification );
952
+				// Format the email data
953
+				self::format_email_data( $atts, $notification );
954 954
 
955 955
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
956 956
 					do_action( 'frm_create_twilio_action', $atts, $notification );
957 957
 				}
958 958
 
959
-                // Setup the new notification
960
-                $new_notification = array();
961
-                self::setup_new_notification( $new_notification, $notification, $atts );
959
+				// Setup the new notification
960
+				$new_notification = array();
961
+				self::setup_new_notification( $new_notification, $notification, $atts );
962 962
 
963
-                $notifications[] = $new_notification;
964
-            }
965
-        }
966
-    }
963
+				$notifications[] = $new_notification;
964
+			}
965
+		}
966
+	}
967 967
 
968
-    private static function format_email_data( &$atts, $notification ) {
969
-        // Format email_to
970
-        self::format_email_to_data( $atts, $notification );
968
+	private static function format_email_data( &$atts, $notification ) {
969
+		// Format email_to
970
+		self::format_email_to_data( $atts, $notification );
971 971
 
972
-        // Format the reply to email and name
973
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
974
-        foreach ( $reply_fields as $f => $val ) {
972
+		// Format the reply to email and name
973
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
974
+		foreach ( $reply_fields as $f => $val ) {
975 975
 			if ( isset( $notification[ $f ] ) ) {
976 976
 				$atts[ $f ] = $notification[ $f ];
977 977
 				if ( 'custom' == $notification[ $f ] ) {
978 978
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
979 979
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
980 980
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
981
-                }
982
-            }
983
-            unset( $f, $val );
984
-        }
981
+				}
982
+			}
983
+			unset( $f, $val );
984
+		}
985 985
 
986
-        // Format event
986
+		// Format event
987 987
 		$atts['event'] = array( 'create' );
988
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
989
-            $atts['event'][] = 'update';
990
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
988
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
989
+			$atts['event'][] = 'update';
990
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
991 991
 			$atts['event'] = array( 'update' );
992
-        }
993
-    }
992
+		}
993
+	}
994 994
 
995
-    private static function format_email_to_data( &$atts, $notification ) {
996
-        if ( isset( $notification['email_to'] ) ) {
995
+	private static function format_email_to_data( &$atts, $notification ) {
996
+		if ( isset( $notification['email_to'] ) ) {
997 997
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
998
-        } else {
999
-            $atts['email_to'] = array();
1000
-        }
998
+		} else {
999
+			$atts['email_to'] = array();
1000
+		}
1001 1001
 
1002
-        if ( isset( $notification['also_email_to'] ) ) {
1003
-            $email_fields = (array) $notification['also_email_to'];
1004
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1005
-            unset( $email_fields );
1006
-        }
1002
+		if ( isset( $notification['also_email_to'] ) ) {
1003
+			$email_fields = (array) $notification['also_email_to'];
1004
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1005
+			unset( $email_fields );
1006
+		}
1007 1007
 
1008
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1008
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1009 1009
 
1010
-            if ( is_numeric( $email_field ) ) {
1010
+			if ( is_numeric( $email_field ) ) {
1011 1011
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1012
-            }
1012
+			}
1013 1013
 
1014
-            if ( strpos( $email_field, '|') ) {
1015
-                $email_opt = explode( '|', $email_field );
1016
-                if ( isset( $email_opt[0] ) ) {
1014
+			if ( strpos( $email_field, '|') ) {
1015
+				$email_opt = explode( '|', $email_field );
1016
+				if ( isset( $email_opt[0] ) ) {
1017 1017
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1018
-                }
1019
-                unset( $email_opt );
1020
-            }
1021
-        }
1022
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1023
-    }
1024
-
1025
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1026
-        // Set up new notification
1027
-        $new_notification = array(
1028
-            'post_content'  => array(
1029
-                'email_to'      => $atts['email_to'],
1030
-                'event'         => $atts['event'],
1031
-            ),
1032
-            'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
1033
-        );
1034
-
1035
-        // Add more fields to the new notification
1036
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1037
-        foreach ( $add_fields as $add_field ) {
1018
+				}
1019
+				unset( $email_opt );
1020
+			}
1021
+		}
1022
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1023
+	}
1024
+
1025
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1026
+		// Set up new notification
1027
+		$new_notification = array(
1028
+			'post_content'  => array(
1029
+				'email_to'      => $atts['email_to'],
1030
+				'event'         => $atts['event'],
1031
+			),
1032
+			'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
1033
+		);
1034
+
1035
+		// Add more fields to the new notification
1036
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1037
+		foreach ( $add_fields as $add_field ) {
1038 1038
 			if ( isset( $notification[ $add_field ] ) ) {
1039 1039
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1040
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1040
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1041 1041
 				$new_notification['post_content'][ $add_field ] = 0;
1042
-            } else {
1042
+			} else {
1043 1043
 				$new_notification['post_content'][ $add_field ] = '';
1044
-            }
1045
-            unset( $add_field );
1046
-        }
1044
+			}
1045
+			unset( $add_field );
1046
+		}
1047 1047
 
1048 1048
 		// Set reply to
1049 1049
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1050 1050
 
1051
-        // Set from
1051
+		// Set from
1052 1052
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1053
-            $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
1054
-        }
1055
-    }
1053
+			$new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
1054
+		}
1055
+	}
1056 1056
 
1057 1057
 	/**
1058
-	* Switch field IDs in pre-2.0 email conditional logic
1059
-	*
1060
-	* @param $post_content array, pass by reference
1061
-	*/
1058
+	 * Switch field IDs in pre-2.0 email conditional logic
1059
+	 *
1060
+	 * @param $post_content array, pass by reference
1061
+	 */
1062 1062
 	private static function switch_email_contition_field_ids( &$post_content ) {
1063 1063
 		// Switch field IDs in conditional logic
1064 1064
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1071,48 +1071,48 @@  discard block
 block discarded – undo
1071 1071
 		}
1072 1072
 	}
1073 1073
 
1074
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1075
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1076
-            // migrate autoresponder
1077
-
1078
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1079
-            if ( strpos($email_field, '|') ) {
1080
-                // data from entries field
1081
-                $email_field = explode('|', $email_field);
1082
-                if ( isset($email_field[1]) ) {
1083
-                    $email_field = $email_field[1];
1084
-                }
1085
-            }
1086
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1087
-                $email_field = '['. $email_field .']';
1088
-            }
1089
-
1090
-            $notification = $form_options;
1091
-            $new_notification2 = array(
1092
-                'post_content'  => array(
1093
-                    'email_message' => $notification['ar_email_message'],
1094
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1095
-                    'email_to'      => $email_field,
1096
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1097
-                    'inc_user_info' => 0,
1098
-                ),
1099
-                'post_name'     => $form_id .'_email_'. count( $notifications ),
1100
-            );
1101
-
1102
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1103
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1074
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1075
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1076
+			// migrate autoresponder
1077
+
1078
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1079
+			if ( strpos($email_field, '|') ) {
1080
+				// data from entries field
1081
+				$email_field = explode('|', $email_field);
1082
+				if ( isset($email_field[1]) ) {
1083
+					$email_field = $email_field[1];
1084
+				}
1085
+			}
1086
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1087
+				$email_field = '['. $email_field .']';
1088
+			}
1089
+
1090
+			$notification = $form_options;
1091
+			$new_notification2 = array(
1092
+				'post_content'  => array(
1093
+					'email_message' => $notification['ar_email_message'],
1094
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1095
+					'email_to'      => $email_field,
1096
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1097
+					'inc_user_info' => 0,
1098
+				),
1099
+				'post_name'     => $form_id .'_email_'. count( $notifications ),
1100
+			);
1101
+
1102
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1103
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1104 1104
 
1105 1105
 			if ( ! empty( $reply_to ) ) {
1106 1106
 				$new_notification2['post_content']['reply_to'] = $reply_to;
1107 1107
 			}
1108 1108
 
1109 1109
 			if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) {
1110
-                $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1110
+				$new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1111 1111
 			}
1112 1112
 
1113
-            $notifications[] = $new_notification2;
1114
-            unset( $new_notification2 );
1115
-        }
1116
-    }
1113
+			$notifications[] = $new_notification2;
1114
+			unset( $new_notification2 );
1115
+		}
1116
+	}
1117 1117
 }
1118 1118
 
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 				echo "\n" . $padding;
12 12
 				$tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok;
13 13
 				echo '<' . $tag . '>';
14
-				self::get_xml_values( $ov, $padding .'    ' );
14
+				self::get_xml_values( $ov, $padding . '    ' );
15 15
 				if ( is_array( $ov ) ) {
16 16
 					echo "\n" . $padding;
17 17
 				}
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94 94
                 'slug'          => (string) $t->term_slug,
95
-            ));
95
+            ) );
96 96
 
97 97
 			if ( $term && is_array( $term ) ) {
98
-                $imported['imported']['terms']++;
99
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
98
+                $imported['imported']['terms'] ++;
99
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
100 100
             }
101 101
 
102 102
 			unset( $term, $t );
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
                 'default_template' => (int) $item->default_template,
140 140
                 'editable'      => (int) $item->editable,
141 141
                 'status'        => (string) $item->status,
142
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
142
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
143
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
144 144
             );
145 145
 
146
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
147 147
 
148 148
 			self::update_custom_style_setting_on_import( $form );
149 149
 
@@ -153,35 +153,35 @@  discard block
 block discarded – undo
153 153
                 $edit_query['created_at'] = $form['created_at'];
154 154
             }
155 155
 
156
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
157 157
 
158
-            $this_form = FrmForm::getAll($edit_query, '', 1);
159
-            unset($edit_query);
158
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
159
+            unset( $edit_query );
160 160
 
161 161
             if ( ! empty( $this_form ) ) {
162 162
                 $old_id = $form_id = $this_form->id;
163
-                FrmForm::update($form_id, $form );
164
-                $imported['updated']['forms']++;
163
+                FrmForm::update( $form_id, $form );
164
+                $imported['updated']['forms'] ++;
165 165
                 // Keep track of whether this specific form was updated or not
166
-				$imported['form_status'][ $form_id ] = 'updated';
166
+				$imported['form_status'][$form_id] = 'updated';
167 167
 
168 168
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
169 169
                 $old_fields = array();
170 170
                 foreach ( $form_fields as $f ) {
171
-					$old_fields[ $f->id ] = $f;
172
-					$old_fields[ $f->field_key ] = $f->id;
173
-                    unset($f);
171
+					$old_fields[$f->id] = $f;
172
+					$old_fields[$f->field_key] = $f->id;
173
+                    unset( $f );
174 174
                 }
175 175
                 $form_fields = $old_fields;
176
-                unset($old_fields);
176
+                unset( $old_fields );
177 177
             } else {
178 178
                 $old_id = false;
179 179
                 //form does not exist, so create it
180 180
 				$form_id = FrmForm::create( $form );
181 181
                 if ( $form_id ) {
182
-                    $imported['imported']['forms']++;
182
+                    $imported['imported']['forms'] ++;
183 183
                     // Keep track of whether this specific form was updated or not
184
-					$imported['form_status'][ $form_id ] = 'imported';
184
+					$imported['form_status'][$form_id] = 'imported';
185 185
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
186 186
                 }
187 187
             }
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
     		// Delete any fields attached to this form that were not included in the template
192 192
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
193 193
 				foreach ( $form_fields as $field ) {
194
-                    if ( is_object($field) ) {
195
-                        FrmField::destroy($field->id);
194
+                    if ( is_object( $field ) ) {
195
+                        FrmField::destroy( $field->id );
196 196
                     }
197
-                    unset($field);
197
+                    unset( $field );
198 198
                 }
199
-                unset($form_fields);
199
+                unset( $form_fields );
200 200
             }
201 201
 
202 202
 		    // Update field ids/keys to new ones
203 203
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
204 204
 
205
-			$imported['forms'][ (int) $item->id ] = $form_id;
205
+			$imported['forms'][(int) $item->id] = $form_id;
206 206
 
207 207
             // Send pre 2.0 form options through function that creates actions
208 208
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
209 209
 
210
-		    unset($form, $item);
210
+		    unset( $form, $item );
211 211
 		}
212 212
 
213 213
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		$regular_forms = array();
227 227
 
228 228
 		foreach ( $forms as $form ) {
229
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
229
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
230 230
 
231 231
 			if ( $parent_form_id ) {
232 232
 				$child_forms[] = $form;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	*/
249 249
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
250 250
 		if ( $parent_form_id ) {
251
-			$child_forms[ $form_id ] = $parent_form_id;
251
+			$child_forms[$form_id] = $parent_form_id;
252 252
 		}
253 253
 	}
254 254
 
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
264 264
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
265 265
 
266
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
266
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
267 267
 				// Update all children with this old parent_form_id
268
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
268
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
269 269
 
270 270
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
271 271
 			}
@@ -286,51 +286,51 @@  discard block
 block discarded – undo
286 286
 		        'name'          => (string) $field->name,
287 287
 		        'description'   => (string) $field->description,
288 288
 		        'type'          => (string) $field->type,
289
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
289
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
290 290
 		        'field_order'   => (int) $field->field_order,
291 291
 		        'form_id'       => (int) $form_id,
292 292
 		        'required'      => (int) $field->required,
293
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
293
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
294 294
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
295 295
 		    );
296 296
 
297
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
297
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
298 298
 		        'text', 'email', 'url', 'textarea',
299
-		        'number','phone', 'date', 'time',
299
+		        'number', 'phone', 'date', 'time',
300 300
 		        'hidden', 'password', 'tag', 'image',
301
-		    )) ) {
302
-		        if ( count($f['default_value']) === 1 ) {
303
-		            $f['default_value'] = '['. reset($f['default_value']) .']';
301
+		    ) ) ) {
302
+		        if ( count( $f['default_value'] ) === 1 ) {
303
+		            $f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
304 304
 		        } else {
305
-		            $f['default_value'] = reset($f['default_value']);
305
+		            $f['default_value'] = reset( $f['default_value'] );
306 306
 		        }
307 307
 		    }
308 308
 
309
-		    $f = apply_filters('frm_duplicated_field', $f);
309
+		    $f = apply_filters( 'frm_duplicated_field', $f );
310 310
 
311 311
 			self::maybe_update_form_select( $f, $imported );
312 312
 
313
-		    if ( ! empty($this_form) ) {
313
+		    if ( ! empty( $this_form ) ) {
314 314
 		        // check for field to edit by field id
315
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
315
+				if ( isset( $form_fields[$f['id']] ) ) {
316 316
 		            FrmField::update( $f['id'], $f );
317
-		            $imported['updated']['fields']++;
317
+		            $imported['updated']['fields'] ++;
318 318
 
319
-					unset( $form_fields[ $f['id'] ] );
319
+					unset( $form_fields[$f['id']] );
320 320
 
321 321
 		            //unset old field key
322
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
323
-						unset( $form_fields[ $f['field_key'] ] );
322
+					if ( isset( $form_fields[$f['field_key']] ) ) {
323
+						unset( $form_fields[$f['field_key']] );
324 324
 					}
325
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
325
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
326 326
 		            // check for field to edit by field key
327
-		            unset($f['id']);
327
+		            unset( $f['id'] );
328 328
 
329
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
330
-		            $imported['updated']['fields']++;
329
+					FrmField::update( $form_fields[$f['field_key']], $f );
330
+		            $imported['updated']['fields'] ++;
331 331
 
332
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
333
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
332
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
333
+					unset( $form_fields[$f['field_key']] ); //unset old field key
334 334
 				} else {
335 335
 					$new_id = FrmField::create( $f );
336 336
 					if ( $new_id == false ) {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 					}
339 339
 
340 340
 		            // if no matching field id or key in this form, create the field
341
-		            $imported['imported']['fields']++;
341
+		            $imported['imported']['fields'] ++;
342 342
 		        }
343 343
 			} else {
344 344
 				$new_id = FrmField::create( $f );
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 					continue;
347 347
 				}
348 348
 
349
-	            $imported['imported']['fields']++;
349
+	            $imported['imported']['fields'] ++;
350 350
 		    }
351 351
 
352
-			unset($field, $new_id);
352
+			unset( $field, $new_id );
353 353
 		}
354 354
 	}
355 355
 
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
369 369
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
370 370
 				$form_select = $f['field_options']['form_select'];
371
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
372
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
371
+				if ( isset( $imported['forms'][$form_select] ) ) {
372
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
373 373
 				}
374 374
 			}
375 375
 		}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	*
384 384
 	*/
385 385
 	private static function update_custom_style_setting_on_import( &$form ) {
386
-		if ( is_numeric ( $form['options']['custom_style'] ) ) {
386
+		if ( is_numeric( $form['options']['custom_style'] ) ) {
387 387
 			// Set to default
388 388
 			$form['options']['custom_style'] = 1;
389 389
 		} else {
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 					$wpdb->prefix . 'posts
397 397
 				WHERE
398 398
 					post_name=%s';
399
-			$query = $wpdb->prepare($raw_query, $form['options']['custom_style']);
399
+			$query = $wpdb->prepare( $raw_query, $form['options']['custom_style'] );
400 400
 			$style_id = $wpdb->get_var( $query );
401 401
 			if ( $style_id ) {
402 402
 				$form['options']['custom_style'] = $style_id;
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
 				'post_id'       => (int) $item->post_id,
431 431
 				'post_parent'   => (int) $item->post_parent,
432 432
 				'menu_order'    => (int) $item->menu_order,
433
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
434
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
433
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
434
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
435 435
 				'is_sticky'     => (string) $item->is_sticky,
436 436
 				'comment_status' => (string) $item->comment_status,
437 437
 				'post_date'     => (string) $item->post_date,
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 			);
443 443
 
444 444
             $old_id = $post['post_id'];
445
-            self::populate_post($post, $item, $imported);
445
+            self::populate_post( $post, $item, $imported );
446 446
 
447
-			unset($item);
447
+			unset( $item );
448 448
 
449 449
 			$post_id = false;
450 450
             if ( $post['post_type'] == $form_action_type ) {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 				if ( $action_control ) {
453 453
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
454 454
 				}
455
-                unset($action_control);
455
+                unset( $action_control );
456 456
             } else if ( $post['post_type'] == 'frm_styles' ) {
457 457
                 // Properly encode post content before inserting the post
458 458
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -465,26 +465,26 @@  discard block
 block discarded – undo
465 465
                 $post_id = wp_insert_post( $post );
466 466
             }
467 467
 
468
-            if ( ! is_numeric($post_id) ) {
468
+            if ( ! is_numeric( $post_id ) ) {
469 469
                 continue;
470 470
             }
471 471
 
472
-            self::update_postmeta($post, $post_id);
472
+            self::update_postmeta( $post, $post_id );
473 473
 
474 474
             $this_type = 'posts';
475
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
476
-				$this_type = $post_types[ $post['post_type'] ];
475
+			if ( isset( $post_types[$post['post_type']] ) ) {
476
+				$this_type = $post_types[$post['post_type']];
477 477
             }
478 478
 
479
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
480
-                $imported['updated'][ $this_type ]++;
479
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
480
+                $imported['updated'][$this_type] ++;
481 481
             } else {
482
-                $imported['imported'][ $this_type ]++;
482
+                $imported['imported'][$this_type] ++;
483 483
             }
484 484
 
485
-            unset($post);
485
+            unset( $post );
486 486
 
487
-			$imported['posts'][ (int) $old_id ] = $post_id;
487
+			$imported['posts'][(int) $old_id] = $post_id;
488 488
 		}
489 489
 
490 490
 		self::maybe_update_stylesheet( $imported );
@@ -493,23 +493,23 @@  discard block
 block discarded – undo
493 493
     }
494 494
 
495 495
     private static function populate_post( &$post, $item, $imported ) {
496
-		if ( isset($item->attachment_url) ) {
496
+		if ( isset( $item->attachment_url ) ) {
497 497
 			$post['attachment_url'] = (string) $item->attachment_url;
498 498
 		}
499 499
 
500
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
500
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
501 501
 		    // update to new form id
502
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
502
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
503 503
 		}
504 504
 
505 505
 		foreach ( $item->postmeta as $meta ) {
506
-		    self::populate_postmeta($post, $meta, $imported);
507
-			unset($meta);
506
+		    self::populate_postmeta( $post, $meta, $imported );
507
+			unset( $meta );
508 508
 		}
509 509
 
510
-        self::populate_taxonomies($post, $item);
510
+        self::populate_taxonomies( $post, $item );
511 511
 
512
-        self::maybe_editing_post($post);
512
+        self::maybe_editing_post( $post );
513 513
     }
514 514
 
515 515
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -521,27 +521,27 @@  discard block
 block discarded – undo
521 521
 		);
522 522
 
523 523
 		//switch old form and field ids to new ones
524
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
525
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
524
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
525
+		    $m['value'] = $imported['forms'][(int) $m['value']];
526 526
 		} else {
527
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
527
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
528 528
 
529
-		    if ( ! empty($frm_duplicate_ids) ) {
529
+		    if ( ! empty( $frm_duplicate_ids ) ) {
530 530
 
531 531
 		        if ( $m['key'] == 'frm_dyncontent' ) {
532
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
532
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
533 533
     		    } else if ( $m['key'] == 'frm_options' ) {
534 534
 
535 535
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
536
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
537
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
536
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
537
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
538 538
     		            }
539 539
     		        }
540 540
 
541 541
                     $check_dup_array = array();
542 542
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
543
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
544
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
543
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
544
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
545 545
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
546 546
                             $check_dup_array[] = 'order_by';
547 547
     		            }
@@ -552,22 +552,22 @@  discard block
 block discarded – undo
552 552
     		        }
553 553
 
554 554
                     foreach ( $check_dup_array as $check_k ) {
555
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
556
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
557
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
555
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
556
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
557
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
558 558
 		                    }
559
-		                    unset($mk, $mv);
559
+		                    unset( $mk, $mv );
560 560
 		                }
561 561
                     }
562 562
     		    }
563 563
 		    }
564 564
 		}
565 565
 
566
-		if ( ! is_array($m['value']) ) {
567
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
566
+		if ( ! is_array( $m['value'] ) ) {
567
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
568 568
 		}
569 569
 
570
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
570
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
571 571
     }
572 572
 
573 573
     /**
@@ -583,23 +583,23 @@  discard block
 block discarded – undo
583 583
             }
584 584
 
585 585
 		    $taxonomy = (string) $att['domain'];
586
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
586
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
587 587
 		        $name = (string) $att['nicename'];
588
-		        $h_term = get_term_by('slug', $name, $taxonomy);
588
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
589 589
 		        if ( $h_term ) {
590 590
 		            $name = $h_term->term_id;
591 591
 		        }
592
-		        unset($h_term);
592
+		        unset( $h_term );
593 593
 		    } else {
594 594
 		        $name = (string) $c;
595 595
 		    }
596 596
 
597
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
598
-				$post['tax_input'][ $taxonomy ] = array();
597
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
598
+				$post['tax_input'][$taxonomy] = array();
599 599
 			}
600 600
 
601
-			$post['tax_input'][ $taxonomy ][] = $name;
602
-		    unset($name);
601
+			$post['tax_input'][$taxonomy][] = $name;
602
+		    unset( $name );
603 603
 		}
604 604
     }
605 605
 
@@ -616,29 +616,29 @@  discard block
 block discarded – undo
616 616
 
617 617
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
618 618
 		    $match_by['include'] = $post['post_id'];
619
-		    unset($match_by['name']);
619
+		    unset( $match_by['name'] );
620 620
 		}
621 621
 
622
-		$editing = get_posts($match_by);
622
+		$editing = get_posts( $match_by );
623 623
 
624
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
624
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
625 625
             // set the id of the post to edit
626
-            $post['ID'] = current($editing)->ID;
626
+            $post['ID'] = current( $editing )->ID;
627 627
         }
628 628
     }
629 629
 
630 630
     private static function update_postmeta( &$post, $post_id ) {
631 631
         foreach ( $post['postmeta'] as $k => $v ) {
632 632
             if ( '_edit_last' == $k ) {
633
-                $v = FrmAppHelper::get_user_id_param($v);
633
+                $v = FrmAppHelper::get_user_id_param( $v );
634 634
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
635 635
                 //change the attachment ID
636
-                $v = FrmProXMLHelper::get_file_id($v);
636
+                $v = FrmProXMLHelper::get_file_id( $v );
637 637
             }
638 638
 
639
-            update_post_meta($post_id, $k, $v);
639
+            update_post_meta( $post_id, $k, $v );
640 640
 
641
-            unset($k, $v);
641
+            unset( $k, $v );
642 642
         }
643 643
     }
644 644
 
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
      * @param string $message
656 656
      */
657 657
 	public static function parse_message( $result, &$message, &$errors ) {
658
-        if ( is_wp_error($result) ) {
658
+        if ( is_wp_error( $result ) ) {
659 659
             $errors[] = $result->get_error_message();
660 660
         } else if ( ! $result ) {
661 661
             return;
662 662
         }
663 663
 
664
-        if ( ! is_array($result) ) {
664
+        if ( ! is_array( $result ) ) {
665 665
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
666 666
             return;
667 667
         }
@@ -673,20 +673,20 @@  discard block
 block discarded – undo
673 673
 
674 674
         $message = '<ul>';
675 675
         foreach ( $result as $type => $results ) {
676
-			if ( ! isset( $t_strings[ $type ] ) ) {
676
+			if ( ! isset( $t_strings[$type] ) ) {
677 677
                 // only print imported and updated
678 678
                 continue;
679 679
             }
680 680
 
681 681
             $s_message = array();
682 682
             foreach ( $results as $k => $m ) {
683
-                self::item_count_message($m, $k, $s_message);
684
-                unset($k, $m);
683
+                self::item_count_message( $m, $k, $s_message );
684
+                unset( $k, $m );
685 685
             }
686 686
 
687
-            if ( ! empty($s_message) ) {
688
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
689
-                $message .= implode(', ', $s_message);
687
+            if ( ! empty( $s_message ) ) {
688
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
689
+                $message .= implode( ', ', $s_message );
690 690
                 $message .= '</li>';
691 691
             }
692 692
         }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
716 716
         );
717 717
 
718
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
718
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
719 719
     }
720 720
 
721 721
 	/**
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	 * @return string
727 727
 	 */
728 728
 	public static function prepare_form_options_for_export( $options ) {
729
-		$options = maybe_unserialize ( $options );
729
+		$options = maybe_unserialize( $options );
730 730
 		// Change custom_style to the post_name instead of ID
731 731
 		if ( isset( $options['custom_style'] ) && $options['custom_style'] !== 1 ) {
732 732
 			global $wpdb;
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 	}
751 751
 
752 752
 	public static function cdata( $str ) {
753
-	    $str = maybe_unserialize($str);
754
-	    if ( is_array($str) ) {
755
-	        $str = json_encode($str);
753
+	    $str = maybe_unserialize( $str );
754
+	    if ( is_array( $str ) ) {
755
+	        $str = json_encode( $str );
756 756
 		} else if ( seems_utf8( $str ) == false ) {
757 757
 			$str = utf8_encode( $str );
758 758
 		}
759 759
 
760
-        if ( is_numeric($str) ) {
760
+        if ( is_numeric( $str ) ) {
761 761
             return $str;
762 762
         }
763 763
 
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
     * @param string $post_type
790 790
     */
791 791
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
792
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
792
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
793 793
             return;
794 794
         }
795 795
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
             'menu_order'    => $form_id,
801 801
             'post_status'   => 'publish',
802 802
             'post_content'  => array(),
803
-            'post_name'     => $form_id .'_wppost_1',
803
+            'post_name'     => $form_id . '_wppost_1',
804 804
         );
805 805
 
806 806
         $post_settings = array(
@@ -810,10 +810,10 @@  discard block
 block discarded – undo
810 810
         );
811 811
 
812 812
         foreach ( $post_settings as $post_setting ) {
813
-			if ( isset( $form_options[ $post_setting ] ) ) {
814
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
813
+			if ( isset( $form_options[$post_setting] ) ) {
814
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
815 815
             }
816
-            unset($post_setting);
816
+            unset( $post_setting );
817 817
         }
818 818
 
819 819
 		$new_action['event'] = array( 'create', 'update' );
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
829 829
         }
830
-        $new_action['post_content'] = json_encode($new_action['post_content']);
830
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
831 831
 
832 832
         $exists = get_posts( array(
833 833
             'name'          => $new_action['post_name'],
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
         if ( ! $exists ) {
840 840
 			// this isn't an email, but we need to use a class that will always be included
841 841
 			FrmAppHelper::save_json_post( $new_action );
842
-            $imported['imported']['actions']++;
842
+            $imported['imported']['actions'] ++;
843 843
         }
844 844
     }
845 845
 
@@ -871,11 +871,11 @@  discard block
 block discarded – undo
871 871
         foreach ( $post_content as $key => $setting ) {
872 872
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
873 873
                 // Replace old IDs with new IDs
874
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
874
+				$post_content[$key] = str_replace( $old, $new, $setting );
875 875
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
876 876
                 foreach ( $setting as $k => $val ) {
877 877
                     // Replace old IDs with new IDs
878
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
878
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
879 879
                 }
880 880
             }
881 881
             unset( $key, $setting );
@@ -898,14 +898,14 @@  discard block
 block discarded – undo
898 898
         // Migrate autoresponders
899 899
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
900 900
 
901
-        if (  empty( $notifications ) ) {
901
+        if ( empty( $notifications ) ) {
902 902
             return;
903 903
         }
904 904
 
905 905
         foreach ( $notifications as $new_notification ) {
906 906
             $new_notification['post_type']      = $post_type;
907 907
             $new_notification['post_excerpt']   = 'email';
908
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
908
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
909 909
             $new_notification['menu_order']     = $form_id;
910 910
             $new_notification['post_status']    = 'publish';
911 911
 
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 				// Switch all other field IDs in email
919 919
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
920 920
             }
921
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
921
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
922 922
 
923 923
             $exists = get_posts( array(
924 924
                 'name'          => $new_notification['post_name'],
@@ -927,11 +927,11 @@  discard block
 block discarded – undo
927 927
                 'numberposts'   => 1,
928 928
             ) );
929 929
 
930
-            if ( empty($exists) ) {
930
+            if ( empty( $exists ) ) {
931 931
 				FrmAppHelper::save_json_post( $new_notification );
932
-                $imported['imported']['actions']++;
932
+                $imported['imported']['actions'] ++;
933 933
             }
934
-            unset($new_notification);
934
+            unset( $new_notification );
935 935
         }
936 936
     }
937 937
 
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
945 945
         }
946 946
 
947
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
947
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
948 948
             foreach ( $form_options['notification'] as $email_key => $notification ) {
949 949
 
950 950
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -972,12 +972,12 @@  discard block
 block discarded – undo
972 972
         // Format the reply to email and name
973 973
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
974 974
         foreach ( $reply_fields as $f => $val ) {
975
-			if ( isset( $notification[ $f ] ) ) {
976
-				$atts[ $f ] = $notification[ $f ];
977
-				if ( 'custom' == $notification[ $f ] ) {
978
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
979
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
980
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
975
+			if ( isset( $notification[$f] ) ) {
976
+				$atts[$f] = $notification[$f];
977
+				if ( 'custom' == $notification[$f] ) {
978
+					$atts[$f] = $notification['cust_' . $f];
979
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
980
+					$atts[$f] = '[' . $atts[$f] . ']';
981 981
                 }
982 982
             }
983 983
             unset( $f, $val );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		$atts['event'] = array( 'create' );
988 988
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
989 989
             $atts['event'][] = 'update';
990
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
990
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
991 991
 			$atts['event'] = array( 'update' );
992 992
         }
993 993
     }
@@ -1008,18 +1008,18 @@  discard block
 block discarded – undo
1008 1008
         foreach ( $atts['email_to'] as $key => $email_field ) {
1009 1009
 
1010 1010
             if ( is_numeric( $email_field ) ) {
1011
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1011
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1012 1012
             }
1013 1013
 
1014
-            if ( strpos( $email_field, '|') ) {
1014
+            if ( strpos( $email_field, '|' ) ) {
1015 1015
                 $email_opt = explode( '|', $email_field );
1016 1016
                 if ( isset( $email_opt[0] ) ) {
1017
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1017
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1018 1018
                 }
1019 1019
                 unset( $email_opt );
1020 1020
             }
1021 1021
         }
1022
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1022
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1023 1023
     }
1024 1024
 
1025 1025
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1029,18 +1029,18 @@  discard block
 block discarded – undo
1029 1029
                 'email_to'      => $atts['email_to'],
1030 1030
                 'event'         => $atts['event'],
1031 1031
             ),
1032
-            'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
1032
+            'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1033 1033
         );
1034 1034
 
1035 1035
         // Add more fields to the new notification
1036 1036
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1037 1037
         foreach ( $add_fields as $add_field ) {
1038
-			if ( isset( $notification[ $add_field ] ) ) {
1039
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1038
+			if ( isset( $notification[$add_field] ) ) {
1039
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1040 1040
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1041
-				$new_notification['post_content'][ $add_field ] = 0;
1041
+				$new_notification['post_content'][$add_field] = 0;
1042 1042
             } else {
1043
-				$new_notification['post_content'][ $add_field ] = '';
1043
+				$new_notification['post_content'][$add_field] = '';
1044 1044
             }
1045 1045
             unset( $add_field );
1046 1046
         }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
         // Set from
1052 1052
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1053
-            $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
1053
+            $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1054 1054
         }
1055 1055
     }
1056 1056
 
@@ -1064,50 +1064,50 @@  discard block
 block discarded – undo
1064 1064
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1065 1065
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1066 1066
 				if ( is_numeric( $email_key ) ) {
1067
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1067
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1068 1068
 				}
1069
-				unset( $email_key, $val);
1069
+				unset( $email_key, $val );
1070 1070
 			}
1071 1071
 		}
1072 1072
 	}
1073 1073
 
1074 1074
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1075
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1075
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1076 1076
             // migrate autoresponder
1077 1077
 
1078
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1079
-            if ( strpos($email_field, '|') ) {
1078
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1079
+            if ( strpos( $email_field, '|' ) ) {
1080 1080
                 // data from entries field
1081
-                $email_field = explode('|', $email_field);
1082
-                if ( isset($email_field[1]) ) {
1081
+                $email_field = explode( '|', $email_field );
1082
+                if ( isset( $email_field[1] ) ) {
1083 1083
                     $email_field = $email_field[1];
1084 1084
                 }
1085 1085
             }
1086
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1087
-                $email_field = '['. $email_field .']';
1086
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1087
+                $email_field = '[' . $email_field . ']';
1088 1088
             }
1089 1089
 
1090 1090
             $notification = $form_options;
1091 1091
             $new_notification2 = array(
1092 1092
                 'post_content'  => array(
1093 1093
                     'email_message' => $notification['ar_email_message'],
1094
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1094
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1095 1095
                     'email_to'      => $email_field,
1096
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1096
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1097 1097
                     'inc_user_info' => 0,
1098 1098
                 ),
1099
-                'post_name'     => $form_id .'_email_'. count( $notifications ),
1099
+                'post_name'     => $form_id . '_email_' . count( $notifications ),
1100 1100
             );
1101 1101
 
1102
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1103
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1102
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1103
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1104 1104
 
1105 1105
 			if ( ! empty( $reply_to ) ) {
1106 1106
 				$new_notification2['post_content']['reply_to'] = $reply_to;
1107 1107
 			}
1108 1108
 
1109 1109
 			if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) {
1110
-                $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1110
+                $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1111 1111
 			}
1112 1112
 
1113 1113
             $notifications[] = $new_notification2;
Please login to merge, or discard this patch.