Completed
Push — master ( b19fc8...7b84d5 )
by Stephanie
15:31 queued 07:40
created
classes/controllers/FrmFormsController.php 1 patch
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  discard block
 block discarded – undo
3 3
 class FrmFormsController {
4 4
 
5 5
     public static function menu() {
6
-        add_submenu_page('formidable', 'Formidable | '. __( 'Forms', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
6
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Forms', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
7 7
 
8
-	    add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
8
+	    add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
9 9
 
10
-	    add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
11
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
10
+	    add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
11
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
12 12
     }
13 13
 
14 14
     public static function head() {
15
-        wp_enqueue_script('formidable-editinplace');
15
+        wp_enqueue_script( 'formidable-editinplace' );
16 16
 
17 17
         if ( wp_is_mobile() ) {
18 18
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
     }
21 21
 
22 22
     public static function register_widgets() {
23
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
24
-        register_widget('FrmShowForm');
23
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
24
+        register_widget( 'FrmShowForm' );
25 25
     }
26 26
 
27 27
     public static function list_form() {
28
-        FrmAppHelper::permission_check('frm_view_forms');
28
+        FrmAppHelper::permission_check( 'frm_view_forms' );
29 29
 
30 30
 		$params = FrmForm::list_page_params();
31
-        $errors = self::process_bulk_form_actions( array());
32
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
31
+        $errors = self::process_bulk_form_actions( array() );
32
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
33 33
 
34 34
 		return self::display_forms_list( $params, '', $errors );
35 35
     }
36 36
 
37 37
 	public static function new_form( $values = array() ) {
38
-        FrmAppHelper::permission_check('frm_edit_forms');
38
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
39 39
 
40 40
         global $frm_vars;
41 41
 
42
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
43
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
42
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
43
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
44 44
 
45 45
 		if ( $action == 'create' ) {
46
-            return self::create($values);
46
+            return self::create( $values );
47 47
 		} else if ( $action == 'new' ) {
48 48
 			$frm_field_selection = FrmField::field_selection();
49
-            $values = FrmFormsHelper::setup_new_vars($values);
49
+            $values = FrmFormsHelper::setup_new_vars( $values );
50 50
             $id = FrmForm::create( $values );
51
-            $form = FrmForm::getOne($id);
51
+            $form = FrmForm::getOne( $id );
52 52
 
53 53
             // add default email notification
54 54
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
55
-            $action_control->create($form->id);
55
+            $action_control->create( $form->id );
56 56
 
57 57
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
58 58
 
59 59
             $values['id'] = $id;
60
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
60
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
61 61
         }
62 62
     }
63 63
 
64 64
 	public static function create( $values = array() ) {
65
-        FrmAppHelper::permission_check('frm_edit_forms');
65
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
66 66
 
67 67
         global $frm_vars;
68 68
         if ( empty( $values ) ) {
@@ -74,58 +74,58 @@  discard block
 block discarded – undo
74 74
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
75 75
         }
76 76
 
77
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
77
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
78 78
 
79 79
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
80 80
             $frm_settings = FrmAppHelper::get_settings();
81 81
             $errors = array( 'form' => $frm_settings->admin_permission );
82 82
         } else {
83
-            $errors = FrmForm::validate($values);
83
+            $errors = FrmForm::validate( $values );
84 84
         }
85 85
 
86
-        if ( count($errors) > 0 ) {
86
+        if ( count( $errors ) > 0 ) {
87 87
             $hide_preview = true;
88 88
 			$frm_field_selection = FrmField::field_selection();
89 89
             $form = FrmForm::getOne( $id );
90
-            $fields = FrmField::get_all_for_form($id);
90
+            $fields = FrmField::get_all_for_form( $id );
91 91
 
92
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
92
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
93 93
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
94 94
 
95
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
95
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
96 96
         } else {
97 97
             FrmForm::update( $id, $values, true );
98
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
98
+            die( FrmAppHelper::js_redirect( admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ) ) );
99 99
         }
100 100
     }
101 101
 
102 102
     public static function edit( $values = false ) {
103
-        FrmAppHelper::permission_check('frm_edit_forms');
103
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
104 104
 
105 105
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106
-        return self::get_edit_vars($id);
106
+        return self::get_edit_vars( $id );
107 107
     }
108 108
 
109 109
     public static function settings( $id = false, $message = '' ) {
110
-        FrmAppHelper::permission_check('frm_edit_forms');
110
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
111 111
 
112
-        if ( ! $id || ! is_numeric($id) ) {
112
+        if ( ! $id || ! is_numeric( $id ) ) {
113 113
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
114 114
         }
115 115
 		return self::get_settings_vars( $id, array(), $message );
116 116
     }
117 117
 
118 118
     public static function update_settings() {
119
-        FrmAppHelper::permission_check('frm_edit_forms');
119
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
120 120
 
121 121
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
122 122
 
123
-        $errors = FrmForm::validate($_POST);
124
-        if ( count($errors) > 0 ) {
125
-            return self::get_settings_vars($id, $errors);
123
+        $errors = FrmForm::validate( $_POST );
124
+        if ( count( $errors ) > 0 ) {
125
+            return self::get_settings_vars( $id, $errors );
126 126
         }
127 127
 
128
-        do_action('frm_before_update_form_settings', $id);
128
+        do_action( 'frm_before_update_form_settings', $id );
129 129
 
130 130
 		FrmForm::update( $id, $_POST );
131 131
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
 	private static function edit_in_place_value( $field ) {
149 149
 		check_ajax_referer( 'frm_ajax', 'nonce' );
150
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
150
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
151 151
 
152 152
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
153 153
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 	}
220 220
 
221 221
     public static function duplicate() {
222
-        FrmAppHelper::permission_check('frm_edit_forms');
222
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 
224 224
 		$params = FrmForm::list_page_params();
225 225
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
226
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
226
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
227 227
         if ( $form ) {
228 228
 			return self::get_edit_vars( $form, array(), $message, true );
229 229
         } else {
230
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
230
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
231 231
         }
232 232
     }
233 233
 
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
         if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
254 254
             global $wp;
255 255
             $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
256
-            include_once( $root.'/wp-config.php' );
256
+            include_once( $root . '/wp-config.php' );
257 257
             $wp->init();
258 258
             $wp->register_globals();
259 259
         }
260 260
 
261 261
 		self::register_pro_scripts();
262 262
 
263
-		header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
263
+		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
264 264
 
265 265
 		$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
266 266
 		if ( $key == '' ) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			$form = FrmForm::getAll( array(), '', 1 );
273 273
         }
274 274
 
275
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
275
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
276 276
         wp_die();
277 277
     }
278 278
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		if ( FrmAppHelper::pro_is_installed() ) {
281 281
 			wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
282 282
 			wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
283
-			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true );
283
+			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true );
284 284
 		}
285 285
 	}
