Completed
Push — master ( 012bab...c8799f )
by Stephanie
09:13
created
classes/controllers/FrmFormsController.php 2 patches
Indentation   +625 added lines, -625 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,127 +24,127 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+			return self::create($values);
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
63
-            $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
62
+			$values = FrmFormsHelper::setup_new_vars($values);
63
+			$id = FrmForm::create( $values );
64
+			$form = FrmForm::getOne($id);
65 65
 
66
-            // add default email notification
67
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
66
+			// add default email notification
67
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
68
+			$action_control->create($form->id);
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72
-            $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
-        }
75
-    }
72
+			$values['id'] = $id;
73
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
+		}
75
+	}
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+		FrmAppHelper::permission_check('frm_edit_forms');
79 79
 
80
-        global $frm_vars;
81
-        if ( empty( $values ) ) {
82
-            $values = $_POST;
83
-        }
80
+		global $frm_vars;
81
+		if ( empty( $values ) ) {
82
+			$values = $_POST;
83
+		}
84 84
 
85
-        //Set radio button and checkbox meta equal to "other" value
86
-        if ( FrmAppHelper::pro_is_installed() ) {
87
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
88
-        }
85
+		//Set radio button and checkbox meta equal to "other" value
86
+		if ( FrmAppHelper::pro_is_installed() ) {
87
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
88
+		}
89 89
 
90 90
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
-            $frm_settings = FrmAppHelper::get_settings();
94
-            $errors = array( 'form' => $frm_settings->admin_permission );
95
-        } else {
96
-            $errors = FrmForm::validate($values);
97
-        }
92
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
+			$frm_settings = FrmAppHelper::get_settings();
94
+			$errors = array( 'form' => $frm_settings->admin_permission );
95
+		} else {
96
+			$errors = FrmForm::validate($values);
97
+		}
98 98
 
99
-        if ( count($errors) > 0 ) {
100
-            $hide_preview = true;
99
+		if ( count($errors) > 0 ) {
100
+			$hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102
-            $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
102
+			$form = FrmForm::getOne( $id );
103
+			$fields = FrmField::get_all_for_form($id);
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
-        } else {
110
-            FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
-        }
113
-    }
108
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
+		} else {
110
+			FrmForm::update( $id, $values, true );
111
+			die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
+		}
113
+	}
114 114
 
115
-    public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
115
+	public static function edit( $values = false ) {
116
+		FrmAppHelper::permission_check('frm_edit_forms');
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
120
-    }
119
+		return self::get_edit_vars($id);
120
+	}
121 121
 
122
-    public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
122
+	public static function settings( $id = false, $message = '' ) {
123
+		FrmAppHelper::permission_check('frm_edit_forms');
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+		if ( ! $id || ! is_numeric($id) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127
-        }
127
+		}
128 128
 		return self::get_settings_vars( $id, array(), $message );
129
-    }
129
+	}
130 130
 
131
-    public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function update_settings() {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
139
-        }
136
+		$errors = FrmForm::validate($_POST);
137
+		if ( count($errors) > 0 ) {
138
+			return self::get_settings_vars($id, $errors);
139
+		}
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+		do_action('frm_before_update_form_settings', $id);
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
145
-        $message = __( 'Settings Successfully Updated', 'formidable' );
145
+		$message = __( 'Settings Successfully Updated', 'formidable' );
146 146
 		return self::get_settings_vars( $id, array(), $message );
147
-    }
147
+	}
148 148
 
149 149
 	public static function edit_key() {
150 150
 		$values = self::edit_in_place_value( 'form_key' );
@@ -174,43 +174,43 @@  discard block
 block discarded – undo
174 174
 
175 175
 	public static function update( $values = array() ) {
176 176
 		if ( empty( $values ) ) {
177
-            $values = $_POST;
178
-        }
177
+			$values = $_POST;
178
+		}
179 179
 
180
-        //Set radio button and checkbox meta equal to "other" value
181
-        if ( FrmAppHelper::pro_is_installed() ) {
182
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
183
-        }
180
+		//Set radio button and checkbox meta equal to "other" value
181
+		if ( FrmAppHelper::pro_is_installed() ) {
182
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
183
+		}
184 184
 
185
-        $errors = FrmForm::validate( $values );
186
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
-        if ( $permission_error !== false ) {
188
-            $errors['form'] = $permission_error;
189
-        }
185
+		$errors = FrmForm::validate( $values );
186
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
+		if ( $permission_error !== false ) {
188
+			$errors['form'] = $permission_error;
189
+		}
190 190
 
191 191
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
192 192
 
193 193
 		if ( count( $errors ) > 0 ) {
194
-            return self::get_edit_vars( $id, $errors );
194
+			return self::get_edit_vars( $id, $errors );
195 195
 		} else {
196
-            FrmForm::update( $id, $values );
197
-            $message = __( 'Form was Successfully Updated', 'formidable' );
198
-            if ( defined( 'DOING_AJAX' ) ) {
196
+			FrmForm::update( $id, $values );
197
+			$message = __( 'Form was Successfully Updated', 'formidable' );
198
+			if ( defined( 'DOING_AJAX' ) ) {
199 199
 				wp_die( $message );
200
-            }
200
+			}
201 201
 			return self::get_edit_vars( $id, array(), $message );
202
-        }
203
-    }
202
+		}
203
+	}
204 204
 
205
-    public static function bulk_create_template( $ids ) {
206
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
205
+	public static function bulk_create_template( $ids ) {
206
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
207 207
 
208
-        foreach ( $ids as $id ) {
209
-            FrmForm::duplicate( $id, true, true );
210
-        }
208
+		foreach ( $ids as $id ) {
209
+			FrmForm::duplicate( $id, true, true );
210
+		}
211 211
 
212
-        return __( 'Form template was Successfully Created', 'formidable' );
213
-    }
212
+		return __( 'Form template was Successfully Created', 'formidable' );
213
+	}
214 214
 
