Completed
Push — master ( 980350...b5e3c5 )
by Stephanie
03:26
created
classes/controllers/FrmFormsController.php 1 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.5.1', true );
297
+			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', 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,11 +426,11 @@  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
 			$menu_name = FrmAppHelper::get_menu_name();
431 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' ) . '">
432 432
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> '.
433
-				$menu_name .'</a>';
433
+				$menu_name . '</a>';
434 434
 			echo wp_kses_post( $content );
435 435
 		}
436 436
 	}
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
448 448
         );
449 449
 
450
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
450
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
451 451
 
452
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
452
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
453 453
     }
454 454
 
455 455
     public static function get_shortcode_opts() {
456
-		FrmAppHelper::permission_check('frm_view_forms');
456
+		FrmAppHelper::permission_check( 'frm_view_forms' );
457 457
         check_ajax_referer( 'frm_ajax', 'nonce' );
458 458
 
459 459
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
460
-        if ( empty($shortcode) ) {
460
+        if ( empty( $shortcode ) ) {
461 461
             wp_die();
462 462
         }
463 463
 
464
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464
+        echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
465
+        echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
466 466
 
467 467
         $form_id = '';
468 468
         $opts = array();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 );
478 478
             break;
479 479
         }
480
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
480
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
481 481
 
482 482
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
483 483
 			// allow other shortcodes to use the required form id option
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			unset( $opts['form_id'] );
486 486
 		}
487 487
 
488
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
488
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
489 489
 
490 490
         echo '</div>';
491 491
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             die();
518 518
         }
519 519
 
520
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
520
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
521 521
     }
522 522
 
523 523
 	public static function get_columns( $columns ) {
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
         }
595 595
 
596 596
         if ( $form->parent_form_id ) {
597
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' ));
597
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
598 598
         }
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+        $fields = FrmField::get_all_for_form( $form->id );
602 602
 
603 603
         // Automatically add end section fields if they don't exist (2.0 migration)
604 604
         $reset_fields = false;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609 609
         }
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+        unset( $end_section_values, $last_order, $open, $reset_fields );
612 612
 
613
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
613
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
614 614
 
615 615
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
616 616
         if ( $form->is_template && $message == $edit_message ) {
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
621 621
 
622 622
         if ( $form->default_template ) {
623
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
624
-        } else if ( defined('DOING_AJAX') ) {
623
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
624
+        } else if ( defined( 'DOING_AJAX' ) ) {
625 625
             wp_die();
626 626
         } else if ( $create_link ) {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
627
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
628 628
         } else {
629
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
629
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
630 630
         }
631 631
     }
632 632
 
@@ -637,28 +637,28 @@  discard block
 block discarded – undo
637 637
 
638 638
         $form = FrmForm::getOne( $id );
639 639
 
640
-        $fields = FrmField::get_all_for_form($id);
641
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640
+        $fields = FrmField::get_all_for_form( $id );
641
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
642 642
 
643
-        if ( isset($values['default_template']) && $values['default_template'] ) {
644
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
643
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
644
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
645 645
         }
646 646
 
647 647
         $action_controls = FrmFormActionsController::get_form_actions();
648 648
 
649
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
649
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
650 650
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
651 651
 
652
-        $styles = apply_filters('frm_get_style_opts', array());
652
+        $styles = apply_filters( 'frm_get_style_opts', array() );
653 653
 
654
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
654
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
655 655
     }
656 656
 