286 286
 
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
 	public static function bulk_untrash( $ids ) {
292
-        FrmAppHelper::permission_check('frm_edit_forms');
292
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
293 293
 
294 294
         $count = FrmForm::set_status( $ids, 'published' );
295 295
 
296
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
296
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
297 297
         return $message;
298 298
     }
299 299
 
@@ -312,90 +312,90 @@  discard block
 block discarded – undo
312 312
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
313 313
 		);
314 314
 
315
-		if ( ! isset( $available_status[ $status ] ) ) {
315
+		if ( ! isset( $available_status[$status] ) ) {
316 316
 			return;
317 317
 		}
318 318
 
319
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
319
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
320 320
 
321 321
 		$params = FrmForm::list_page_params();
322 322
 
323 323
 		//check nonce url
324
-		check_admin_referer($status .'_form_' . $params['id']);
324
+		check_admin_referer( $status . '_form_' . $params['id'] );
325 325
 
326 326
 		$count = 0;
327
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
328
-			$count++;
327
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
328
+			$count ++;
329 329
 		}
330 330
 
331
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
332
-		$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>' );
331
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
332
+		$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>' );
333 333
 
334
-		$message = $available_status[ $status ]['message'];
334
+		$message = $available_status[$status]['message'];
335 335
 
336 336
 		self::display_forms_list( $params, $message );
337 337
 	}
338 338
 
339 339
 	public static function bulk_trash( $ids ) {
340
-        FrmAppHelper::permission_check('frm_delete_forms');
340
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
341 341
 
342 342
         $count = 0;
343 343
         foreach ( $ids as $id ) {
344 344
             if ( FrmForm::trash( $id ) ) {
345
-                $count++;
345
+                $count ++;
346 346
             }
347 347
         }
348 348
 
349 349
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
350
-        $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>' );
350
+        $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>' );
351 351
 
352 352
         return $message;
353 353
     }
354 354
 