215 215
 	/**
216 216
 	 * Redirect to the url for creating from a template
@@ -232,45 +232,45 @@  discard block
 block discarded – undo
232 232
 		wp_die();
233 233
 	}
234 234
 
235
-    public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
235
+	public static function duplicate() {
236
+		FrmAppHelper::permission_check('frm_edit_forms');
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
-        if ( $form ) {
239
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
+		if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243
-        } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
-        }
246
-    }
243
+		} else {
244
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
+		}
246
+	}
247 247
 
248
-    public static function page_preview() {
248
+	public static function page_preview() {
249 249
 		$params = FrmForm::list_page_params();
250
-        if ( ! $params['form'] ) {
251
-            return;
252
-        }
253
-
254
-        $form = FrmForm::getOne( $params['form'] );
255
-        if ( ! $form ) {
256
-            return;
257
-        }
258
-        return self::show_form( $form->id, '', true, true );
259
-    }
260
-
261
-    public static function preview() {
262
-        do_action( 'frm_wp' );
263
-
264
-        global $frm_vars;
265
-        $frm_vars['preview'] = true;
266
-
267
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
-            global $wp;
269
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
271
-            $wp->init();
272
-            $wp->register_globals();
273
-        }
250
+		if ( ! $params['form'] ) {
251
+			return;
252
+		}
253
+
254
+		$form = FrmForm::getOne( $params['form'] );
255
+		if ( ! $form ) {
256
+			return;
257
+		}
258
+		return self::show_form( $form->id, '', true, true );
259
+	}
260
+
261
+	public static function preview() {
262
+		do_action( 'frm_wp' );
263
+
264
+		global $frm_vars;
265
+		$frm_vars['preview'] = true;
266
+
267
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
+			global $wp;
269
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
+			include_once( $root.'/wp-config.php' );
271
+			$wp->init();
272
+			$wp->register_globals();
273
+		}
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
285 285
 		if ( empty( $form ) ) {
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287
-        }
287
+		}
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
-        wp_die();
291
-    }
289
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
+		wp_die();
291
+	}
292 292
 
293 293
 	public static function register_pro_scripts() {
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
@@ -298,22 +298,22 @@  discard block
 block discarded – undo
298 298
 		}
299 299
 	}
300 300
 
301
-    public static function untrash() {
301
+	public static function untrash() {
302 302
 		self::change_form_status( 'untrash' );
303
-    }
303
+	}
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+		FrmAppHelper::permission_check('frm_edit_forms');
307 307
 
308
-        $count = FrmForm::set_status( $ids, 'published' );
308
+		$count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
-        return $message;
312
-    }
310
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
+		return $message;
312
+	}
313 313
 
314
-    public static function trash() {
314
+	public static function trash() {
315 315
 		self::change_form_status( 'trash' );
316
-    }
316
+	}
317 317
 
318 318
 	/**
319 319
 	 * @param string $status
@@ -351,68 +351,68 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+		FrmAppHelper::permission_check('frm_delete_forms');
355 355
 
356
-        $count = 0;
357
-        foreach ( $ids as $id ) {
358
-            if ( FrmForm::trash( $id ) ) {
359
-                $count++;
360
-            }
361
-        }
356
+		$count = 0;
357
+		foreach ( $ids as $id ) {
358
+			if ( FrmForm::trash( $id ) ) {
359
+				$count++;
360
+			}
361
+		}
362 362
 
363
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
363
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
+		$message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
365 365
 
366
-        return $message;
367
-    }
366
+		return $message;
367
+	}
368 368
 
369
-    public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
369
+	public static function destroy() {
370
+		FrmAppHelper::permission_check('frm_delete_forms');
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374
-        //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
374
+		//check nonce url
375
+		check_admin_referer('destroy_form_' . $params['id']);
376 376
 
377
-        $count = 0;
378
-        if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
380
-        }
377
+		$count = 0;
378
+		if ( FrmForm::destroy( $params['id'] ) ) {
379
+			$count++;
380
+		}
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385
-    }
385
+	}
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+		FrmAppHelper::permission_check('frm_delete_forms');
389 389
 
390
-        $count = 0;
391
-        foreach ( $ids as $id ) {
392
-            $d = FrmForm::destroy( $id );
393
-            if ( $d ) {
394
-                $count++;
395
-            }
396
-        }
390
+		$count = 0;
391
+		foreach ( $ids as $id ) {
392
+			$d = FrmForm::destroy( $id );
393
+			if ( $d ) {
394
+				$count++;
395
+			}
396
+		}
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
399 399
 
400
-        return $message;
401
-    }
400
+		return $message;
401
+	}
402 402
 
403
-    private static function delete_all() {
404
-        //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
-        if ( $permission_error !== false ) {
403
+	private static function delete_all() {
404
+		//check nonce url
405
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
+		if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408
-            return;
409
-        }
408
+			return;
409
+		}
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415
-    }
415
+	}
416 416
 
417 417
 	public static function scheduled_delete( $delete_timestamp = '' ) {
418 418
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	}
421 421
 
422 422
 	/**
423
-	* Inserts Formidable button
424
-	* Hook exists since 2.5.0
425
-	*
426
-	* @since 2.0.15
427
-	*/
423
+	 * Inserts Formidable button
424
+	 * Hook exists since 2.5.0
425
+	 *
426
+	 * @since 2.0.15
427
+	 */
428 428
 	public static function insert_form_button() {
429 429
 		if ( current_user_can('frm_view_forms') ) {
430 430
 			$frm_settings = FrmAppHelper::get_settings();
@@ -433,49 +433,49 @@  discard block
 block discarded – undo
433 433
 		}
434 434
 	}
435 435
 
436
-    public static function insert_form_popup() {
436
+	public static function insert_form_popup() {
437 437
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
438 438
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
439
-            return;
440
-        }
439
+			return;
440
+		}
441 441
 
442
-        FrmAppHelper::load_admin_wide_js();
442
+		FrmAppHelper::load_admin_wide_js();
443 443
 
444
-        $shortcodes = array(
444
+		$shortcodes = array(
445 445
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
446
-        );
446
+		);
447 447
 
448
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
448
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
449 449
 
450
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
451
-    }
450
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
451
+	}
452 452
 
453
-    public static function get_shortcode_opts() {
453
+	public static function get_shortcode_opts() {
454 454
 		FrmAppHelper::permission_check('frm_view_forms');
455
-        check_ajax_referer( 'frm_ajax', 'nonce' );
455
+		check_ajax_referer( 'frm_ajax', 'nonce' );
456 456
 
457 457
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
458
-        if ( empty($shortcode) ) {
459
-            wp_die();
460
-        }
458
+		if ( empty($shortcode) ) {
459
+			wp_die();
460
+		}
461 461
 
462
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
463
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
462
+		echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
463
+		echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464 464
 
465
-        $form_id = '';
466
-        $opts = array();
465
+		$form_id = '';
466
+		$opts = array();
467 467
 		switch ( $shortcode ) {
468
-            case 'formidable':
469
-                $opts = array(
468
+			case 'formidable':
469
+				$opts = array(
470 470
 					'form_id'       => 'id',
471
-                    //'key' => ',
471
+					//'key' => ',
472 472
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
473 473
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
474 474
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
475
-                );
476
-            break;
477
-        }
478
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
475
+				);
476
+			break;
477
+		}
478
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
479 479
 
480 480
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
481 481
 			// allow other shortcodes to use the required form id option
@@ -483,63 +483,63 @@  discard block
 block discarded – undo
483 483
 			unset( $opts['form_id'] );
484 484
 		}
485 485
 
486
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
486
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
487 487
 
488
-        echo '</div>';
488
+		echo '</div>';
489 489
 
490
-        wp_die();
491
-    }
490
+		wp_die();
491
+	}
492 492
 
493 493
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
494
-        FrmAppHelper::permission_check( 'frm_view_forms' );
494
+		FrmAppHelper::permission_check( 'frm_view_forms' );
495 495
 		if ( ! empty( $deprecated_errors ) ) {
496 496
 			$errors = $deprecated_errors;
497 497
 			_deprecated_argument( 'errors', '2.0.8' );
498 498
 		}
499 499
 
500
-        global $wpdb, $frm_vars;
500
+		global $wpdb, $frm_vars;
501 501
 
502 502
 		if ( empty( $params ) ) {
503 503
 			$params = FrmForm::list_page_params();
504
-        }
504
+		}
505 505
 
506
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
506
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
507 507
 
508
-        $pagenum = $wp_list_table->get_pagenum();
508
+		$pagenum = $wp_list_table->get_pagenum();
509 509
 
510
-        $wp_list_table->prepare_items();
510
+		$wp_list_table->prepare_items();
511 511
 
512
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
513
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
512
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
513
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
514 514
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
515
-            die();
516
-        }
515
+			die();
516
+		}
517 517
 
518
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
519
-    }
518
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
519
+	}
520 520
 