657 657
     public static function mb_tags_box( $form_id, $class = '' ) {
658
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
658
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
659 659
         $linked_forms = array();
660 660
         $col = 'one';
661
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
661
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
662 662
 
663 663
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
664 664
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 
737 737
     // Insert the form class setting into the form
738 738
 	public static function form_classes( $form ) {
739
-        if ( isset($form->options['form_class']) ) {
739
+        if ( isset( $form->options['form_class'] ) ) {
740 740
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
741 741
         }
742 742
     }
743 743
 
744 744
     public static function get_email_html() {
745
-		FrmAppHelper::permission_check('frm_view_forms');
745
+		FrmAppHelper::permission_check( 'frm_view_forms' );
746 746
         check_ajax_referer( 'frm_ajax', 'nonce' );
747 747
 		echo FrmEntryFormat::show_entry( array(
748 748
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
     public static function add_default_templates( $path, $default = true, $template = true ) {
840 840
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
841 841
 
842
-        $path = untrailingslashit(trim($path));
843
-        $templates = glob( $path .'/*.php' );
842
+        $path = untrailingslashit( trim( $path ) );
843
+        $templates = glob( $path . '/*.php' );
844 844
 
845
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
846
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
845
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
846
+            $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
847 847
 			$template_query = array( 'form_key' => $filename );
848 848
             if ( $template ) {
849 849
                 $template_query['is_template'] = 1;
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
                 $values['default_template'] = 1;
862 862
             }
863 863
 
864
-            include( $templates[ $i ] );
864
+            include( $templates[$i] );
865 865
 
866 866
             //get updated form
867
-            if ( isset($form) && ! empty($form) ) {
867
+            if ( isset( $form ) && ! empty( $form ) ) {
868 868
                 $old_id = $form->id;
869
-                $form = FrmForm::getOne($form->id);
869
+                $form = FrmForm::getOne( $form->id );
870 870
             } else {
871 871
                 $old_id = false;
872 872
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -879,24 +879,24 @@  discard block
 block discarded – undo
879 879
     }
880 880
 
881 881
     public static function route() {
882
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
882
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
883 883
         $vars = array();
884 884
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
885 885
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
886 886
 
887
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
-            $json_vars = json_decode($json_vars, true);
889
-            if ( empty($json_vars) ) {
887
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
888
+            $json_vars = json_decode( $json_vars, true );
889
+            if ( empty( $json_vars ) ) {
890 890
                 // json decoding failed so we should return an error message
891 891
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
892 892
                 if ( 'edit' == $action ) {
893 893
                     $action = 'update';
894 894
                 }
895 895
 
896
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
896
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
897 897
             } else {
898
-                $vars = FrmAppHelper::json_to_array($json_vars);
899
-                $action = $vars[ $action ];
898
+                $vars = FrmAppHelper::json_to_array( $json_vars );
899
+                $action = $vars[$action];
900 900
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
901 901
 				$_REQUEST = array_merge( $_REQUEST, $vars );
902 902
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 
915 915
         switch ( $action ) {
916 916
             case 'new':
917
-                return self::new_form($vars);
917
+                return self::new_form( $vars );
918 918
             case 'create':
919 919
             case 'edit':
920 920
             case 'update':
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
             case 'update_settings':
928 928
 				return self::$action( $vars );
929 929
             default:
930
-                do_action('frm_form_action_'. $action);
931
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
930
+                do_action( 'frm_form_action_' . $action );
931
+                if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
932 932
                     return;
933 933
                 }
934 934
 
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
938 938
                 }
939 939
 
940
-                if ( strpos($action, 'bulk_') === 0 ) {
940
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
941 941
                     FrmAppHelper::remove_get_action();
942 942
                     return self::list_form();
943 943
                 }
@@ -964,37 +964,37 @@  discard block
 block discarded – undo
964 964
 
965 965
 	public static function admin_bar_configure() {
966 966
         global $frm_vars;
967
-        if ( empty($frm_vars['forms_loaded']) ) {
967
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
968 968
             return;
969 969
         }
970 970
 
971 971
         $actions = array();
972 972
         foreach ( $frm_vars['forms_loaded'] as $form ) {
973
-            if ( is_object($form) ) {
974
-                $actions[ $form->id ] = $form->name;
973
+            if ( is_object( $form ) ) {
974
+                $actions[$form->id] = $form->name;
975 975
             }
976
-            unset($form);
976
+            unset( $form );
977 977
         }
978 978
 
979
-        if ( empty($actions) ) {
979
+        if ( empty( $actions ) ) {
980 980
             return;
981 981
         }
982 982
 
983
-        asort($actions);
983
+        asort( $actions );
984 984
 
985 985
         global $wp_admin_bar;
986 986
 
987
-        if ( count($actions) == 1 ) {
987
+        if ( count( $actions ) == 1 ) {
988 988
             $wp_admin_bar->add_menu( array(
989 989
                 'title' => 'Edit Form',
990
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
990
+                'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
991 991
                 'id'    => 'frm-forms',
992 992
             ) );
993 993
         } else {
994 994
             $wp_admin_bar->add_menu( array(
995 995
         		'id'    => 'frm-forms',
996 996
         		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
997
+        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
998 998
         		'meta'  => array(
999 999
 					'title' => __( 'Edit Forms', 'formidable' ),
1000 1000
         		),
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
         		$wp_admin_bar->add_menu( array(
1006 1006
         			'parent'    => 'frm-forms',
1007
-        			'id'        => 'edit_form_'. $form_id,
1008
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1007
+        			'id'        => 'edit_form_' . $form_id,
1008
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1009 1009
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1010 1010
         		) );
1011 1011
         	}
@@ -1015,22 +1015,22 @@  discard block
 block discarded – undo
1015 1015
     //formidable shortcode
1016 1016
 	public static function get_form_shortcode( $atts ) {
1017 1017
         global $frm_vars;
1018
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1018
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1019 1019
             $sc = '[formidable';
1020 1020
 			if ( ! empty( $atts ) ) {
1021 1021
 				foreach ( $atts as $k => $v ) {
1022 1022
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1023 1023
 				}
1024 1024
 			}
1025
-            return $sc .']';
1025
+            return $sc . ']';
1026 1026
         }
1027 1027
 
1028 1028
         $shortcode_atts = shortcode_atts( array(
1029 1029
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030 1030
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031 1031
             'exclude_fields' => array(), 'minimize' => false,
1032
-        ), $atts);
1033
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1032
+        ), $atts );
1033
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1034 1034
 
1035 1035
         return self::show_form(
1036 1036
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1118,51 +1118,51 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
         $frm_settings = FrmAppHelper::get_settings();
1120 1120
 
1121
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1121
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122 1122
 
1123 1123
         $user_ID = get_current_user_id();
1124 1124
 		$params = FrmForm::get_params( $form );
1125 1125
         $message = $errors = '';
1126 1126
 
1127 1127
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1128
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1129 1129
         }
1130 1130
 
1131 1131
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1132 1132
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133 1133
 
1134 1134
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1135
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1136
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1137
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1138
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1139 1139
             }
1140 1140
             return;
1141 1141
         }
1142 1142
 
1143
-        if ( ! empty($errors) ) {
1144
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1143
+        if ( ! empty( $errors ) ) {
1144
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1145
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1146 1146
             return;
1147 1147
         }
1148 1148
 
1149
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1149
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1150
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1151 1151
             return;
1152 1152
         }
1153 1153
 
1154
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1154
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1155
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1156
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1157 1157
 
1158
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1158
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1159
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1160 1160
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1161 1161
             return;
1162 1162
         }
1163 1163
 
1164
-        if ( $created && is_numeric($created) ) {
1165
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164
+        if ( $created && is_numeric( $created ) ) {
1165
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166 1166
             $class = 'frm_message';
1167 1167
         } else {
1168 1168
             $message = $frm_settings->failed_msg;
@@ -1173,16 +1173,16 @@  discard block
 block discarded – undo
1173 1173
 			'message' => $message, 'form' => $form,
1174 1174
 			'entry_id' => $created, 'class' => $class,
1175 1175
 		) );
1176
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1176
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1177 1177
 
1178
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1178
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1179
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1180 1180
         } else {
1181 1181
             global $frm_vars;
1182 1182
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1183 1183
 
1184
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1184
+            $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1185
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1186 1186
         }
1187 1187
 
1188 1188
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
Please login to merge, or discard this patch.