355 355
     public static function destroy() {
356
-        FrmAppHelper::permission_check('frm_delete_forms');
356
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
357 357
 
358 358
 		$params = FrmForm::list_page_params();
359 359
 
360 360
         //check nonce url
361
-        check_admin_referer('destroy_form_' . $params['id']);
361
+        check_admin_referer( 'destroy_form_' . $params['id'] );
362 362
 
363 363
         $count = 0;
364 364
         if ( FrmForm::destroy( $params['id'] ) ) {
365
-            $count++;
365
+            $count ++;
366 366
         }
367 367
 
368
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
368
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
369 369
 
370 370
 		self::display_forms_list( $params, $message );
371 371
     }
372 372
 
373 373
 	public static function bulk_destroy( $ids ) {
374
-        FrmAppHelper::permission_check('frm_delete_forms');
374
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
375 375
 
376 376
         $count = 0;
377 377
         foreach ( $ids as $id ) {
378 378
             $d = FrmForm::destroy( $id );
379 379
             if ( $d ) {
380
-                $count++;
380
+                $count ++;
381 381
             }
382 382
         }
383 383
 
384
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
384
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
385 385
 
386 386
         return $message;
387 387
     }
388 388
 
389 389
     private static function delete_all() {
390 390
         //check nonce url
391
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
391
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
392 392
         if ( $permission_error !== false ) {
393 393
 			self::display_forms_list( array(), '', array( $permission_error ) );
394 394
             return;
395 395
         }
396 396
 
397 397
 		$count = FrmForm::scheduled_delete( time() );
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
 		self::display_forms_list( array(), $message );
401 401
     }
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	* @since 2.0.15
413 413
 	*/
414 414
 	public static function insert_form_button() {
415
-		if ( current_user_can('frm_view_forms') ) {
415
+		if ( current_user_can( 'frm_view_forms' ) ) {
416 416
 			$frm_settings = FrmAppHelper::get_settings();
417
-			$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>';
417
+			$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>';
418 418
 			echo wp_kses_post( $content );
419 419
 		}
420 420
 	}
@@ -431,21 +431,21 @@  discard block
 block discarded – undo
431 431
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
432 432
         );
433 433
 
434
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
434
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
435 435
 
436
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
436
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
437 437
     }
438 438
 
439 439
     public static function get_shortcode_opts() {
440 440
         check_ajax_referer( 'frm_ajax', 'nonce' );
441 441
 
442 442
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
443
-        if ( empty($shortcode) ) {
443
+        if ( empty( $shortcode ) ) {
444 444
             wp_die();
445 445
         }
446 446
 
447
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
448
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
447
+        echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
448
+        echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
449 449
 
450 450
         $form_id = '';
451 451
         $opts = array();
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
                 );
461 461
             break;
462 462
         }
463
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
463
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
464 464
 
465 465
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
466 466
 			// allow other shortcodes to use the required form id option
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 			unset( $opts['form_id'] );
469 469
 		}
470 470
 
471
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
471
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
472 472
 
473 473
         echo '</div>';
474 474
 
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             die();
501 501
         }
502 502
 
503
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
503
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
504 504
     }
505 505
 
506 506
 	public static function get_columns( $columns ) {
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
         }
578 578
 
579 579
         if ( $form->parent_form_id ) {
580
-            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>' ));
580
+            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>' ) );
581 581
         }
582 582
 
583 583
 		$frm_field_selection = FrmField::field_selection();
584
-        $fields = FrmField::get_all_for_form($form->id);
584
+        $fields = FrmField::get_all_for_form( $form->id );
585 585
 
586 586
         // Automatically add end section fields if they don't exist (2.0 migration)
587 587
         $reset_fields = false;
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
592 592
         }
593 593
 
594
-        unset($end_section_values, $last_order, $open, $reset_fields);
594
+        unset( $end_section_values, $last_order, $open, $reset_fields );
595 595
 
596
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
596
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
597 597
 
598 598
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
599 599
         if ( $form->is_template && $message == $edit_message ) {
@@ -603,13 +603,13 @@  discard block
 block discarded – undo
603 603
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
604 604
 
605 605
         if ( $form->default_template ) {
606
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
607
-        } else if ( defined('DOING_AJAX') ) {
606
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
607
+        } else if ( defined( 'DOING_AJAX' ) ) {
608 608
             wp_die();
609 609
         } else if ( $create_link ) {
610
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
610
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
611 611
         } else {
612
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
612
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
613 613
         }
614 614
     }
615 615
 
@@ -620,28 +620,28 @@  discard block
 block discarded – undo
620 620
 
621 621
         $form = FrmForm::getOne( $id );
622 622
 