521 521
 	public static function get_columns( $columns ) {
522
-	    $columns['cb'] = '<input type="checkbox" />';
523
-	    $columns['id'] = 'ID';
522
+		$columns['cb'] = '<input type="checkbox" />';
523
+		$columns['id'] = 'ID';
524 524
 
525
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
525
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
526 526
 
527
-        if ( 'template' == $type ) {
528
-            $columns['name']        = __( 'Template Name', 'formidable' );
529
-            $columns['type']        = __( 'Type', 'formidable' );
530
-            $columns['form_key']    = __( 'Key', 'formidable' );
531
-        } else {
532
-            $columns['name']        = __( 'Form Title', 'formidable' );
533
-            $columns['entries']     = __( 'Entries', 'formidable' );
534
-            $columns['form_key']    = __( 'Key', 'formidable' );
535
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
536
-        }
527
+		if ( 'template' == $type ) {
528
+			$columns['name']        = __( 'Template Name', 'formidable' );
529
+			$columns['type']        = __( 'Type', 'formidable' );
530
+			$columns['form_key']    = __( 'Key', 'formidable' );
531
+		} else {
532
+			$columns['name']        = __( 'Form Title', 'formidable' );
533
+			$columns['entries']     = __( 'Entries', 'formidable' );
534
+			$columns['form_key']    = __( 'Key', 'formidable' );
535
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
536
+		}
537 537
 
538
-        $columns['created_at'] = __( 'Date', 'formidable' );
538
+		$columns['created_at'] = __( 'Date', 'formidable' );
539 539
 
540 540
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
541 541
 
542
-        return $columns;
542
+		return $columns;
543 543
 	}
544 544
 
545 545
 	public static function get_sortable_columns() {
@@ -553,110 +553,110 @@  discard block
 block discarded – undo
553 553
 	}
554 554
 
555 555
 	public static function hidden_columns( $result ) {
556
-        $return = false;
557
-        foreach ( (array) $result as $r ) {
558
-            if ( ! empty( $r ) ) {
559
-                $return = true;
560
-                break;
561
-            }
562
-        }
556
+		$return = false;
557
+		foreach ( (array) $result as $r ) {
558
+			if ( ! empty( $r ) ) {
559
+				$return = true;
560
+				break;
561
+			}
562
+		}
563 563
 
564
-        if ( $return ) {
565
-            return $result;
564
+		if ( $return ) {
565
+			return $result;
566 566
 		}
567 567
 
568
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
568
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
569 569
 
570
-        $result[] = 'created_at';
571
-        if ( $type == 'template' ) {
572
-            $result[] = 'id';
573
-            $result[] = 'form_key';
574
-        }
570
+		$result[] = 'created_at';
571
+		if ( $type == 'template' ) {
572
+			$result[] = 'id';
573
+			$result[] = 'form_key';
574
+		}
575 575
 
576
-        return $result;
577
-    }
576
+		return $result;
577
+	}
578 578
 
579 579
 	public static function save_per_page( $save, $option, $value ) {
580
-        if ( $option == 'formidable_page_formidable_per_page' ) {
581
-            $save = (int) $value;
582
-        }
583
-        return $save;
584
-    }
580
+		if ( $option == 'formidable_page_formidable_per_page' ) {
581
+			$save = (int) $value;
582
+		}
583
+		return $save;
584
+	}
585 585
 
586 586
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
587
-        global $frm_vars;
587
+		global $frm_vars;
588 588
 
589
-        $form = FrmForm::getOne( $id );
590
-        if ( ! $form ) {
591
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
592
-        }
589
+		$form = FrmForm::getOne( $id );
590
+		if ( ! $form ) {
591
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
592
+		}
593 593
 
594
-        if ( $form->parent_form_id ) {
594
+		if ( $form->parent_form_id ) {
595 595
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' ));
596
-        }
596
+		}
597 597
 
598 598
 		$frm_field_selection = FrmField::field_selection();
599
-        $fields = FrmField::get_all_for_form($form->id);
599
+		$fields = FrmField::get_all_for_form($form->id);
600 600
 
601
-        // Automatically add end section fields if they don't exist (2.0 migration)
602
-        $reset_fields = false;
603
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
601
+		// Automatically add end section fields if they don't exist (2.0 migration)
602
+		$reset_fields = false;
603
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
604 604
 
605
-        if ( $reset_fields ) {
606
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
607
-        }
605
+		if ( $reset_fields ) {
606
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
607
+		}
608 608
 
609
-        unset($end_section_values, $last_order, $open, $reset_fields);
609
+		unset($end_section_values, $last_order, $open, $reset_fields);
610 610
 
611
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
611
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
612 612
 
613
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
614
-        if ( $form->is_template && $message == $edit_message ) {
615
-            $message = __( 'Template was Successfully Updated', 'formidable' );
616
-        }
613
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
614
+		if ( $form->is_template && $message == $edit_message ) {
615
+			$message = __( 'Template was Successfully Updated', 'formidable' );
616
+		}
617 617
 
618 618
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
619 619
 
620
-        if ( $form->default_template ) {
621
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
622
-        } else if ( defined('DOING_AJAX') ) {
623
-            wp_die();
624
-        } else if ( $create_link ) {
625
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
626
-        } else {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
628
-        }
629
-    }
620
+		if ( $form->default_template ) {
621
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
622
+		} else if ( defined('DOING_AJAX') ) {
623
+			wp_die();
624
+		} else if ( $create_link ) {
625
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
626
+		} else {
627
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
628
+		}
629
+	}
630 630
 
631 631
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
632 632
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
633 633
 
634
-        global $frm_vars;
634
+		global $frm_vars;
635 635
 
636
-        $form = FrmForm::getOne( $id );
636
+		$form = FrmForm::getOne( $id );
637 637
 
638
-        $fields = FrmField::get_all_for_form($id);
639
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
638
+		$fields = FrmField::get_all_for_form($id);
639
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640 640
 
641
-        if ( isset($values['default_template']) && $values['default_template'] ) {
642
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
643
-        }
641
+		if ( isset($values['default_template']) && $values['default_template'] ) {
642
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
643
+		}
644 644
 
645
-        $action_controls = FrmFormActionsController::get_form_actions();
645
+		$action_controls = FrmFormActionsController::get_form_actions();
646 646
 
647
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
648
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
647
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
648
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
649 649
 
650
-        $styles = apply_filters('frm_get_style_opts', array());
650
+		$styles = apply_filters('frm_get_style_opts', array());
651 651
 
652
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
653
-    }
652
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
653
+	}
654 654
 
655
-    public static function mb_tags_box( $form_id, $class = '' ) {
656
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
657
-        $linked_forms = array();
658
-        $col = 'one';
659
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
655
+	public static function mb_tags_box( $form_id, $class = '' ) {
656
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
657
+		$linked_forms = array();
658
+		$col = 'one';
659
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
660 660
 
661 661
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
662 662
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
665 665
 
666 666
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
667
-    }
667
+	}
668 668
 