623
-        $fields = FrmField::get_all_for_form($id);
624
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
623
+        $fields = FrmField::get_all_for_form( $id );
624
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
625 625
 
626
-        if ( isset($values['default_template']) && $values['default_template'] ) {
627
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
626
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
627
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
628 628
         }
629 629
 
630 630
         $action_controls = FrmFormActionsController::get_form_actions();
631 631
 
632
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
632
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
633 633
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
634 634
 
635
-        $styles = apply_filters('frm_get_style_opts', array());
635
+        $styles = apply_filters( 'frm_get_style_opts', array() );
636 636
 
637
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
637
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
638 638
     }
639 639
 
640 640
     public static function mb_tags_box( $form_id, $class = '' ) {
641
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
641
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
642 642
         $linked_forms = array();
643 643
         $col = 'one';
644
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
644
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
645 645
 
646 646
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
647 647
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 
720 720
     // Insert the form class setting into the form
721 721
 	public static function form_classes( $form ) {
722
-        if ( isset($form->options['form_class']) ) {
722
+        if ( isset( $form->options['form_class'] ) ) {
723 723
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
724 724
         }
725 725
     }
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
     public static function add_default_templates( $path, $default = true, $template = true ) {
822 822
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
823 823
 
824
-        $path = untrailingslashit(trim($path));
825
-        $templates = glob( $path .'/*.php' );
824
+        $path = untrailingslashit( trim( $path ) );
825
+        $templates = glob( $path . '/*.php' );
826 826
 
827
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
828
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
827
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
828
+            $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
829 829
 			$template_query = array( 'form_key' => $filename );
830 830
             if ( $template ) {
831 831
                 $template_query['is_template'] = 1;
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
                 $values['default_template'] = 1;
844 844
             }
845 845
 
846
-            include( $templates[ $i ] );
846
+            include( $templates[$i] );
847 847
 
848 848
             //get updated form
849
-            if ( isset($form) && ! empty($form) ) {
849
+            if ( isset( $form ) && ! empty( $form ) ) {
850 850
                 $old_id = $form->id;
851
-                $form = FrmForm::getOne($form->id);
851
+                $form = FrmForm::getOne( $form->id );
852 852
             } else {
853 853
                 $old_id = false;
854 854
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -861,24 +861,24 @@  discard block
 block discarded – undo
861 861
     }
862 862
 
863 863
     public static function route() {
864
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
864
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
865 865
         $vars = array();
866 866
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
867 867
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
868 868
 
869
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
870
-            $json_vars = json_decode($json_vars, true);
871
-            if ( empty($json_vars) ) {
869
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
870
+            $json_vars = json_decode( $json_vars, true );
871
+            if ( empty( $json_vars ) ) {
872 872
                 // json decoding failed so we should return an error message
873 873
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
874 874
                 if ( 'edit' == $action ) {
875 875
                     $action = 'update';
876 876
                 }
877 877
 
878
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
878
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
879 879
             } else {
880
-                $vars = FrmAppHelper::json_to_array($json_vars);
881
-                $action = $vars[ $action ];
880
+                $vars = FrmAppHelper::json_to_array( $json_vars );
881
+                $action = $vars[$action];
882 882
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
883 883
 				$_REQUEST = array_merge( $_REQUEST, $vars );
884 884
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 
897 897
         switch ( $action ) {
898 898
             case 'new':
899
-                return self::new_form($vars);
899
+                return self::new_form( $vars );
900 900
             case 'create':
901 901
             case 'edit':
902 902
             case 'update':
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
             case 'update_settings':
910 910
 				return self::$action( $vars );
911 911
             default:
912
-                do_action('frm_form_action_'. $action);
913
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
912
+                do_action( 'frm_form_action_' . $action );
913
+                if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
914 914
                     return;
915 915
                 }
916 916
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
920 920
                 }
921 921
 
922
-                if ( strpos($action, 'bulk_') === 0 ) {
922
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
923 923
                     FrmAppHelper::remove_get_action();
924 924
                     return self::list_form();
925 925
                 }
@@ -946,37 +946,37 @@  discard block
 block discarded – undo
946 946
 
947 947
 	public static function admin_bar_configure() {
948 948
         global $frm_vars;
949
-        if ( empty($frm_vars['forms_loaded']) ) {
949
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
950 950
             return;
951 951
         }
952 952
 
953 953
         $actions = array();
954 954
         foreach ( $frm_vars['forms_loaded'] as $form ) {
955
-            if ( is_object($form) ) {
956
-                $actions[ $form->id ] = $form->name;
955
+            if ( is_object( $form ) ) {
956
+                $actions[$form->id] = $form->name;
957 957
             }
958
-            unset($form);
958
+            unset( $form );
959 959
         }
960 960
 
961
-        if ( empty($actions) ) {
961
+        if ( empty( $actions ) ) {
962 962
             return;
963 963
         }
964 964
 
965
-        asort($actions);
965
+        asort( $actions );
966 966
 
967 967
         global $wp_admin_bar;
968 968
 
969
-        if ( count($actions) == 1 ) {
969
+        if ( count( $actions ) == 1 ) {
970 970
             $wp_admin_bar->add_menu( array(
971 971
                 'title' => 'Edit Form',
972
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
972
+                'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
973 973
                 'id'    => 'frm-forms',
974 974
             ) );
975 975
         } else {
976 976
             $wp_admin_bar->add_menu( array(
977 977
         		'id'    => 'frm-forms',
978 978
         		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
979
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
979
+        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
980 980
         		'meta'  => array(
981 981
 					'title' => __( 'Edit Forms', 'formidable' ),
982 982
         		),
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 
987 987
         		$wp_admin_bar->add_menu( array(
988 988
         			'parent'    => 'frm-forms',
989
-        			'id'        => 'edit_form_'. $form_id,
990
-        			'title'     => empty($name) ? __( '(no title)') : $name,
989
+        			'id'        => 'edit_form_' . $form_id,
990
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
991 991
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
992 992
         		) );
993 993
         	}
@@ -997,22 +997,22 @@  discard block
 block discarded – undo
997 997
     //formidable shortcode
998 998
 	public static function get_form_shortcode( $atts ) {
999 999
         global $frm_vars;
1000
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1000
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1001 1001
             $sc = '[formidable';
1002 1002
 			if ( ! empty( $atts ) ) {
1003 1003
 				foreach ( $atts as $k => $v ) {
1004 1004
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1005 1005
 				}
1006 1006
 			}
1007
-            return $sc .']';
1007
+            return $sc . ']';
1008 1008
         }
1009 1009
 
1010 1010
         $shortcode_atts = shortcode_atts( array(
1011 1011
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1012 1012
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1013 1013
             'exclude_fields' => array(), 'minimize' => false,
1014
-        ), $atts);
1015
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1014
+        ), $atts );
1015
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1016 1016
 
1017 1017
         return self::show_form(
1018 1018
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1100,51 +1100,51 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
         $frm_settings = FrmAppHelper::get_settings();
1102 1102
 
1103
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1103
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1104 1104
 
1105 1105
         $user_ID = get_current_user_id();
1106 1106
 		$params = FrmForm::get_params( $form );
1107 1107
         $message = $errors = '';
1108 1108
 
1109 1109
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1110
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1110
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1111 1111
         }
1112 1112
 
1113 1113
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1114 1114
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1115 1115
 
1116 1116
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1117
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1118
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1119
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1120
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1117
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1118
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1119
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1120
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1121 1121
             }
1122 1122
             return;
1123 1123
         }
1124 1124
 
1125
-        if ( ! empty($errors) ) {
1126
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1127
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1125
+        if ( ! empty( $errors ) ) {
1126
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1127
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1128 1128
             return;
1129 1129
         }
1130 1130
 
1131
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1132
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1131
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1132
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1133 1133
             return;
1134 1134
         }
1135 1135
 
1136
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1137
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1138
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1136
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1137
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1138
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1139 1139
 
1140
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1141
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1140
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1141
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1142 1142
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1143 1143
             return;
1144 1144
         }
1145 1145
 
1146
-        if ( $created && is_numeric($created) ) {
1147
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1146
+        if ( $created && is_numeric( $created ) ) {
1147
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1148 1148
             $class = 'frm_message';
1149 1149
         } else {
1150 1150
             $message = $frm_settings->failed_msg;
@@ -1155,16 +1155,16 @@  discard block
 block discarded – undo
1155 1155
 			'message' => $message, 'form' => $form,
1156 1156
 			'entry_id' => $created, 'class' => $class,
1157 1157
 		) );
1158
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1158
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1159 1159
 
1160
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1161
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1160
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1161
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1162 1162
         } else {
1163 1163
             global $frm_vars;
1164 1164
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1165 1165
 
1166
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1167
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1166
+            $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1167
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1168 1168
         }
1169 1169
 
1170 1170
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
Please login to merge, or discard this patch.