669 669
 	/**
670 670
 	 * Get an array of the options to display in the advanced tab
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			''          => '',
706 706
 			'siteurl'   => __( 'Site URL', 'formidable' ),
707 707
 			'sitename'  => __( 'Site Name', 'formidable' ),
708
-        );
708
+		);
709 709
 
710 710
 		if ( ! FrmAppHelper::pro_is_installed() ) {
711 711
 			unset( $entry_shortcodes['post_id'] );
@@ -732,39 +732,39 @@  discard block
 block discarded – undo
732 732
 		return $entry_shortcodes;
733 733
 	}
734 734
 
735
-    // Insert the form class setting into the form
735
+	// Insert the form class setting into the form
736 736
 	public static function form_classes( $form ) {
737
-        if ( isset($form->options['form_class']) ) {
737
+		if ( isset($form->options['form_class']) ) {
738 738
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
739
-        }
740
-    }
739
+		}
740
+	}
741 741
 
742
-    public static function get_email_html() {
742
+	public static function get_email_html() {
743 743
 		FrmAppHelper::permission_check('frm_view_forms');
744
-        check_ajax_referer( 'frm_ajax', 'nonce' );
744
+		check_ajax_referer( 'frm_ajax', 'nonce' );
745 745
 		echo FrmEntryFormat::show_entry( array(
746 746
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
747
-	        'default_email' => true,
747
+			'default_email' => true,
748 748
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
749
-	    ) );
750
-	    wp_die();
749
+		) );
750
+		wp_die();
751 751
 	}
752 752
 
753
-    public static function filter_content( $content, $form, $entry = false ) {
753
+	public static function filter_content( $content, $form, $entry = false ) {
754 754
 		self::get_entry_by_param( $entry );
755
-        if ( ! $entry ) {
756
-            return $content;
757
-        }
755
+		if ( ! $entry ) {
756
+			return $content;
757
+		}
758 758
 
759
-        if ( is_object( $form ) ) {
760
-            $form = $form->id;
761
-        }
759
+		if ( is_object( $form ) ) {
760
+			$form = $form->id;
761
+		}
762 762
 
763
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
764
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
763
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
764
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
765 765
 
766
-        return $content;
767
-    }
766
+		return $content;
767
+	}
768 768
 
769 769
 	private static function get_entry_by_param( &$entry ) {
770 770
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -776,287 +776,287 @@  discard block
 block discarded – undo
776 776
 		}
777 777
 	}
778 778
 
779
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
780
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
781
-    }
779
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
780
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
781
+	}
782 782
 
783
-    public static function process_bulk_form_actions( $errors ) {
784
-        if ( ! $_REQUEST ) {
785
-            return $errors;
786
-        }
783
+	public static function process_bulk_form_actions( $errors ) {
784
+		if ( ! $_REQUEST ) {
785
+			return $errors;
786
+		}
787 787
 
788 788
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
789
-        if ( $bulkaction == -1 ) {
789
+		if ( $bulkaction == -1 ) {
790 790
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
791
-        }
792
-
793
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
794
-            FrmAppHelper::remove_get_action();
795
-
796
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
797
-        }
798
-
799
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
800
-        if ( empty( $ids ) ) {
801
-            $errors[] = __( 'No forms were specified', 'formidable' );
802
-            return $errors;
803
-        }
804
-
805
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
806
-        if ( $permission_error !== false ) {
807
-            $errors[] = $permission_error;
808
-            return $errors;
809
-        }
810
-
811
-        if ( ! is_array( $ids ) ) {
812
-            $ids = explode( ',', $ids );
813
-        }
814
-
815
-        switch ( $bulkaction ) {
816
-            case 'delete':
817
-                $message = self::bulk_destroy( $ids );
818
-            break;
819
-            case 'trash':
820
-                $message = self::bulk_trash( $ids );
821
-            break;
822
-            case 'untrash':
823
-                $message = self::bulk_untrash( $ids );
824
-            break;
825
-            case 'create_template':
826
-                $message = self::bulk_create_template( $ids );
827
-            break;
828
-        }
829
-
830
-        if ( isset( $message ) && ! empty( $message ) ) {
791
+		}
792
+
793
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
794
+			FrmAppHelper::remove_get_action();
795
+
796
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
797
+		}
798
+
799
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
800
+		if ( empty( $ids ) ) {
801
+			$errors[] = __( 'No forms were specified', 'formidable' );
802
+			return $errors;
803
+		}
804
+
805
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
806
+		if ( $permission_error !== false ) {
807
+			$errors[] = $permission_error;
808
+			return $errors;
809
+		}
810
+
811
+		if ( ! is_array( $ids ) ) {
812
+			$ids = explode( ',', $ids );
813
+		}
814
+
815
+		switch ( $bulkaction ) {
816
+			case 'delete':
817
+				$message = self::bulk_destroy( $ids );
818
+			break;
819
+			case 'trash':
820
+				$message = self::bulk_trash( $ids );
821
+			break;
822
+			case 'untrash':
823
+				$message = self::bulk_untrash( $ids );
824
+			break;
825
+			case 'create_template':
826
+				$message = self::bulk_create_template( $ids );
827
+			break;
828
+		}
829
+
830
+		if ( isset( $message ) && ! empty( $message ) ) {
831 831
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>';
832
-        }
832
+		}
833 833
 
834
-        return $errors;
835
-    }
834
+		return $errors;
835
+	}
836 836
 
837
-    public static function add_default_templates( $path, $default = true, $template = true ) {
838
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
837
+	public static function add_default_templates( $path, $default = true, $template = true ) {
838
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
839 839
 
840
-        $path = untrailingslashit(trim($path));
841
-        $templates = glob( $path .'/*.php' );
840
+		$path = untrailingslashit(trim($path));
841
+		$templates = glob( $path .'/*.php' );
842 842
 
843 843
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
844
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
844
+			$filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
845 845
 			$template_query = array( 'form_key' => $filename );
846
-            if ( $template ) {
847
-                $template_query['is_template'] = 1;
848
-            }
849
-            if ( $default ) {
850
-                $template_query['default_template'] = 1;
851
-            }
846
+			if ( $template ) {
847
+				$template_query['is_template'] = 1;
848
+			}
849
+			if ( $default ) {
850
+				$template_query['default_template'] = 1;
851
+			}
852 852
 			$form = FrmForm::getAll( $template_query, '', 1 );
853 853
 
854
-            $values = FrmFormsHelper::setup_new_vars();
855
-            $values['form_key'] = $filename;
856
-            $values['is_template'] = $template;
857
-            $values['status'] = 'published';
858
-            if ( $default ) {
859
-                $values['default_template'] = 1;
860
-            }
861
-
862
-            include( $templates[ $i ] );
863
-
864
-            //get updated form
865
-            if ( isset($form) && ! empty($form) ) {
866
-                $old_id = $form->id;
867
-                $form = FrmForm::getOne($form->id);
868
-            } else {
869
-                $old_id = false;
854
+			$values = FrmFormsHelper::setup_new_vars();
855
+			$values['form_key'] = $filename;
856
+			$values['is_template'] = $template;
857
+			$values['status'] = 'published';
858
+			if ( $default ) {
859
+				$values['default_template'] = 1;
860
+			}
861
+
862
+			include( $templates[ $i ] );
863
+
864
+			//get updated form
865
+			if ( isset($form) && ! empty($form) ) {
866
+				$old_id = $form->id;
867
+				$form = FrmForm::getOne($form->id);
868
+			} else {
869
+				$old_id = false;
870 870
 				$form = FrmForm::getAll( $template_query, '', 1 );
871
-            }
871
+			}
872 872
 
873
-            if ( $form ) {
873
+			if ( $form ) {
874 874
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
875
-            }
876
-        }
877
-    }
875
+			}
876
+		}
877
+	}
878 878
 
879
-    public static function route() {
880
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
881
-        $vars = array();
879
+	public static function route() {
880
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
881
+		$vars = array();
882 882
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
883 883
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
884 884
 
885
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
886
-            $json_vars = json_decode($json_vars, true);
887
-            if ( empty($json_vars) ) {
888
-                // json decoding failed so we should return an error message
885
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
886
+			$json_vars = json_decode($json_vars, true);
887
+			if ( empty($json_vars) ) {
888
+				// json decoding failed so we should return an error message
889 889
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
890
-                if ( 'edit' == $action ) {
891
-                    $action = 'update';
892
-                }
893
-
894
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
895
-            } else {
896
-                $vars = FrmAppHelper::json_to_array($json_vars);
897
-                $action = $vars[ $action ];
890
+				if ( 'edit' == $action ) {
891
+					$action = 'update';
892
+				}
893
+
894
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
895
+			} else {
896
+				$vars = FrmAppHelper::json_to_array($json_vars);
897
+				$action = $vars[ $action ];
898 898
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
899 899
 				$_REQUEST = array_merge( $_REQUEST, $vars );
900 900
 				$_POST = array_merge( $_POST, $_REQUEST );
901
-            }
902
-        } else {
901
+			}
902
+		} else {
903 903
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
904
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
905
-                // override the action for this page
906
-    			$action = 'delete_all';
907
-            }
908
-        }
904
+			if ( isset( $_REQUEST['delete_all'] ) ) {
905
+				// override the action for this page
906
+				$action = 'delete_all';
907
+			}
908
+		}
909 909
 
910 910
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
911
-        FrmAppHelper::trigger_hook_load( 'form' );
912
-
913
-        switch ( $action ) {
914
-            case 'new':
915
-                return self::new_form($vars);
916
-            case 'create':
917
-            case 'edit':
918
-            case 'update':
919
-            case 'duplicate':
920
-            case 'trash':
921
-            case 'untrash':
922
-            case 'destroy':
923
-            case 'delete_all':
924
-            case 'settings':
925
-            case 'update_settings':
911
+		FrmAppHelper::trigger_hook_load( 'form' );
912
+
913
+		switch ( $action ) {
914
+			case 'new':
915
+				return self::new_form($vars);
916
+			case 'create':
917
+			case 'edit':
918
+			case 'update':
919
+			case 'duplicate':
920
+			case 'trash':
921
+			case 'untrash':
922
+			case 'destroy':
923
+			case 'delete_all':
924
+			case 'settings':
925
+			case 'update_settings':
926 926
 				return self::$action( $vars );
927
-            default:
928
-                do_action('frm_form_action_'. $action);
929
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
930
-                    return;
931
-                }
927
+			default:
928
+				do_action('frm_form_action_'. $action);
929
+				if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
930
+					return;
931
+				}
932 932
 
933 933
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
934
-                if ( $action == -1 ) {
934
+				if ( $action == -1 ) {
935 935
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
936
-                }
936
+				}
937 937
 
938
-                if ( strpos($action, 'bulk_') === 0 ) {
939
-                    FrmAppHelper::remove_get_action();
940
-                    return self::list_form();
941
-                }
938
+				if ( strpos($action, 'bulk_') === 0 ) {
939
+					FrmAppHelper::remove_get_action();
940
+					return self::list_form();
941
+				}
942 942
 
943
-                return self::display_forms_list();
944
-        }
945
-    }
943
+				return self::display_forms_list();
944
+		}
945
+	}
946 946
 
947
-    public static function json_error( $errors ) {
948
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
949
-        return $errors;
950
-    }
947
+	public static function json_error( $errors ) {
948
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
949
+		return $errors;
950
+	}
951 951
 
952 952
 
953
-    /* FRONT-END FORMS */
954
-    public static function admin_bar_css() {
953
+	/* FRONT-END FORMS */
954
+	public static function admin_bar_css() {
955 955
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
956
-            return;
957
-        }
956
+			return;
957
+		}
958 958
 
959 959
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
960 960
 		FrmAppHelper::load_font_style();
961 961
 	}
962 962
 
963 963
 	public static function admin_bar_configure() {
964
-        global $frm_vars;
965
-        if ( empty($frm_vars['forms_loaded']) ) {
966
-            return;
967
-        }
968
-
969
-        $actions = array();
970
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
971
-            if ( is_object($form) ) {
972
-                $actions[ $form->id ] = $form->name;
973
-            }
974
-            unset($form);
975
-        }
976
-
977
-        if ( empty($actions) ) {
978
-            return;
979
-        }
980
-
981
-        asort($actions);
982
-
983
-        global $wp_admin_bar;
984
-
985
-        if ( count($actions) == 1 ) {
986
-            $wp_admin_bar->add_menu( array(
987
-                'title' => 'Edit Form',
988
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
989
-                'id'    => 'frm-forms',
990
-            ) );
991
-        } else {
992
-            $wp_admin_bar->add_menu( array(
993
-        		'id'    => 'frm-forms',
994
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
995
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
996
-        		'meta'  => array(
964
+		global $frm_vars;
965
+		if ( empty($frm_vars['forms_loaded']) ) {
966
+			return;
967
+		}
968
+
969
+		$actions = array();
970
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
971
+			if ( is_object($form) ) {
972
+				$actions[ $form->id ] = $form->name;
973
+			}
974
+			unset($form);
975
+		}
976
+
977
+		if ( empty($actions) ) {
978
+			return;
979
+		}
980
+
981
+		asort($actions);
982
+
983
+		global $wp_admin_bar;
984
+
985
+		if ( count($actions) == 1 ) {
986
+			$wp_admin_bar->add_menu( array(
987
+				'title' => 'Edit Form',
988
+				'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
989
+				'id'    => 'frm-forms',
990
+			) );
991
+		} else {
992
+			$wp_admin_bar->add_menu( array(
993
+				'id'    => 'frm-forms',
994
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
995
+				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
996
+				'meta'  => array(
997 997
 					'title' => __( 'Edit Forms', 'formidable' ),
998
-        		),
999
-        	) );
998
+				),
999
+			) );
1000 1000
 
1001
-        	foreach ( $actions as $form_id => $name ) {
1001
+			foreach ( $actions as $form_id => $name ) {
1002 1002
 
1003
-        		$wp_admin_bar->add_menu( array(
1004
-        			'parent'    => 'frm-forms',
1005
-        			'id'        => 'edit_form_'. $form_id,
1006
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1003
+				$wp_admin_bar->add_menu( array(
1004
+					'parent'    => 'frm-forms',
1005
+					'id'        => 'edit_form_'. $form_id,
1006
+					'title'     => empty($name) ? __( '(no title)') : $name,
1007 1007
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1008
-        		) );
1009
-        	}
1010
-        }
1011
-    }
1008
+				) );
1009
+			}
1010
+		}
1011
+	}
1012 1012
 
1013
-    //formidable shortcode
1013
+	//formidable shortcode
1014 1014
 	public static function get_form_shortcode( $atts ) {
1015
-        global $frm_vars;
1016
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1017
-            $sc = '[formidable';
1015
+		global $frm_vars;
1016
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1017
+			$sc = '[formidable';
1018 1018
 			if ( ! empty( $atts ) ) {
1019 1019
 				foreach ( $atts as $k => $v ) {
1020 1020
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1021 1021
 				}
1022 1022
 			}
1023
-            return $sc .']';
1024
-        }
1025
-
1026
-        $shortcode_atts = shortcode_atts( array(
1027
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1028
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1029
-            'exclude_fields' => array(), 'minimize' => false,
1030
-        ), $atts);
1031
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1032
-
1033
-        return self::show_form(
1034
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1035
-            $shortcode_atts['description'], $atts
1036
-        );
1037
-    }
1038
-
1039
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1040
-        if ( empty( $id ) ) {
1041
-            $id = $key;
1042
-        }
1043
-
1044
-        // no form id or key set
1045
-        if ( empty( $id ) ) {
1046
-            return __( 'Please select a valid form', 'formidable' );
1047
-        }
1048
-
1049
-        $form = FrmForm::getOne( $id );
1050
-        if ( ! $form || $form->parent_form_id ) {
1051
-            return __( 'Please select a valid form', 'formidable' );
1052
-        }
1023
+			return $sc .']';
1024
+		}
1025
+
1026
+		$shortcode_atts = shortcode_atts( array(
1027
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1028
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1029
+			'exclude_fields' => array(), 'minimize' => false,
1030
+		), $atts);
1031
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1032
+
1033
+		return self::show_form(
1034
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1035
+			$shortcode_atts['description'], $atts
1036
+		);
1037
+	}
1038
+
1039
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1040
+		if ( empty( $id ) ) {
1041
+			$id = $key;
1042
+		}
1043
+
1044
+		// no form id or key set
1045
+		if ( empty( $id ) ) {
1046
+			return __( 'Please select a valid form', 'formidable' );
1047
+		}
1048
+
1049
+		$form = FrmForm::getOne( $id );
1050
+		if ( ! $form || $form->parent_form_id ) {
1051
+			return __( 'Please select a valid form', 'formidable' );
1052
+		}
1053 1053
 
1054 1054
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1055
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1055
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1056 1056
 
1057
-        $form = apply_filters( 'frm_pre_display_form', $form );
1057
+		$form = apply_filters( 'frm_pre_display_form', $form );
1058 1058
 
1059
-        $frm_settings = FrmAppHelper::get_settings();
1059
+		$frm_settings = FrmAppHelper::get_settings();
1060 1060
 
1061 1061
 		if ( self::is_viewable_draft_form( $form ) ) {
1062 1062
 			// don't show a draft form on a page
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		}
1078 1078
 
1079 1079
 		return $form;
1080
-    }
1080
+	}
1081 1081
 
1082 1082
 	private static function is_viewable_draft_form( $form ) {
1083 1083
 		global $post;
@@ -1093,98 +1093,98 @@  discard block
 block discarded – undo
1093 1093
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1094 1094
 	}
1095 1095
 
1096
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1097
-        ob_start();
1096
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1097
+		ob_start();
1098 1098
 
1099
-        self::get_form_contents( $form, $title, $description, $atts );
1099
+		self::get_form_contents( $form, $title, $description, $atts );
1100 1100
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1101 1101
 
1102
-        $contents = ob_get_contents();
1103
-        ob_end_clean();
1102
+		$contents = ob_get_contents();
1103
+		ob_end_clean();
1104 1104
 
1105 1105
 		self::maybe_minimize_form( $atts, $contents );
1106 1106
 
1107
-        return $contents;
1108
-    }
1107
+		return $contents;
1108
+	}
1109 1109
 
1110 1110
 	public static function enqueue_scripts( $params ) {
1111 1111
 		do_action( 'frm_enqueue_form_scripts', $params );
1112 1112
 	}
1113 1113
 
1114 1114
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1115
-        global $frm_vars;
1115
+		global $frm_vars;
1116 1116
 
1117
-        $frm_settings = FrmAppHelper::get_settings();
1117
+		$frm_settings = FrmAppHelper::get_settings();
1118 1118
 
1119
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1119
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1120 1120
 
1121
-        $user_ID = get_current_user_id();
1121
+		$user_ID = get_current_user_id();
1122 1122
 		$params = FrmForm::get_params( $form );
1123
-        $message = $errors = '';
1123
+		$message = $errors = '';
1124 1124
 
1125
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1126
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1127
-        }
1125
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1126
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1127
+		}
1128 1128
 
1129 1129
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1130
-        $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1131
-
1132
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1133
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1134
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1135
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1136
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1137
-            }
1138
-            return;
1139
-        }
1140
-
1141
-        if ( ! empty($errors) ) {
1142
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1143
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1144
-            return;
1145
-        }
1146
-
1147
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1148
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1149
-            return;
1150
-        }
1151
-
1152
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1153
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1154
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1155
-
1156
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1157
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1130
+		$fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1131
+
1132
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1133
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1134
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1135
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1136
+				include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1137
+			}
1138
+			return;
1139
+		}
1140
+
1141
+		if ( ! empty($errors) ) {
1142
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1143
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1144
+			return;
1145
+		}
1146
+
1147
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1148
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1149
+			return;
1150
+		}
1151
+
1152
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1153
+		$created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1154
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1155
+
1156
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1157
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1158 1158
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1159
-            return;
1160
-        }
1159
+			return;
1160
+		}
1161 1161
 
1162
-        if ( $created && is_numeric($created) ) {
1163
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164
-            $class = 'frm_message';
1165
-        } else {
1166
-            $message = $frm_settings->failed_msg;
1167
-            $class = 'frm_error_style';
1168
-        }
1162
+		if ( $created && is_numeric($created) ) {
1163
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164
+			$class = 'frm_message';
1165
+		} else {
1166
+			$message = $frm_settings->failed_msg;
1167
+			$class = 'frm_error_style';
1168
+		}
1169 1169
 
1170 1170
 		$message = FrmFormsHelper::get_success_message( array(
1171 1171
 			'message' => $message, 'form' => $form,
1172 1172
 			'entry_id' => $created, 'class' => $class,
1173 1173
 		) );
1174
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1174
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1175 1175
 
1176
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1177
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1178
-        } else {
1179
-            global $frm_vars;
1176
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1177
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1178
+		} else {
1179
+			global $frm_vars;
1180 1180
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1181 1181
 
1182
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1183
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1184
-        }
1182
+			$include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1183
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1184
+		}
1185 1185
 
1186 1186
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1187
-    }
1187
+	}
1188 1188
 
1189 1189
 	public static function front_head() {
1190 1190
 		$version = FrmAppHelper::plugin_version();
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,49 +33,49 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+            return self::create( $values );
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
62
+            $values = FrmFormsHelper::setup_new_vars( $values );
63 63
             $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
64
+            $form = FrmForm::getOne( $id );
65 65
 
66 66
             // add default email notification
67 67
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
68
+            $action_control->create( $form->id );
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72 72
             $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
73
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
74 74
         }
75 75
     }
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
79 79
 
80 80
         global $frm_vars;
81 81
         if ( empty( $values ) ) {
@@ -87,58 +87,58 @@  discard block
 block discarded – undo
87 87
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
88 88
         }
89 89
 
90
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
90
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92 92
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93 93
             $frm_settings = FrmAppHelper::get_settings();
94 94
             $errors = array( 'form' => $frm_settings->admin_permission );
95 95
         } else {
96
-            $errors = FrmForm::validate($values);
96
+            $errors = FrmForm::validate( $values );
97 97
         }
98 98
 
99
-        if ( count($errors) > 0 ) {
99
+        if ( count( $errors ) > 0 ) {
100 100
             $hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102 102
             $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
103
+            $fields = FrmField::get_all_for_form( $id );
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
108
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
109 109
         } else {
110 110
             FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
111
+            die( FrmAppHelper::js_redirect( admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ) ) );
112 112
         }
113 113
     }
114 114
 
115 115
     public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
116
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
119
+        return self::get_edit_vars( $id );
120 120
     }
121 121
 
122 122
     public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
123
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+        if ( ! $id || ! is_numeric( $id ) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127 127
         }
128 128
 		return self::get_settings_vars( $id, array(), $message );
129 129
     }
130 130
 
131 131
     public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
136
+        $errors = FrmForm::validate( $_POST );
137
+        if ( count( $errors ) > 0 ) {
138
+            return self::get_settings_vars( $id, $errors );
139 139
         }
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+        do_action( 'frm_before_update_form_settings', $id );
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
 	private static function edit_in_place_value( $field ) {
162 162
 		check_ajax_referer( 'frm_ajax', 'nonce' );
163
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
163
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
164 164
 
165 165
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
166 166
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @since 2.0
219 219
 	 */
220 220
 	public static function _create_from_template() {
221
-		FrmAppHelper::permission_check('frm_edit_forms');
221
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
222 222
 		check_ajax_referer( 'frm_ajax', 'nonce' );
223 223
 
224 224
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 
235 235
     public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
236
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239 239
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
240
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241 241
         if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243 243
         } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
244
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
245 245
         }
246 246
     }
247 247
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
         if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268 268
             global $wp;
269 269
             $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
270
+            include_once( $root . '/wp-config.php' );
271 271
             $wp->init();
272 272
             $wp->register_globals();
273 273
         }
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
277
-		header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
277
+		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
278 278
 
279 279
 		$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
280 280
 		if ( $key == '' ) {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287 287
         }
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
289
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
290 290
         wp_die();
291 291
     }
292 292
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
295 295
 			wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
296 296
 			wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
297
-			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true );
297
+			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true );
298 298
 		}
299 299
 	}
300 300
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
     }
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
307 307
 
308 308
         $count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
310
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311 311
         return $message;
312 312
     }
313 313
 
@@ -326,90 +326,90 @@  discard block
 block discarded – undo
326 326
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
327 327
 		);
328 328
 
329
-		if ( ! isset( $available_status[ $status ] ) ) {
329
+		if ( ! isset( $available_status[$status] ) ) {
330 330
 			return;
331 331
 		}
332 332
 
333
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
333
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
334 334
 
335 335
 		$params = FrmForm::list_page_params();
336 336
 
337 337
 		//check nonce url
338
-		check_admin_referer($status .'_form_' . $params['id']);
338
+		check_admin_referer( $status . '_form_' . $params['id'] );
339 339
 
340 340
 		$count = 0;
341
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
342
-			$count++;
341
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
342
+			$count ++;
343 343
 		}
344 344
 
345
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
-		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
345
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
+		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
347 347
 
348
-		$message = $available_status[ $status ]['message'];
348
+		$message = $available_status[$status]['message'];
349 349
 
350 350
 		self::display_forms_list( $params, $message );
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
355 355
 
356 356
         $count = 0;
357 357
         foreach ( $ids as $id ) {
358 358
             if ( FrmForm::trash( $id ) ) {
359
-                $count++;
359
+                $count ++;
360 360
             }
361 361
         }
362 362
 
363 363
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
364
+        $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action[]=' . implode( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
365 365
 
366 366
         return $message;
367 367
     }
368 368
 
369 369
     public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
370
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374 374
         //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
375
+        check_admin_referer( 'destroy_form_' . $params['id'] );
376 376
 
377 377
         $count = 0;
378 378
         if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
379
+            $count ++;
380 380
         }
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385 385
     }
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
389 389
 
390 390
         $count = 0;
391 391
         foreach ( $ids as $id ) {
392 392
             $d = FrmForm::destroy( $id );
393 393
             if ( $d ) {
394
-                $count++;
394
+                $count ++;
395 395
             }
396 396
         }
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
399 399
 
400 400
         return $message;
401 401
     }
402 402
 
403 403
     private static function delete_all() {
404 404
         //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
405
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
406 406
         if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408 408
             return;
409 409
         }
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415 415
     }
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 	* @since 2.0.15
427 427
 	*/
428 428
 	public static function insert_form_button() {
429
-		if ( current_user_can('frm_view_forms') ) {
429
+		if ( current_user_can( 'frm_view_forms' ) ) {
430 430
 			$frm_settings = FrmAppHelper::get_settings();
431
-			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"><span class="frm-buttons-icon wp-media-buttons-icon"></span> '. $frm_settings->menu .'</a>';
431
+			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"><span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . $frm_settings->menu . '</a>';
432 432
 			echo wp_kses_post( $content );
433 433
 		}
434 434
 	}
@@ -445,22 +445,22 @@  discard block
 block discarded – undo
445 445
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
446 446
         );
447 447
 
448
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
448
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
449 449
 
450
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
450
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
451 451
     }
452 452
 
453 453
     public static function get_shortcode_opts() {
454
-		FrmAppHelper::permission_check('frm_view_forms');
454
+		FrmAppHelper::permission_check( 'frm_view_forms' );
455 455
         check_ajax_referer( 'frm_ajax', 'nonce' );
456 456
 
457 457
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
458
-        if ( empty($shortcode) ) {
458
+        if ( empty( $shortcode ) ) {
459 459
             wp_die();
460 460
         }
461 461
 
462
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
463
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
462
+        echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
463
+        echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
464 464
 
465 465
         $form_id = '';
466 466
         $opts = array();
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
                 );
476 476
             break;
477 477
         }
478
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
478
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
479 479
 
480 480
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
481 481
 			// allow other shortcodes to use the required form id option
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			unset( $opts['form_id'] );
484 484
 		}
485 485
 
486
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
486
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
487 487
 
488 488
         echo '</div>';
489 489
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
             die();
516 516
         }
517 517
 
518
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
518
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
519 519
     }
520 520
 
521 521
 	public static function get_columns( $columns ) {
@@ -592,11 +592,11 @@  discard block
 block discarded – undo
592 592
         }
593 593
 
594 594
         if ( $form->parent_form_id ) {
595
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' ));
595
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
596 596
         }
597 597
 
598 598
 		$frm_field_selection = FrmField::field_selection();
599
-        $fields = FrmField::get_all_for_form($form->id);
599
+        $fields = FrmField::get_all_for_form( $form->id );
600 600
 
601 601
         // Automatically add end section fields if they don't exist (2.0 migration)
602 602
         $reset_fields = false;
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
607 607
         }
608 608
 
609
-        unset($end_section_values, $last_order, $open, $reset_fields);
609
+        unset( $end_section_values, $last_order, $open, $reset_fields );
610 610
 
611
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
611
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
612 612
 
613 613
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
614 614
         if ( $form->is_template && $message == $edit_message ) {
@@ -618,13 +618,13 @@  discard block
 block discarded – undo
618 618
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
619 619
 
620 620
         if ( $form->default_template ) {
621
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
622
-        } else if ( defined('DOING_AJAX') ) {
621
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
622
+        } else if ( defined( 'DOING_AJAX' ) ) {
623 623
             wp_die();
624 624
         } else if ( $create_link ) {
625
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
625
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
626 626
         } else {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
627
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
628 628
         }
629 629
     }
630 630
 
@@ -635,28 +635,28 @@  discard block
 block discarded – undo
635 635
 
636 636
         $form = FrmForm::getOne( $id );
637 637
 
638
-        $fields = FrmField::get_all_for_form($id);
639
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
638
+        $fields = FrmField::get_all_for_form( $id );
639
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
640 640
 
641
-        if ( isset($values['default_template']) && $values['default_template'] ) {
642
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
641
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
642
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
643 643
         }
644 644
 
645 645
         $action_controls = FrmFormActionsController::get_form_actions();
646 646
 
647
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
647
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
648 648
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
649 649
 
650
-        $styles = apply_filters('frm_get_style_opts', array());
650
+        $styles = apply_filters( 'frm_get_style_opts', array() );
651 651
 
652
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
652
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
653 653
     }
654 654
 
655 655
     public static function mb_tags_box( $form_id, $class = '' ) {
656
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
656
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
657 657
         $linked_forms = array();
658 658
         $col = 'one';
659
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
659
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
660 660
 
661 661
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
662 662
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 
735 735
     // Insert the form class setting into the form
736 736
 	public static function form_classes( $form ) {
737
-        if ( isset($form->options['form_class']) ) {
737
+        if ( isset( $form->options['form_class'] ) ) {
738 738
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
739 739
         }
740 740
     }
741 741
 
742 742
     public static function get_email_html() {
743
-		FrmAppHelper::permission_check('frm_view_forms');
743
+		FrmAppHelper::permission_check( 'frm_view_forms' );
744 744
         check_ajax_referer( 'frm_ajax', 'nonce' );
745 745
 		echo FrmEntryFormat::show_entry( array(
746 746
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
     public static function add_default_templates( $path, $default = true, $template = true ) {
838 838
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
839 839
 
840
-        $path = untrailingslashit(trim($path));
841
-        $templates = glob( $path .'/*.php' );
840
+        $path = untrailingslashit( trim( $path ) );
841
+        $templates = glob( $path . '/*.php' );
842 842
 
843
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
844
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
843
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
844
+            $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
845 845
 			$template_query = array( 'form_key' => $filename );
846 846
             if ( $template ) {
847 847
                 $template_query['is_template'] = 1;
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
                 $values['default_template'] = 1;
860 860
             }
861 861
 
862
-            include( $templates[ $i ] );
862
+            include( $templates[$i] );
863 863
 
864 864
             //get updated form
865
-            if ( isset($form) && ! empty($form) ) {
865
+            if ( isset( $form ) && ! empty( $form ) ) {
866 866
                 $old_id = $form->id;
867
-                $form = FrmForm::getOne($form->id);
867
+                $form = FrmForm::getOne( $form->id );
868 868
             } else {
869 869
                 $old_id = false;
870 870
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -877,24 +877,24 @@  discard block
 block discarded – undo
877 877
     }
878 878
 
879 879
     public static function route() {
880
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
880
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
881 881
         $vars = array();
882 882
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
883 883
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
884 884
 
885
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
886
-            $json_vars = json_decode($json_vars, true);
887
-            if ( empty($json_vars) ) {
885
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
886
+            $json_vars = json_decode( $json_vars, true );
887
+            if ( empty( $json_vars ) ) {
888 888
                 // json decoding failed so we should return an error message
889 889
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
890 890
                 if ( 'edit' == $action ) {
891 891
                     $action = 'update';
892 892
                 }
893 893
 
894
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
894
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
895 895
             } else {
896
-                $vars = FrmAppHelper::json_to_array($json_vars);
897
-                $action = $vars[ $action ];
896
+                $vars = FrmAppHelper::json_to_array( $json_vars );
897
+                $action = $vars[$action];
898 898
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
899 899
 				$_REQUEST = array_merge( $_REQUEST, $vars );
900 900
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 
913 913
         switch ( $action ) {
914 914
             case 'new':
915
-                return self::new_form($vars);
915
+                return self::new_form( $vars );
916 916
             case 'create':
917 917
             case 'edit':
918 918
             case 'update':
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
             case 'update_settings':
926 926
 				return self::$action( $vars );
927 927
             default:
928
-                do_action('frm_form_action_'. $action);
929
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
928
+                do_action( 'frm_form_action_' . $action );
929
+                if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
930 930
                     return;
931 931
                 }
932 932
 
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
936 936
                 }
937 937
 
938
-                if ( strpos($action, 'bulk_') === 0 ) {
938
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
939 939
                     FrmAppHelper::remove_get_action();
940 940
                     return self::list_form();
941 941
                 }
@@ -962,37 +962,37 @@  discard block
 block discarded – undo
962 962
 
963 963
 	public static function admin_bar_configure() {
964 964
         global $frm_vars;
965
-        if ( empty($frm_vars['forms_loaded']) ) {
965
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
966 966
             return;
967 967
         }
968 968
 
969 969
         $actions = array();
970 970
         foreach ( $frm_vars['forms_loaded'] as $form ) {
971
-            if ( is_object($form) ) {
972
-                $actions[ $form->id ] = $form->name;
971
+            if ( is_object( $form ) ) {
972
+                $actions[$form->id] = $form->name;
973 973
             }
974
-            unset($form);
974
+            unset( $form );
975 975
         }
976 976
 
977
-        if ( empty($actions) ) {
977
+        if ( empty( $actions ) ) {
978 978
             return;
979 979
         }
980 980
 
981
-        asort($actions);
981
+        asort( $actions );
982 982
 
983 983
         global $wp_admin_bar;
984 984
 
985
-        if ( count($actions) == 1 ) {
985
+        if ( count( $actions ) == 1 ) {
986 986
             $wp_admin_bar->add_menu( array(
987 987
                 'title' => 'Edit Form',
988
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
988
+                'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
989 989
                 'id'    => 'frm-forms',
990 990
             ) );
991 991
         } else {
992 992
             $wp_admin_bar->add_menu( array(
993 993
         		'id'    => 'frm-forms',
994 994
         		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
995
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
995
+        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
996 996
         		'meta'  => array(
997 997
 					'title' => __( 'Edit Forms', 'formidable' ),
998 998
         		),
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 
1003 1003
         		$wp_admin_bar->add_menu( array(
1004 1004
         			'parent'    => 'frm-forms',
1005
-        			'id'        => 'edit_form_'. $form_id,
1006
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1005
+        			'id'        => 'edit_form_' . $form_id,
1006
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1007 1007
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1008 1008
         		) );
1009 1009
         	}
@@ -1013,22 +1013,22 @@  discard block
 block discarded – undo
1013 1013
     //formidable shortcode
1014 1014
 	public static function get_form_shortcode( $atts ) {
1015 1015
         global $frm_vars;
1016
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1016
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1017 1017
             $sc = '[formidable';
1018 1018
 			if ( ! empty( $atts ) ) {
1019 1019
 				foreach ( $atts as $k => $v ) {
1020 1020
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1021 1021
 				}
1022 1022
 			}
1023
-            return $sc .']';
1023
+            return $sc . ']';
1024 1024
         }
1025 1025
 
1026 1026
         $shortcode_atts = shortcode_atts( array(
1027 1027
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1028 1028
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1029 1029
             'exclude_fields' => array(), 'minimize' => false,
1030
-        ), $atts);
1031
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1030
+        ), $atts );
1031
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1032 1032
 
1033 1033
         return self::show_form(
1034 1034
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1116,51 +1116,51 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
         $frm_settings = FrmAppHelper::get_settings();
1118 1118
 
1119
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1119
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1120 1120
 
1121 1121
         $user_ID = get_current_user_id();
1122 1122
 		$params = FrmForm::get_params( $form );
1123 1123
         $message = $errors = '';
1124 1124
 
1125 1125
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1126
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1126
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1127 1127
         }
1128 1128
 
1129 1129
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1130 1130
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1131 1131
 
1132 1132
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1133
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1134
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1135
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1136
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1133
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1134
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1135
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1136
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1137 1137
             }
1138 1138
             return;
1139 1139
         }
1140 1140
 
1141
-        if ( ! empty($errors) ) {
1142
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1143
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1141
+        if ( ! empty( $errors ) ) {
1142
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1143
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1144 1144
             return;
1145 1145
         }
1146 1146
 
1147
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1148
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1147
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1148
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1149 1149
             return;
1150 1150
         }
1151 1151
 
1152
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1153
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1154
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1152
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1153
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1154
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1155 1155
 
1156
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1157
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1156
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1157
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1158 1158
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1159 1159
             return;
1160 1160
         }
1161 1161
 
1162
-        if ( $created && is_numeric($created) ) {
1163
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1162
+        if ( $created && is_numeric( $created ) ) {
1163
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164 1164
             $class = 'frm_message';
1165 1165
         } else {
1166 1166
             $message = $frm_settings->failed_msg;
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 			'message' => $message, 'form' => $form,
1172 1172
 			'entry_id' => $created, 'class' => $class,
1173 1173
 		) );
1174
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1174
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1175 1175
 
1176
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1177
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1176
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1177
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1178 1178
         } else {
1179 1179
             global $frm_vars;
1180 1180
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1181 1181
 
1182
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1183
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1182
+            $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1183
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1184 1184
         }
1185 1185
 
1186 1186
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
Please login to merge, or discard this patch.