Completed
Push — master ( 6f86cb...d1e6f6 )
by Stephanie
07:36
created
classes/controllers/FrmFormsController.php 1 patch
Indentation   +364 added lines, -364 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,13 +24,13 @@  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() {
27
+	public static function head() {
28 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 35
 	public static function register_widgets() {
36 36
 		require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public static function new_form( $values = array() ) {
62 62
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
63 63
 
64
-        global $frm_vars;
64
+		global $frm_vars;
65 65
 
66 66
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
67 67
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 		} else if ( $action == 'new' ) {
73 73
 			$frm_field_selection = FrmField::field_selection();
74 74
 			$values = FrmFormsHelper::setup_new_vars( $values );
75
-            $id = FrmForm::create( $values );
75
+			$id = FrmForm::create( $values );
76 76
 			$form = FrmForm::getOne( $id );
77 77
 
78 78
 			self::create_default_email_action( $form );
79 79
 
80 80
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
81 81
 
82
-            $values['id'] = $id;
82
+			$values['id'] = $id;
83 83
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
84
-        }
85
-    }
84
+		}
85
+	}
86 86
 
87 87
 	/**
88 88
 	 * Create the default email action
@@ -91,41 +91,41 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @param object $form
93 93
 	 */
94
-    private static function create_default_email_action( $form ) {
95
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
94
+	private static function create_default_email_action( $form ) {
95
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
96 96
 
97
-	    if ( $create_email ) {
98
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
99
-		    $action_control->create( $form->id );
100
-	    }
101
-    }
97
+		if ( $create_email ) {
98
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
99
+			$action_control->create( $form->id );
100
+		}
101
+	}
102 102
 
103 103
 	public static function create( $values = array() ) {
104 104
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
105 105
 
106
-        global $frm_vars;
107
-        if ( empty( $values ) ) {
108
-            $values = $_POST;
109
-        }
106
+		global $frm_vars;
107
+		if ( empty( $values ) ) {
108
+			$values = $_POST;
109
+		}
110 110
 
111
-        //Set radio button and checkbox meta equal to "other" value
112
-        if ( FrmAppHelper::pro_is_installed() ) {
113
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
114
-        }
111
+		//Set radio button and checkbox meta equal to "other" value
112
+		if ( FrmAppHelper::pro_is_installed() ) {
113
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
114
+		}
115 115
 
116 116
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
117 117
 
118
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
-            $frm_settings = FrmAppHelper::get_settings();
120
-            $errors = array( 'form' => $frm_settings->admin_permission );
121
-        } else {
118
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
+			$frm_settings = FrmAppHelper::get_settings();
120
+			$errors = array( 'form' => $frm_settings->admin_permission );
121
+		} else {
122 122
 			$errors = FrmForm::validate( $values );
123
-        }
123
+		}
124 124
 
125 125
 		if ( count( $errors ) > 0 ) {
126
-            $hide_preview = true;
126
+			$hide_preview = true;
127 127
 			$frm_field_selection = FrmField::field_selection();
128
-            $form = FrmForm::getOne( $id );
128
+			$form = FrmForm::getOne( $id );
129 129
 			$fields = FrmField::get_all_for_form( $id );
130 130
 
131 131
 			$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
@@ -133,30 +133,30 @@  discard block
 block discarded – undo
133 133
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
134 134
 
135 135
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
136
-        } else {
137
-            FrmForm::update( $id, $values, true );
136
+		} else {
137
+			FrmForm::update( $id, $values, true );
138 138
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
139 139
 			die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok.
140
-        }
141
-    }
140
+		}
141
+	}
142 142
 
143
-    public static function edit( $values = false ) {
143
+	public static function edit( $values = false ) {
144 144
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
145 145
 
146 146
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
147 147
 		return self::get_edit_vars( $id );
148
-    }
148
+	}
149 149
 
150
-    public static function settings( $id = false, $message = '' ) {
150
+	public static function settings( $id = false, $message = '' ) {
151 151
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
152 152
 
153 153
 		if ( ! $id || ! is_numeric( $id ) ) {
154 154
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
155
-        }
155
+		}
156 156
 		return self::get_settings_vars( $id, array(), $message );
157
-    }
157
+	}
158 158
 
159
-    public static function update_settings() {
159
+	public static function update_settings() {
160 160
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
161 161
 
162 162
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
@@ -170,39 +170,39 @@  discard block
 block discarded – undo
170 170
 
171 171
 		FrmForm::update( $id, $_POST );
172 172
 
173
-        $message = __( 'Settings Successfully Updated', 'formidable' );
173
+		$message = __( 'Settings Successfully Updated', 'formidable' );
174 174
 		return self::get_settings_vars( $id, array(), $message );
175
-    }
175
+	}
176 176
 
177 177
 	public static function update( $values = array() ) {
178 178
 		if ( empty( $values ) ) {
179
-            $values = $_POST;
180
-        }
179
+			$values = $_POST;
180
+		}
181 181
 
182
-        //Set radio button and checkbox meta equal to "other" value
183
-        if ( FrmAppHelper::pro_is_installed() ) {
184
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
185
-        }
182
+		//Set radio button and checkbox meta equal to "other" value
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
185
+		}
186 186
 
187
-        $errors = FrmForm::validate( $values );
188
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
189
-        if ( $permission_error !== false ) {
190
-            $errors['form'] = $permission_error;
191
-        }
187
+		$errors = FrmForm::validate( $values );
188
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
189
+		if ( $permission_error !== false ) {
190
+			$errors['form'] = $permission_error;
191
+		}
192 192
 
193 193
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
194 194
 
195 195
 		if ( count( $errors ) > 0 ) {
196
-            return self::get_edit_vars( $id, $errors );
196
+			return self::get_edit_vars( $id, $errors );
197 197
 		} else {
198
-            FrmForm::update( $id, $values );
199
-            $message = __( 'Form was Successfully Updated', 'formidable' );
200
-            if ( defined( 'DOING_AJAX' ) ) {
198
+			FrmForm::update( $id, $values );
199
+			$message = __( 'Form was Successfully Updated', 'formidable' );
200
+			if ( defined( 'DOING_AJAX' ) ) {
201 201
 				wp_die( esc_html( $message ) );
202
-            }
202
+			}
203 203
 			return self::get_edit_vars( $id, array(), $message );
204
-        }
205
-    }
204
+		}
205
+	}
206 206
 
207 207
 	/**
208 208
 	 * Redirect to the url for creating from a template
@@ -224,30 +224,30 @@  discard block
 block discarded – undo
224 224
 		wp_die();
225 225
 	}
226 226
 
227
-    public static function duplicate() {
227
+	public static function duplicate() {
228 228
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
229 229
 
230 230
 		$params = FrmForm::list_page_params();
231
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
232
-        $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
233
-        if ( $form ) {
231
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
232
+		$message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
233
+		if ( $form ) {
234 234
 			return self::get_edit_vars( $form, array(), $message, true );
235
-        } else {
235
+		} else {
236 236
 			return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
237
-        }
238
-    }
237
+		}
238
+	}
239 239
 
240
-    public static function page_preview() {
240
+	public static function page_preview() {
241 241
 		$params = FrmForm::list_page_params();
242
-        if ( ! $params['form'] ) {
243
-            return;
244
-        }
242
+		if ( ! $params['form'] ) {
243
+			return;
244
+		}
245 245
 
246
-        $form = FrmForm::getOne( $params['form'] );
246
+		$form = FrmForm::getOne( $params['form'] );
247 247
 		if ( $form ) {
248 248
 			return self::show_form( $form->id, '', true, true );
249 249
 		}
250
-    }
250
+	}
251 251
 
252 252
 	/**
253 253
 	 * @since 3.0
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 		echo self::page_preview(); // WPCS: XSS ok.
257 257
 	}
258 258
 
259
-    public static function preview() {
260
-        do_action( 'frm_wp' );
259
+	public static function preview() {
260
+		do_action( 'frm_wp' );
261 261
 
262
-        global $frm_vars;
263
-        $frm_vars['preview'] = true;
262
+		global $frm_vars;
263
+		$frm_vars['preview'] = true;
264 264
 
265 265
 		self::load_wp();
266 266
 
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
371 371
 	}
372 372
 
373
-    public static function untrash() {
373
+	public static function untrash() {
374 374
 		self::change_form_status( 'untrash' );
375
-    }
375
+	}
376 376
 
377 377
 	public static function bulk_untrash( $ids ) {
378 378
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
379 379
 
380
-        $count = FrmForm::set_status( $ids, 'published' );
380
+		$count = FrmForm::set_status( $ids, 'published' );
381 381
 
382 382
 		$message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
383
-        return $message;
384
-    }
383
+		return $message;
384
+	}
385 385
 
386
-    public static function trash() {
386
+	public static function trash() {
387 387
 		self::change_form_status( 'trash' );
388
-    }
388
+	}
389 389
 
390 390
 	/**
391 391
 	 * @param string $status
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
 	public static function bulk_trash( $ids ) {
437 437
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
438 438
 
439
-        $count = 0;
440
-        foreach ( $ids as $id ) {
441
-            if ( FrmForm::trash( $id ) ) {
442
-                $count++;
443
-            }
444
-        }
439
+		$count = 0;
440
+		foreach ( $ids as $id ) {
441
+			if ( FrmForm::trash( $id ) ) {
442
+				$count++;
443
+			}
444
+		}
445 445
 
446 446
 		$current_page = FrmAppHelper::get_simple_request( array(
447 447
 			'param' => 'form_type',
@@ -449,63 +449,63 @@  discard block
 block discarded – undo
449 449
 		) );
450 450
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
451 451
 
452
-        return $message;
453
-    }
452
+		return $message;
453
+	}
454 454
 
455
-    public static function destroy() {
455
+	public static function destroy() {
456 456
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
457 457
 
458 458
 		$params = FrmForm::list_page_params();
459 459
 
460
-        //check nonce url
460
+		//check nonce url
461 461
 		check_admin_referer( 'destroy_form_' . $params['id'] );
462 462
 
463
-        $count = 0;
464
-        if ( FrmForm::destroy( $params['id'] ) ) {
465
-            $count++;
466
-        }
463
+		$count = 0;
464
+		if ( FrmForm::destroy( $params['id'] ) ) {
465
+			$count++;
466
+		}
467 467
 
468 468
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
469 469
 
470 470
 		self::display_forms_list( $params, $message );
471
-    }
471
+	}
472 472
 
473 473
 	public static function bulk_destroy( $ids ) {
474 474
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
475 475
 
476
-        $count = 0;
477
-        foreach ( $ids as $id ) {
478
-            $d = FrmForm::destroy( $id );
479
-            if ( $d ) {
480
-                $count++;
481
-            }
482
-        }
476
+		$count = 0;
477
+		foreach ( $ids as $id ) {
478
+			$d = FrmForm::destroy( $id );
479
+			if ( $d ) {
480
+				$count++;
481
+			}
482
+		}
483 483
 
484 484
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
485 485
 
486
-        return $message;
487
-    }
486
+		return $message;
487
+	}
488 488
 
489
-    private static function delete_all() {
490
-        //check nonce url
489
+	private static function delete_all() {
490
+		//check nonce url
491 491
 		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
492
-        if ( $permission_error !== false ) {
492
+		if ( $permission_error !== false ) {
493 493
 			self::display_forms_list( array(), '', array( $permission_error ) );
494
-            return;
495
-        }
494
+			return;
495
+		}
496 496
 
497 497
 		$count = FrmForm::scheduled_delete( time() );
498 498
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
499 499
 
500 500
 		self::display_forms_list( array(), $message );
501
-    }
501
+	}
502 502
 
503 503
 	/**
504
-	* Inserts Formidable button
505
-	* Hook exists since 2.5.0
506
-	*
507
-	* @since 2.0.15
508
-	*/
504
+	 * Inserts Formidable button
505
+	 * Hook exists since 2.5.0
506
+	 *
507
+	 * @since 2.0.15
508
+	 */
509 509
 	public static function insert_form_button() {
510 510
 		if ( current_user_can( 'frm_view_forms' ) ) {
511 511
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -516,45 +516,45 @@  discard block
 block discarded – undo
516 516
 		}
517 517
 	}
518 518
 
519
-    public static function insert_form_popup() {
519
+	public static function insert_form_popup() {
520 520
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
521 521
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
522
-            return;
523
-        }
522
+			return;
523
+		}
524 524
 
525
-        FrmAppHelper::load_admin_wide_js();
525
+		FrmAppHelper::load_admin_wide_js();
526 526
 
527
-        $shortcodes = array(
527
+		$shortcodes = array(
528 528
 			'formidable' => array(
529 529
 				'name'  => __( 'Form', 'formidable' ),
530 530
 				'label' => __( 'Insert a Form', 'formidable' ),
531 531
 			),
532
-        );
532
+		);
533 533
 
534 534
 		$shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
535 535
 
536 536
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
537
-    }
537
+	}
538 538
 
539
-    public static function get_shortcode_opts() {
539
+	public static function get_shortcode_opts() {
540 540
 		FrmAppHelper::permission_check( 'frm_view_forms' );
541
-        check_ajax_referer( 'frm_ajax', 'nonce' );
541
+		check_ajax_referer( 'frm_ajax', 'nonce' );
542 542
 
543 543
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
544 544
 		if ( empty( $shortcode ) ) {
545
-            wp_die();
546
-        }
545
+			wp_die();
546
+		}
547 547
 
548 548
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
549 549
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
550 550
 
551
-        $form_id = '';
552
-        $opts = array();
551
+		$form_id = '';
552
+		$opts = array();
553 553
 		switch ( $shortcode ) {
554
-            case 'formidable':
555
-                $opts = array(
554
+			case 'formidable':
555
+				$opts = array(
556 556
 					'form_id'       => 'id',
557
-                    //'key' => ',
557
+					//'key' => ',
558 558
 					'title'         => array(
559 559
 						'val'   => 1,
560 560
 						'label' => __( 'Display form title', 'formidable' ),
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 						'val'   => 1,
568 568
 						'label' => __( 'Minimize form HTML', 'formidable' ),
569 569
 					),
570
-                );
571
-        }
570
+				);
571
+		}
572 572
 		$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
573 573
 
574 574
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
@@ -579,38 +579,38 @@  discard block
 block discarded – undo
579 579
 
580 580
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
581 581
 
582
-        echo '</div>';
582
+		echo '</div>';
583 583
 
584
-        wp_die();
585
-    }
584
+		wp_die();
585
+	}
586 586
 
587 587
 	public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
588
-        FrmAppHelper::permission_check( 'frm_view_forms' );
588
+		FrmAppHelper::permission_check( 'frm_view_forms' );
589 589
 
590
-        global $wpdb, $frm_vars;
590
+		global $wpdb, $frm_vars;
591 591
 
592 592
 		if ( empty( $params ) ) {
593 593
 			$params = FrmForm::list_page_params();
594
-        }
594
+		}
595 595
 
596
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
596
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
597 597
 
598
-        $pagenum = $wp_list_table->get_pagenum();
598
+		$pagenum = $wp_list_table->get_pagenum();
599 599
 
600
-        $wp_list_table->prepare_items();
600
+		$wp_list_table->prepare_items();
601 601
 
602
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
603
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
602
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
603
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
604 604
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
605
-            die();
606
-        }
605
+			die();
606
+		}
607 607
 
608 608
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
609
-    }
609
+	}
610 610
 
611 611
 	public static function get_columns( $columns ) {
612
-	    $columns['cb'] = '<input type="checkbox" />';
613
-	    $columns['id'] = 'ID';
612
+		$columns['cb'] = '<input type="checkbox" />';
613
+		$columns['id'] = 'ID';
614 614
 
615 615
 		$type = FrmAppHelper::get_simple_request( array(
616 616
 			'param'   => 'form_type',
@@ -618,18 +618,18 @@  discard block
 block discarded – undo
618 618
 			'default' => 'published',
619 619
 		) );
620 620
 
621
-        if ( 'template' == $type ) {
622
-            $columns['name']        = __( 'Template Name', 'formidable' );
623
-            $columns['type']        = __( 'Type', 'formidable' );
624
-            $columns['form_key']    = __( 'Key', 'formidable' );
625
-        } else {
626
-            $columns['name']        = __( 'Form Title', 'formidable' );
627
-            $columns['entries']     = __( 'Entries', 'formidable' );
628
-            $columns['form_key']    = __( 'Key', 'formidable' );
629
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
630
-        }
621
+		if ( 'template' == $type ) {
622
+			$columns['name']        = __( 'Template Name', 'formidable' );
623
+			$columns['type']        = __( 'Type', 'formidable' );
624
+			$columns['form_key']    = __( 'Key', 'formidable' );
625
+		} else {
626
+			$columns['name']        = __( 'Form Title', 'formidable' );
627
+			$columns['entries']     = __( 'Entries', 'formidable' );
628
+			$columns['form_key']    = __( 'Key', 'formidable' );
629
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
630
+		}
631 631
 
632
-        $columns['created_at'] = __( 'Date', 'formidable' );
632
+		$columns['created_at'] = __( 'Date', 'formidable' );
633 633
 
634 634
 		add_screen_option( 'per_page', array(
635 635
 			'label'   => __( 'Forms', 'formidable' ),
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			'option'  => 'formidable_page_formidable_per_page',
638 638
 		) );
639 639
 
640
-        return $columns;
640
+		return $columns;
641 641
 	}
642 642
 
643 643
 	public static function get_sortable_columns() {
@@ -665,34 +665,34 @@  discard block
 block discarded – undo
665 665
 	}
666 666
 
667 667
 	public static function save_per_page( $save, $option, $value ) {
668
-        if ( $option == 'formidable_page_formidable_per_page' ) {
669
-            $save = (int) $value;
670
-        }
671
-        return $save;
672
-    }
668
+		if ( $option == 'formidable_page_formidable_per_page' ) {
669
+			$save = (int) $value;
670
+		}
671
+		return $save;
672
+	}
673 673
 
674 674
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
675
-        global $frm_vars;
675
+		global $frm_vars;
676 676
 
677
-        $form = FrmForm::getOne( $id );
678
-        if ( ! $form ) {
679
-            wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
680
-        }
677
+		$form = FrmForm::getOne( $id );
678
+		if ( ! $form ) {
679
+			wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
680
+		}
681 681
 
682
-        if ( $form->parent_form_id ) {
682
+		if ( $form->parent_form_id ) {
683 683
 			wp_die( sprintf( esc_html__( '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>' ) );
684
-        }
684
+		}
685 685
 
686 686
 		$frm_field_selection = FrmField::field_selection();
687 687
 		$fields = FrmField::get_all_for_form( $form->id );
688 688
 
689
-        // Automatically add end section fields if they don't exist (2.0 migration)
690
-        $reset_fields = false;
691
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
689
+		// Automatically add end section fields if they don't exist (2.0 migration)
690
+		$reset_fields = false;
691
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
692 692
 
693
-        if ( $reset_fields ) {
694
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
695
-        }
693
+		if ( $reset_fields ) {
694
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
695
+		}
696 696
 
697 697
 		unset( $end_section_values, $last_order, $open, $reset_fields );
698 698
 
@@ -700,30 +700,30 @@  discard block
 block discarded – undo
700 700
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
701 701
 		$values['fields'] = $fields;
702 702
 
703
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
704
-        if ( $form->is_template && $message == $edit_message ) {
705
-            $message = __( 'Template was Successfully Updated', 'formidable' );
706
-        }
703
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
704
+		if ( $form->is_template && $message == $edit_message ) {
705
+			$message = __( 'Template was Successfully Updated', 'formidable' );
706
+		}
707 707
 
708 708
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
709 709
 
710
-        if ( $form->default_template ) {
710
+		if ( $form->default_template ) {
711 711
 			wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) );
712 712
 		} elseif ( defined( 'DOING_AJAX' ) ) {
713
-            wp_die();
714
-        } else if ( $create_link ) {
713
+			wp_die();
714
+		} else if ( $create_link ) {
715 715
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
716
-        } else {
716
+		} else {
717 717
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
718
-        }
719
-    }
718
+		}
719
+	}
720 720
 
721 721
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
722 722
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
723 723
 
724
-        global $frm_vars;
724
+		global $frm_vars;
725 725
 
726
-        $form = FrmForm::getOne( $id );
726
+		$form = FrmForm::getOne( $id );
727 727
 
728 728
 		$fields = FrmField::get_all_for_form( $id );
729 729
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
@@ -734,17 +734,17 @@  discard block
 block discarded – undo
734 734
 
735 735
 		self::clean_submit_html( $values );
736 736
 
737
-        $action_controls = FrmFormActionsController::get_form_actions();
737
+		$action_controls = FrmFormActionsController::get_form_actions();
738 738
 
739 739
 		$sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
740
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
740
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
741 741
 
742 742
 		$styles = apply_filters( 'frm_get_style_opts', array() );
743 743
 
744 744
 		$first_h3 = 'frm_first_h3';
745 745
 
746 746
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
747
-    }
747
+	}
748 748
 
749 749
 	/**
750 750
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -759,10 +759,10 @@  discard block
 block discarded – undo
759 759
 		}
760 760
 	}
761 761
 
762
-    public static function mb_tags_box( $form_id, $class = '' ) {
762
+	public static function mb_tags_box( $form_id, $class = '' ) {
763 763
 		$fields = FrmField::get_all_for_form( $form_id, '', 'include' );
764
-        $linked_forms = array();
765
-        $col = 'one';
764
+		$linked_forms = array();
765
+		$col = 'one';
766 766
 		$settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
767 767
 
768 768
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
772 772
 
773 773
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
774
-    }
774
+	}
775 775
 
776 776
 	/**
777 777
 	 * Get an array of the options to display in the advanced tab
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 			''          => '',
813 813
 			'siteurl'   => __( 'Site URL', 'formidable' ),
814 814
 			'sitename'  => __( 'Site Name', 'formidable' ),
815
-        );
815
+		);
816 816
 
817 817
 		if ( ! FrmAppHelper::pro_is_installed() ) {
818 818
 			unset( $entry_shortcodes['post_id'] );
@@ -859,21 +859,21 @@  discard block
 block discarded – undo
859 859
 		wp_die();
860 860
 	}
861 861
 
862
-    public static function filter_content( $content, $form, $entry = false ) {
862
+	public static function filter_content( $content, $form, $entry = false ) {
863 863
 		self::get_entry_by_param( $entry );
864
-        if ( ! $entry ) {
865
-            return $content;
866
-        }
864
+		if ( ! $entry ) {
865
+			return $content;
866
+		}
867 867
 
868
-        if ( is_object( $form ) ) {
869
-            $form = $form->id;
870
-        }
868
+		if ( is_object( $form ) ) {
869
+			$form = $form->id;
870
+		}
871 871
 
872
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
873
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
872
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
873
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
874 874
 
875
-        return $content;
876
-    }
875
+		return $content;
876
+	}
877 877
 
878 878
 	private static function get_entry_by_param( &$entry ) {
879 879
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -885,66 +885,66 @@  discard block
 block discarded – undo
885 885
 		}
886 886
 	}
887 887
 
888
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
889
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
890
-    }
888
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
889
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
890
+	}
891 891
 
892
-    public static function process_bulk_form_actions( $errors ) {
893
-        if ( ! $_REQUEST ) {
894
-            return $errors;
895
-        }
892
+	public static function process_bulk_form_actions( $errors ) {
893
+		if ( ! $_REQUEST ) {
894
+			return $errors;
895
+		}
896 896
 
897 897
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
898
-        if ( $bulkaction == -1 ) {
898
+		if ( $bulkaction == -1 ) {
899 899
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
900
-        }
900
+		}
901 901
 
902
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
903
-            FrmAppHelper::remove_get_action();
902
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
903
+			FrmAppHelper::remove_get_action();
904 904
 
905
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
906
-        }
905
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
906
+		}
907 907
 
908 908
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
909
-        if ( empty( $ids ) ) {
910
-            $errors[] = __( 'No forms were specified', 'formidable' );
911
-            return $errors;
912
-        }
913
-
914
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
915
-        if ( $permission_error !== false ) {
916
-            $errors[] = $permission_error;
917
-            return $errors;
918
-        }
919
-
920
-        if ( ! is_array( $ids ) ) {
921
-            $ids = explode( ',', $ids );
922
-        }
923
-
924
-        switch ( $bulkaction ) {
925
-            case 'delete':
926
-                $message = self::bulk_destroy( $ids );
909
+		if ( empty( $ids ) ) {
910
+			$errors[] = __( 'No forms were specified', 'formidable' );
911
+			return $errors;
912
+		}
913
+
914
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
915
+		if ( $permission_error !== false ) {
916
+			$errors[] = $permission_error;
917
+			return $errors;
918
+		}
919
+
920
+		if ( ! is_array( $ids ) ) {
921
+			$ids = explode( ',', $ids );
922
+		}
923
+
924
+		switch ( $bulkaction ) {
925
+			case 'delete':
926
+				$message = self::bulk_destroy( $ids );
927 927
 				break;
928
-            case 'trash':
929
-                $message = self::bulk_trash( $ids );
928
+			case 'trash':
929
+				$message = self::bulk_trash( $ids );
930 930
 				break;
931
-            case 'untrash':
932
-                $message = self::bulk_untrash( $ids );
933
-        }
931
+			case 'untrash':
932
+				$message = self::bulk_untrash( $ids );
933
+		}
934 934
 
935
-        if ( isset( $message ) && ! empty( $message ) ) {
935
+		if ( isset( $message ) && ! empty( $message ) ) {
936 936
 			echo '<div id="message" class="updated frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; // WPCS: XSS ok.
937
-        }
937
+		}
938 938
 
939
-        return $errors;
940
-    }
939
+		return $errors;
940
+	}
941 941
 
942 942
 	/**
943 943
 	 * @deprecated 1.07.05
944 944
 	 * @codeCoverageIgnore
945 945
 	 */
946
-    public static function add_default_templates( $path, $default = true, $template = true ) {
947
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
946
+	public static function add_default_templates( $path, $default = true, $template = true ) {
947
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
948 948
 
949 949
 		$path = untrailingslashit( trim( $path ) );
950 950
 		$templates = glob( $path . '/*.php' );
@@ -952,130 +952,130 @@  discard block
 block discarded – undo
952 952
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
953 953
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
954 954
 			$template_query = array( 'form_key' => $filename );
955
-            if ( $template ) {
956
-                $template_query['is_template'] = 1;
957
-            }
958
-            if ( $default ) {
959
-                $template_query['default_template'] = 1;
960
-            }
955
+			if ( $template ) {
956
+				$template_query['is_template'] = 1;
957
+			}
958
+			if ( $default ) {
959
+				$template_query['default_template'] = 1;
960
+			}
961 961
 			$form = FrmForm::getAll( $template_query, '', 1 );
962 962
 
963
-            $values = FrmFormsHelper::setup_new_vars();
964
-            $values['form_key'] = $filename;
965
-            $values['is_template'] = $template;
966
-            $values['status'] = 'published';
967
-            if ( $default ) {
968
-                $values['default_template'] = 1;
969
-            }
963
+			$values = FrmFormsHelper::setup_new_vars();
964
+			$values['form_key'] = $filename;
965
+			$values['is_template'] = $template;
966
+			$values['status'] = 'published';
967
+			if ( $default ) {
968
+				$values['default_template'] = 1;
969
+			}
970 970
 
971
-            include( $templates[ $i ] );
971
+			include( $templates[ $i ] );
972 972
 
973
-            //get updated form
973
+			//get updated form
974 974
 			if ( isset( $form ) && ! empty( $form ) ) {
975
-                $old_id = $form->id;
975
+				$old_id = $form->id;
976 976
 				$form = FrmForm::getOne( $form->id );
977
-            } else {
978
-                $old_id = false;
977
+			} else {
978
+				$old_id = false;
979 979
 				$form = FrmForm::getAll( $template_query, '', 1 );
980
-            }
980
+			}
981 981
 
982
-            if ( $form ) {
982
+			if ( $form ) {
983 983
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
984
-            }
985
-        }
986
-    }
984
+			}
985
+		}
986
+	}
987 987
 
988
-    public static function route() {
988
+	public static function route() {
989 989
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
990
-        $vars = array();
990
+		$vars = array();
991 991
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
992 992
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
993 993
 
994 994
 			$json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
995 995
 			$json_vars = json_decode( $json_vars, true );
996 996
 			if ( empty( $json_vars ) ) {
997
-                // json decoding failed so we should return an error message
997
+				// json decoding failed so we should return an error message
998 998
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
999
-                if ( 'edit' == $action ) {
1000
-                    $action = 'update';
1001
-                }
999
+				if ( 'edit' == $action ) {
1000
+					$action = 'update';
1001
+				}
1002 1002
 
1003 1003
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1004
-            } else {
1004
+			} else {
1005 1005
 				$vars = FrmAppHelper::json_to_array( $json_vars );
1006
-                $action = $vars[ $action ];
1006
+				$action = $vars[ $action ];
1007 1007
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1008 1008
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1009 1009
 				$_POST = array_merge( $_POST, $_REQUEST );
1010
-            }
1011
-        } else {
1010
+			}
1011
+		} else {
1012 1012
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1013
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
1014
-                // override the action for this page
1015
-    			$action = 'delete_all';
1016
-            }
1017
-        }
1013
+			if ( isset( $_REQUEST['delete_all'] ) ) {
1014
+				// override the action for this page
1015
+				$action = 'delete_all';
1016
+			}
1017
+		}
1018 1018
 
1019 1019
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1020
-        FrmAppHelper::trigger_hook_load( 'form' );
1020
+		FrmAppHelper::trigger_hook_load( 'form' );
1021 1021
 
1022
-        switch ( $action ) {
1023
-            case 'new':
1022
+		switch ( $action ) {
1023
+			case 'new':
1024 1024
 				return self::new_form( $vars );
1025
-            case 'create':
1026
-            case 'edit':
1027
-            case 'update':
1028
-            case 'duplicate':
1029
-            case 'trash':
1030
-            case 'untrash':
1031
-            case 'destroy':
1032
-            case 'delete_all':
1033
-            case 'settings':
1034
-            case 'update_settings':
1025
+			case 'create':
1026
+			case 'edit':
1027
+			case 'update':
1028
+			case 'duplicate':
1029
+			case 'trash':
1030
+			case 'untrash':
1031
+			case 'destroy':
1032
+			case 'delete_all':
1033
+			case 'settings':
1034
+			case 'update_settings':
1035 1035
 				return self::$action( $vars );
1036
-            default:
1036
+			default:
1037 1037
 				do_action( 'frm_form_action_' . $action );
1038 1038
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1039
-                    return;
1040
-                }
1039
+					return;
1040
+				}
1041 1041
 
1042 1042
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1043
-                if ( $action == -1 ) {
1043
+				if ( $action == -1 ) {
1044 1044
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1045
-                }
1045
+				}
1046 1046
 
1047 1047
 				if ( strpos( $action, 'bulk_' ) === 0 ) {
1048
-                    FrmAppHelper::remove_get_action();
1049
-                    return self::list_form();
1050
-                }
1048
+					FrmAppHelper::remove_get_action();
1049
+					return self::list_form();
1050
+				}
1051 1051
 
1052
-                return self::display_forms_list();
1053
-        }
1054
-    }
1052
+				return self::display_forms_list();
1053
+		}
1054
+	}
1055 1055
 
1056
-    public static function json_error( $errors ) {
1057
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1058
-        return $errors;
1059
-    }
1056
+	public static function json_error( $errors ) {
1057
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1058
+		return $errors;
1059
+	}
1060 1060
 
1061 1061
 
1062
-    /* FRONT-END FORMS */
1063
-    public static function admin_bar_css() {
1062
+	/* FRONT-END FORMS */
1063
+	public static function admin_bar_css() {
1064 1064
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1065
-            return;
1066
-        }
1065
+			return;
1066
+		}
1067 1067
 
1068 1068
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1069 1069
 		FrmAppHelper::load_font_style();
1070 1070
 	}
1071 1071
 
1072 1072
 	public static function admin_bar_configure() {
1073
-        global $frm_vars;
1073
+		global $frm_vars;
1074 1074
 		if ( empty( $frm_vars['forms_loaded'] ) ) {
1075
-            return;
1076
-        }
1075
+			return;
1076
+		}
1077 1077
 
1078
-        $actions = array();
1078
+		$actions = array();
1079 1079
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1080 1080
 			if ( is_object( $form ) ) {
1081 1081
 				$actions[ $form->id ] = $form->name;
@@ -1126,18 +1126,18 @@  discard block
 block discarded – undo
1126 1126
 		}
1127 1127
 	}
1128 1128
 
1129
-    //formidable shortcode
1129
+	//formidable shortcode
1130 1130
 	public static function get_form_shortcode( $atts ) {
1131
-        global $frm_vars;
1131
+		global $frm_vars;
1132 1132
 		if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1133
-            $sc = '[formidable';
1133
+			$sc = '[formidable';
1134 1134
 			if ( ! empty( $atts ) ) {
1135 1135
 				foreach ( $atts as $k => $v ) {
1136 1136
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1137 1137
 				}
1138 1138
 			}
1139 1139
 			return $sc . ']';
1140
-        }
1140
+		}
1141 1141
 
1142 1142
 		$shortcode_atts = shortcode_atts( array(
1143 1143
 			'id'          => '',
@@ -1152,30 +1152,30 @@  discard block
 block discarded – undo
1152 1152
 		), $atts );
1153 1153
 		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1154 1154
 
1155
-        return self::show_form(
1156
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1157
-            $shortcode_atts['description'], $atts
1158
-        );
1159
-    }
1155
+		return self::show_form(
1156
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1157
+			$shortcode_atts['description'], $atts
1158
+		);
1159
+	}
1160 1160
 
1161
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1162
-        if ( empty( $id ) ) {
1163
-            $id = $key;
1164
-        }
1161
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1162
+		if ( empty( $id ) ) {
1163
+			$id = $key;
1164
+		}
1165 1165
 
1166
-        $form = self::maybe_get_form_to_show( $id );
1167
-        if ( ! $form ) {
1168
-            return __( 'Please select a valid form', 'formidable' );
1169
-        }
1166
+		$form = self::maybe_get_form_to_show( $id );
1167
+		if ( ! $form ) {
1168
+			return __( 'Please select a valid form', 'formidable' );
1169
+		}
1170 1170
 
1171 1171
 		FrmAppController::maybe_update_styles();
1172 1172
 
1173 1173
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1174
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1174
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1175 1175
 
1176
-        $form = apply_filters( 'frm_pre_display_form', $form );
1176
+		$form = apply_filters( 'frm_pre_display_form', $form );
1177 1177
 
1178
-        $frm_settings = FrmAppHelper::get_settings();
1178
+		$frm_settings = FrmAppHelper::get_settings();
1179 1179
 
1180 1180
 		if ( self::is_viewable_draft_form( $form ) ) {
1181 1181
 			// don't show a draft form on a page
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		}
1198 1198
 
1199 1199
 		return $form;
1200
-    }
1200
+	}
1201 1201
 
1202 1202
 	private static function maybe_get_form_to_show( $id ) {
1203 1203
 		$form = false;
@@ -1226,21 +1226,21 @@  discard block
 block discarded – undo
1226 1226
 		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'] );
1227 1227
 	}
1228 1228
 
1229
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1229
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1230 1230
 		ob_start();
1231 1231
 
1232 1232
 		do_action( 'frm_before_get_form', $atts );
1233 1233
 
1234
-        self::get_form_contents( $form, $title, $description, $atts );
1234
+		self::get_form_contents( $form, $title, $description, $atts );
1235 1235
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1236 1236
 
1237
-        $contents = ob_get_contents();
1238
-        ob_end_clean();
1237
+		$contents = ob_get_contents();
1238
+		ob_end_clean();
1239 1239
 
1240 1240
 		self::maybe_minimize_form( $atts, $contents );
1241 1241
 
1242
-        return $contents;
1243
-    }
1242
+		return $contents;
1243
+	}
1244 1244
 
1245 1245
 	public static function enqueue_scripts( $params ) {
1246 1246
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1580,10 +1580,10 @@  discard block
 block discarded – undo
1580 1580
 	}
1581 1581
 
1582 1582
 	public static function defer_script_loading( $tag, $handle ) {
1583
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1584
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1583
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1584
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1585 1585
 		}
1586
-	    return $tag;
1586
+		return $tag;
1587 1587
 	}
1588 1588
 
1589 1589
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +559 added lines, -559 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.02';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25 25
 
26 26
 	public static function plugin_folder() {
27 27
 		return basename( self::plugin_path() );
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 		return dirname( dirname( dirname( __FILE__ ) ) );
32 32
 	}
33 33
 
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57 57
 	public static function site_name() {
58 58
 		return get_option( 'blogname' );
59 59
 	}
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82 82
 	public static function get_settings() {
83 83
 		global $frm_settings;
84 84
 		if ( empty( $frm_settings ) ) {
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257 257
 		if ( strpos( $param, '[' ) ) {
258 258
 			$params = explode( '[', $param );
259
-            $param = $params[0];
260
-        }
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request( array(
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 			}
286 286
 		}
287 287
 
288
-        return $value;
289
-    }
288
+		return $value;
289
+	}
290 290
 
291 291
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
292 292
 		return self::get_simple_request( array(
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
-	*
355
-	* @since 2.0.8
356
-	* @param string $value
357
-	* @return string $value
358
-	*/
353
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
+	 *
355
+	 * @since 2.0.8
356
+	 * @param string $value
357
+	 * @return string $value
358
+	 */
359 359
 	public static function preserve_backslashes( $value ) {
360 360
 		// If backslashes have already been added, don't add them again
361 361
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    public static function sanitize_request( $sanitize_method, &$values ) {
381
-        $temp_values = $values;
382
-        foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
380
+	public static function sanitize_request( $sanitize_method, &$values ) {
381
+		$temp_values = $values;
382
+		foreach ( $temp_values as $k => $val ) {
383
+			if ( isset( $sanitize_method[ $k ] ) ) {
384 384
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
385
-            }
386
-        }
387
-    }
385
+			}
386
+		}
387
+	}
388 388
 
389 389
 	/**
390 390
 	 * @deprecated 3.01
@@ -514,39 +514,39 @@  discard block
 block discarded – undo
514 514
 		);
515 515
 	}
516 516
 
517
-    /**
518
-     * Used when switching the action for a bulk action
519
-     * @since 2.0
520
-     */
517
+	/**
518
+	 * Used when switching the action for a bulk action
519
+	 * @since 2.0
520
+	 */
521 521
 	public static function remove_get_action() {
522 522
 		if ( ! isset( $_GET ) ) {
523 523
 			return;
524 524
 		}
525 525
 
526
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
-        if ( ! empty( $new_action ) ) {
526
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
+		if ( ! empty( $new_action ) ) {
528 528
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
529
-        }
530
-    }
529
+		}
530
+	}
531 531
 
532
-    /**
533
-     * Check the WP query for a parameter
534
-     *
535
-     * @since 2.0
536
-     * @return string|array
537
-     */
538
-    public static function get_query_var( $value, $param ) {
539
-        if ( $value != '' ) {
540
-            return $value;
541
-        }
532
+	/**
533
+	 * Check the WP query for a parameter
534
+	 *
535
+	 * @since 2.0
536
+	 * @return string|array
537
+	 */
538
+	public static function get_query_var( $value, $param ) {
539
+		if ( $value != '' ) {
540
+			return $value;
541
+		}
542 542
 
543
-        global $wp_query;
544
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
-            $value = $wp_query->query_vars[ $param ];
546
-        }
543
+		global $wp_query;
544
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
+			$value = $wp_query->query_vars[ $param ];
546
+		}
547 547
 
548
-        return $value;
549
-    }
548
+		return $value;
549
+	}
550 550
 
551 551
 	/**
552 552
 	 * @since 3.0
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 	}
570 570
 
571
-    /**
572
-     * @param string $type
573
-     */
574
-    public static function trigger_hook_load( $type, $object = null ) {
575
-        // only load the form hooks once
571
+	/**
572
+	 * @param string $type
573
+	 */
574
+	public static function trigger_hook_load( $type, $object = null ) {
575
+		// only load the form hooks once
576 576
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
577
-        if ( ! $hooks_loaded ) {
577
+		if ( ! $hooks_loaded ) {
578 578
 			do_action( 'frm_load_' . $type . '_hooks' );
579
-        }
580
-    }
579
+		}
580
+	}
581 581
 
582 582
 	/**
583 583
 	 * Save all front-end js scripts into a single file
@@ -599,29 +599,29 @@  discard block
 block discarded – undo
599 599
 		$new_file->combine_files( $files );
600 600
 	}
601 601
 
602
-    /**
603
-     * Check a value from a shortcode to see if true or false.
604
-     * True when value is 1, true, 'true', 'yes'
605
-     *
606
-     * @since 1.07.10
607
-     *
608
-     * @param string $value The value to compare
609
-     * @return boolean True or False
610
-     */
602
+	/**
603
+	 * Check a value from a shortcode to see if true or false.
604
+	 * True when value is 1, true, 'true', 'yes'
605
+	 *
606
+	 * @since 1.07.10
607
+	 *
608
+	 * @param string $value The value to compare
609
+	 * @return boolean True or False
610
+	 */
611 611
 	public static function is_true( $value ) {
612
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
-    }
612
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
+	}
614 614
 
615
-    /**
616
-     * Used to filter shortcode in text widgets
615
+	/**
616
+	 * Used to filter shortcode in text widgets
617 617
 	 *
618 618
 	 * @deprecated 2.5.4
619 619
 	 * @codeCoverageIgnore
620
-     */
621
-    public static function widget_text_filter_callback( $matches ) {
620
+	 */
621
+	public static function widget_text_filter_callback( $matches ) {
622 622
 		_deprecated_function( __METHOD__, '2.5.4' );
623
-        return do_shortcode( $matches[0] );
624
-    }
623
+		return do_shortcode( $matches[0] );
624
+	}
625 625
 
626 626
 	public static function get_pages() {
627 627
 		return get_posts( array(
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 		) );
634 634
 	}
635 635
 
636
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
-        $pages = self::get_pages();
636
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
+		$pages = self::get_pages();
638 638
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
639
-    ?>
639
+	?>
640 640
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
641 641
             <option value=""> </option>
642 642
             <?php foreach ( $pages as $page ) { ?>
@@ -646,16 +646,16 @@  discard block
 block discarded – undo
646 646
             <?php } ?>
647 647
         </select>
648 648
     <?php
649
-    }
649
+	}
650 650
 
651 651
 	public static function post_edit_link( $post_id ) {
652 652
 		$post = get_post( $post_id );
653
-        if ( $post ) {
653
+		if ( $post ) {
654 654
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
655 655
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
656
-        }
657
-        return '';
658
-    }
656
+		}
657
+		return '';
658
+	}
659 659
 
660 660
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661 661
 		?>
@@ -666,73 +666,73 @@  discard block
 block discarded – undo
666 666
 	}
667 667
 
668 668
 	public static function roles_options( $capability ) {
669
-        global $frm_vars;
669
+		global $frm_vars;
670 670
 		if ( isset( $frm_vars['editable_roles'] ) ) {
671
-            $editable_roles = $frm_vars['editable_roles'];
672
-        } else {
673
-            $editable_roles = get_editable_roles();
674
-            $frm_vars['editable_roles'] = $editable_roles;
675
-        }
671
+			$editable_roles = $frm_vars['editable_roles'];
672
+		} else {
673
+			$editable_roles = get_editable_roles();
674
+			$frm_vars['editable_roles'] = $editable_roles;
675
+		}
676 676
 
677
-        foreach ( $editable_roles as $role => $details ) {
677
+		foreach ( $editable_roles as $role => $details ) {
678 678
 			$name = translate_user_role( $details['name'] );
679 679
 			?>
680 680
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
681 681
 <?php
682 682
 			unset( $role, $details );
683
-        }
684
-    }
683
+		}
684
+	}
685 685
 
686 686
 	public static function frm_capabilities( $type = 'auto' ) {
687
-        $cap = array(
688
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
-        );
687
+		$cap = array(
688
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
+		);
695 695
 
696 696
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
697
-            return $cap;
698
-        }
697
+			return $cap;
698
+		}
699 699
 
700
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
700
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
704 704
 
705
-        return $cap;
706
-    }
705
+		return $cap;
706
+	}
707 707
 
708 708
 	public static function user_has_permission( $needed_role ) {
709
-        if ( $needed_role == '-1' ) {
710
-            return false;
709
+		if ( $needed_role == '-1' ) {
710
+			return false;
711 711
 		}
712 712
 
713
-        // $needed_role will be equal to blank if "Logged-in users" is selected
714
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
-            return true;
716
-        }
713
+		// $needed_role will be equal to blank if "Logged-in users" is selected
714
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
+			return true;
716
+		}
717 717
 
718
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
-        foreach ( $roles as $role ) {
718
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
+		foreach ( $roles as $role ) {
720 720
 			if ( current_user_can( $role ) ) {
721
-        		return true;
721
+				return true;
722 722
 			}
723
-        	if ( $role == $needed_role ) {
724
-        		break;
723
+			if ( $role == $needed_role ) {
724
+				break;
725 725
 			}
726
-        }
727
-        return false;
728
-    }
729
-
730
-    /**
731
-     * Make sure administrators can see Formidable menu
732
-     *
733
-     * @since 2.0
734
-     */
735
-    public static function maybe_add_permissions() {
726
+		}
727
+		return false;
728
+	}
729
+
730
+	/**
731
+	 * Make sure administrators can see Formidable menu
732
+	 *
733
+	 * @since 2.0
734
+	 */
735
+	public static function maybe_add_permissions() {
736 736
 		self::force_capability( 'frm_view_entries' );
737 737
 
738 738
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 
742 742
 		$user_id = get_current_user_id();
743 743
 		$user = new WP_User( $user_id );
744
-        $frm_roles = self::frm_capabilities();
745
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
744
+		$frm_roles = self::frm_capabilities();
745
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
746 746
 			$user->add_cap( $frm_role );
747 747
 			unset( $frm_role, $frm_role_description );
748
-        }
749
-    }
748
+		}
749
+	}
750 750
 
751 751
 	/**
752 752
 	 * Make sure admins have permission to see the menu items
@@ -762,28 +762,28 @@  discard block
 block discarded – undo
762 762
 		}
763 763
 	}
764 764
 
765
-    /**
766
-     * Check if the user has permision for action.
767
-     * Return permission message and stop the action if no permission
768
-     * @since 2.0
769
-     * @param string $permission
770
-     */
765
+	/**
766
+	 * Check if the user has permision for action.
767
+	 * Return permission message and stop the action if no permission
768
+	 * @since 2.0
769
+	 * @param string $permission
770
+	 */
771 771
 	public static function permission_check( $permission, $show_message = 'show' ) {
772 772
 		$permission_error = self::permission_nonce_error( $permission );
773
-        if ( $permission_error !== false ) {
774
-            if ( 'hide' == $show_message ) {
775
-                $permission_error = '';
776
-            }
773
+		if ( $permission_error !== false ) {
774
+			if ( 'hide' == $show_message ) {
775
+				$permission_error = '';
776
+			}
777 777
 			wp_die( esc_html( $permission_error ) );
778
-        }
779
-    }
780
-
781
-    /**
782
-     * Check user permission and nonce
783
-     * @since 2.0
784
-     * @param string $permission
785
-     * @return false|string The permission message or false if allowed
786
-     */
778
+		}
779
+	}
780
+
781
+	/**
782
+	 * Check user permission and nonce
783
+	 * @since 2.0
784
+	 * @param string $permission
785
+	 * @return false|string The permission message or false if allowed
786
+	 */
787 787
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
788 788
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
789 789
 			$frm_settings = self::get_settings();
@@ -792,22 +792,22 @@  discard block
 block discarded – undo
792 792
 
793 793
 		$error = false;
794 794
 		if ( empty( $nonce_name ) ) {
795
-            return $error;
796
-        }
795
+			return $error;
796
+		}
797 797
 
798
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
-            $frm_settings = self::get_settings();
800
-            $error = $frm_settings->admin_permission;
801
-        }
798
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
+			$frm_settings = self::get_settings();
800
+			$error = $frm_settings->admin_permission;
801
+		}
802 802
 
803
-        return $error;
804
-    }
803
+		return $error;
804
+	}
805 805
 
806
-    public static function checked( $values, $current ) {
806
+	public static function checked( $values, $current ) {
807 807
 		if ( self::check_selected( $values, $current ) ) {
808
-            echo ' checked="checked"';
808
+			echo ' checked="checked"';
809 809
 		}
810
-    }
810
+	}
811 811
 
812 812
 	public static function check_selected( $values, $current ) {
813 813
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -845,24 +845,24 @@  discard block
 block discarded – undo
845 845
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
846 846
 	}
847 847
 
848
-    /**
849
-     * Flatten a multi-dimensional array
850
-     */
848
+	/**
849
+	 * Flatten a multi-dimensional array
850
+	 */
851 851
 	public static function array_flatten( $array, $keys = 'keep' ) {
852
-        $return = array();
853
-        foreach ( $array as $key => $value ) {
852
+		$return = array();
853
+		foreach ( $array as $key => $value ) {
854 854
 			if ( is_array( $value ) ) {
855 855
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
856
-            } else {
856
+			} else {
857 857
 				if ( $keys == 'keep' ) {
858 858
 					$return[ $key ] = $value;
859 859
 				} else {
860 860
 					$return[] = $value;
861 861
 				}
862
-            }
863
-        }
864
-        return $return;
865
-    }
862
+			}
863
+		}
864
+		return $return;
865
+	}
866 866
 
867 867
 	public static function esc_textarea( $text, $is_rich_text = false ) {
868 868
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -873,10 +873,10 @@  discard block
 block discarded – undo
873 873
 		return apply_filters( 'esc_textarea', $safe_text, $text );
874 874
 	}
875 875
 
876
-    /**
877
-     * Add auto paragraphs to text areas
878
-     * @since 2.0
879
-     */
876
+	/**
877
+	 * Add auto paragraphs to text areas
878
+	 * @since 2.0
879
+	 */
880 880
 	public static function use_wpautop( $content ) {
881 881
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
882 882
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -885,26 +885,26 @@  discard block
 block discarded – undo
885 885
 	}
886 886
 
887 887
 	public static function replace_quotes( $val ) {
888
-        //Replace double quotes
888
+		//Replace double quotes
889 889
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
890
-        //Replace single quotes
891
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
-        return $val;
893
-    }
894
-
895
-    /**
896
-     * @since 2.0
897
-     * @return string The base Google APIS url for the current version of jQuery UI
898
-     */
899
-    public static function jquery_ui_base_url() {
890
+		//Replace single quotes
891
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
+		return $val;
893
+	}
894
+
895
+	/**
896
+	 * @since 2.0
897
+	 * @return string The base Google APIS url for the current version of jQuery UI
898
+	 */
899
+	public static function jquery_ui_base_url() {
900 900
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901 901
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
902
-        return $url;
903
-    }
902
+		return $url;
903
+	}
904 904
 
905
-    /**
906
-     * @param string $handle
907
-     */
905
+	/**
906
+	 * @param string $handle
907
+	 */
908 908
 	public static function script_version( $handle, $default = 0 ) {
909 909
 		global $wp_scripts;
910 910
 		if ( ! $wp_scripts ) {
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
 
927 927
 	public static function js_redirect( $url ) {
928 928
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
929
-    }
929
+	}
930 930
 
931 931
 	public static function get_user_id_param( $user_id ) {
932 932
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
933
-            return $user_id;
934
-        }
933
+			return $user_id;
934
+		}
935 935
 
936 936
 		$user_id = sanitize_text_field( $user_id );
937 937
 		if ( $user_id == 'current' ) {
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 				$user = get_user_by( 'login', $user_id );
944 944
 			}
945 945
 
946
-            if ( $user ) {
947
-                $user_id = $user->ID;
948
-            }
946
+			if ( $user ) {
947
+				$user_id = $user->ID;
948
+			}
949 949
 			unset( $user );
950
-        }
950
+		}
951 951
 
952
-        return $user_id;
953
-    }
952
+		return $user_id;
953
+	}
954 954
 
955 955
 	public static function get_file_contents( $filename, $atts = array() ) {
956 956
 		if ( ! is_file( $filename ) ) {
@@ -965,28 +965,28 @@  discard block
 block discarded – undo
965 965
 		return $contents;
966 966
 	}
967 967
 
968
-    /**
969
-     * @param string $table_name
970
-     * @param string $column
968
+	/**
969
+	 * @param string $table_name
970
+	 * @param string $column
971 971
 	 * @param int $id
972 972
 	 * @param int $num_chars
973
-     */
974
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
-        $key = '';
973
+	 */
974
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
+		$key = '';
976 976
 
977
-        if ( ! empty( $name ) ) {
977
+		if ( ! empty( $name ) ) {
978 978
 			$key = sanitize_key( $name );
979
-        }
979
+		}
980 980
 
981 981
 		if ( empty( $key ) ) {
982 982
 			$max_slug_value = pow( 36, $num_chars );
983
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
983
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
984 984
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
985
-        }
985
+		}
986 986
 
987 987
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988 988
 			$key = $key . 'a';
989
-        }
989
+		}
990 990
 
991 991
 		$key_check = FrmDb::get_var( $table_name, array(
992 992
 			$column => $key,
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		), $column );
995 995
 
996 996
 		if ( $key_check || is_numeric( $key_check ) ) {
997
-            $suffix = 2;
997
+			$suffix = 2;
998 998
 			do {
999 999
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1000 1000
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -1004,19 +1004,19 @@  discard block
 block discarded – undo
1004 1004
 				$suffix++;
1005 1005
 			} while ( $key_check || is_numeric( $key_check ) );
1006 1006
 			$key = $alt_post_name;
1007
-        }
1008
-        return $key;
1009
-    }
1010
-
1011
-    /**
1012
-     * Editing a Form or Entry
1013
-     * @param string $table
1014
-     * @return bool|array
1015
-     */
1016
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
-        if ( ! $record ) {
1018
-            return false;
1019
-        }
1007
+		}
1008
+		return $key;
1009
+	}
1010
+
1011
+	/**
1012
+	 * Editing a Form or Entry
1013
+	 * @param string $table
1014
+	 * @return bool|array
1015
+	 */
1016
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
+		if ( ! $record ) {
1018
+			return false;
1019
+		}
1020 1020
 
1021 1021
 		if ( empty( $post_values ) ) {
1022 1022
 			$post_values = stripslashes_deep( $_POST );
@@ -1039,14 +1039,14 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1041 1041
 
1042
-        if ( $table == 'entries' ) {
1043
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
-        } else if ( $table == 'forms' ) {
1045
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
-        }
1042
+		if ( $table == 'entries' ) {
1043
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
+		} else if ( $table == 'forms' ) {
1045
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
+		}
1047 1047
 
1048
-        return $values;
1049
-    }
1048
+		return $values;
1049
+	}
1050 1050
 
1051 1051
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052 1052
 		if ( ! empty( $fields ) ) {
@@ -1059,46 +1059,46 @@  discard block
 block discarded – undo
1059 1059
 	}
1060 1060
 
1061 1061
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1062
-        $post_values = $args['post_values'];
1062
+		$post_values = $args['post_values'];
1063 1063
 
1064
-        if ( $args['default'] ) {
1065
-            $meta_value = $field->default_value;
1066
-        } else {
1064
+		if ( $args['default'] ) {
1065
+			$meta_value = $field->default_value;
1066
+		} else {
1067 1067
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1068 1068
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1069
-                    $field->field_options['custom_field'] = '';
1070
-                }
1069
+					$field->field_options['custom_field'] = '';
1070
+				}
1071 1071
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1072 1072
 					'truncate' => false,
1073 1073
 					'type' => $field->type,
1074 1074
 					'form_id' => $field->form_id,
1075 1075
 					'field' => $field,
1076 1076
 				) );
1077
-            } else {
1077
+			} else {
1078 1078
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1079
-            }
1080
-        }
1079
+			}
1080
+		}
1081 1081
 
1082 1082
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1083
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1083
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1084 1084
 
1085 1085
 		$field_array = self::start_field_array( $field );
1086 1086
 		$field_array['value'] = $new_value;
1087 1087
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1088 1088
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1089 1089
 
1090
-        $args['field_type'] = $field_type;
1090
+		$args['field_type'] = $field_type;
1091 1091
 
1092 1092
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093 1093
 
1094 1094
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1095
-            $field_array['unique_msg'] = '';
1096
-        }
1095
+			$field_array['unique_msg'] = '';
1096
+		}
1097 1097
 
1098
-        $field_array = array_merge( $field->field_options, $field_array );
1098
+		$field_array = array_merge( $field->field_options, $field_array );
1099 1099
 
1100
-        $values['fields'][ $field->id ] = $field_array;
1101
-    }
1100
+		$values['fields'][ $field->id ] = $field_array;
1101
+	}
1102 1102
 
1103 1103
 	/**
1104 1104
 	 * @since 3.0
@@ -1119,20 +1119,20 @@  discard block
 block discarded – undo
1119 1119
 		);
1120 1120
 	}
1121 1121
 
1122
-    /**
1123
-     * @param string $table
1124
-     */
1122
+	/**
1123
+	 * @param string $table
1124
+	 */
1125 1125
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1126
-        if ( $table == 'entries' ) {
1127
-            $form = $record->form_id;
1126
+		if ( $table == 'entries' ) {
1127
+			$form = $record->form_id;
1128 1128
 			FrmForm::maybe_get_form( $form );
1129
-        } else {
1130
-            $form = $record;
1131
-        }
1129
+		} else {
1130
+			$form = $record;
1131
+		}
1132 1132
 
1133
-        if ( ! $form ) {
1134
-            return;
1135
-        }
1133
+		if ( ! $form ) {
1134
+			return;
1135
+		}
1136 1136
 
1137 1137
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1138 1138
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1141,26 +1141,26 @@  discard block
 block discarded – undo
1141 1141
 			return;
1142 1142
 		}
1143 1143
 
1144
-        foreach ( $form->options as $opt => $value ) {
1145
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
-        }
1144
+		foreach ( $form->options as $opt => $value ) {
1145
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
+		}
1147 1147
 
1148 1148
 		self::fill_form_defaults( $post_values, $values );
1149
-    }
1149
+	}
1150 1150
 
1151
-    /**
1152
-     * Set to POST value or default
1153
-     */
1151
+	/**
1152
+	 * Set to POST value or default
1153
+	 */
1154 1154
 	private static function fill_form_defaults( $post_values, array &$values ) {
1155
-        $form_defaults = FrmFormsHelper::get_default_opts();
1155
+		$form_defaults = FrmFormsHelper::get_default_opts();
1156 1156
 
1157
-        foreach ( $form_defaults as $opt => $default ) {
1158
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1157
+		foreach ( $form_defaults as $opt => $default ) {
1158
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1159 1159
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1160
-            }
1160
+			}
1161 1161
 
1162 1162
 			unset( $opt, $default );
1163
-        }
1163
+		}
1164 1164
 
1165 1165
 		if ( ! isset( $values['custom_style'] ) ) {
1166 1166
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1169,10 +1169,10 @@  discard block
 block discarded – undo
1169 1169
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1170 1170
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1171 1171
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1172
-            }
1172
+			}
1173 1173
 			unset( $h );
1174
-        }
1175
-    }
1174
+		}
1175
+	}
1176 1176
 
1177 1177
 	/**
1178 1178
 	 * @since 2.2.10
@@ -1195,33 +1195,33 @@  discard block
 block discarded – undo
1195 1195
 		if ( $possible_email_field ) {
1196 1196
 			$class .= 'show_frm_not_email_to';
1197 1197
 		}
1198
-    ?>
1198
+	?>
1199 1199
 <li>
1200 1200
 	<a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a>
1201 1201
 	<a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a>
1202 1202
 	<a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a>
1203 1203
 </li>
1204 1204
     <?php
1205
-    }
1205
+	}
1206 1206
 
1207 1207
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1208
-        if ( is_array( $str ) ) {
1209
-            return '';
1208
+		if ( is_array( $str ) ) {
1209
+			return '';
1210 1210
 		}
1211 1211
 
1212
-        $length = (int) $length;
1212
+		$length = (int) $length;
1213 1213
 		$str = wp_strip_all_tags( $str );
1214 1214
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1215 1215
 
1216 1216
 		if ( $length == 0 ) {
1217
-            return '';
1218
-        } else if ( $length <= 10 ) {
1217
+			return '';
1218
+		} else if ( $length <= 10 ) {
1219 1219
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1220 1220
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1221
-        }
1221
+		}
1222 1222
 
1223
-        $sub = '';
1224
-        $len = 0;
1223
+		$sub = '';
1224
+		$len = 0;
1225 1225
 
1226 1226
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1227 1227
 
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230 1230
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231 1231
 			if ( $total_len > $length && str_word_count( $sub ) ) {
1232
-                break;
1233
-            }
1232
+				break;
1233
+			}
1234 1234
 
1235
-            $sub .= $part;
1235
+			$sub .= $part;
1236 1236
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237 1237
 
1238 1238
 			if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1239
-                break;
1240
-            }
1239
+				break;
1240
+			}
1241 1241
 
1242 1242
 			unset( $total_len, $word );
1243
-        }
1243
+		}
1244 1244
 
1245 1245
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1246
-    }
1246
+	}
1247 1247
 
1248 1248
 	public static function mb_function( $function_names, $args ) {
1249 1249
 		$mb_function_name = $function_names[0];
@@ -1256,17 +1256,17 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258 1258
 		if ( empty( $date ) ) {
1259
-            return $date;
1260
-        }
1259
+			return $date;
1260
+		}
1261 1261
 
1262 1262
 		if ( empty( $date_format ) ) {
1263 1263
 			$date_format = get_option( 'date_format' );
1264 1264
 		}
1265 1265
 
1266 1266
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1267
-            $frmpro_settings = new FrmProSettings();
1267
+			$frmpro_settings = new FrmProSettings();
1268 1268
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1269
-        }
1269
+		}
1270 1270
 
1271 1271
 		$formatted = self::get_localized_date( $date_format, $date );
1272 1272
 
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 			$formatted .= self::add_time_to_date( $time_format, $date );
1276 1276
 		}
1277 1277
 
1278
-        return $formatted;
1279
-    }
1278
+		return $formatted;
1279
+	}
1280 1280
 
1281 1281
 	private static function add_time_to_date( $time_format, $date ) {
1282 1282
 		if ( empty( $time_format ) ) {
@@ -1358,32 +1358,32 @@  discard block
 block discarded – undo
1358 1358
 		);
1359 1359
 	}
1360 1360
 
1361
-    // Pagination Methods
1361
+	// Pagination Methods
1362 1362
 
1363
-    /**
1364
-     * @param integer $current_p
1365
-     */
1363
+	/**
1364
+	 * @param integer $current_p
1365
+	 */
1366 1366
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1367 1367
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1368 1368
 	}
1369 1369
 
1370
-    /**
1371
-     * @param integer $current_p
1372
-     */
1373
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
-        if ( $current_p == 1 ) {
1375
-            return 1;
1376
-        } else {
1377
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
-        }
1379
-    }
1370
+	/**
1371
+	 * @param integer $current_p
1372
+	 */
1373
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
+		if ( $current_p == 1 ) {
1375
+			return 1;
1376
+		} else {
1377
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
+		}
1379
+	}
1380 1380
 
1381 1381
 	/**
1382 1382
 	 * @return array
1383 1383
 	 */
1384 1384
 	public static function json_to_array( $json_vars ) {
1385
-        $vars = array();
1386
-        foreach ( $json_vars as $jv ) {
1385
+		$vars = array();
1386
+		foreach ( $json_vars as $jv ) {
1387 1387
 			$jv_name = explode( '[', $jv['name'] );
1388 1388
 			$last = count( $jv_name ) - 1;
1389 1389
 			foreach ( $jv_name as $p => $n ) {
@@ -1400,77 +1400,77 @@  discard block
 block discarded – undo
1400 1400
 					$l3 = $name;
1401 1401
 				}
1402 1402
 
1403
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1403
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1404 1404
 
1405
-                switch ( $p ) {
1406
-                    case 0:
1407
-                        $l1 = $name;
1408
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1405
+				switch ( $p ) {
1406
+					case 0:
1407
+						$l1 = $name;
1408
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1409 1409
 						break;
1410 1410
 
1411
-                    case 1:
1412
-                        $l2 = $name;
1413
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1411
+					case 1:
1412
+						$l2 = $name;
1413
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1414 1414
 						break;
1415 1415
 
1416
-                    case 2:
1417
-                        $l3 = $name;
1418
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1416
+					case 2:
1417
+						$l3 = $name;
1418
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1419 1419
 						break;
1420 1420
 
1421
-                    case 3:
1422
-                        $l4 = $name;
1423
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
-                }
1421
+					case 3:
1422
+						$l4 = $name;
1423
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
+				}
1425 1425
 
1426 1426
 				unset( $this_val, $n );
1427
-            }
1427
+			}
1428 1428
 
1429 1429
 			unset( $last, $jv );
1430
-        }
1431
-
1432
-        return $vars;
1433
-    }
1434
-
1435
-    /**
1436
-     * @param string $name
1437
-     * @param string $l1
1438
-     */
1439
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
-        if ( $name == '' ) {
1441
-            $vars[] = $val;
1442
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1443
-            $vars[ $l1 ] = $val;
1444
-        }
1445
-    }
1430
+		}
1431
+
1432
+		return $vars;
1433
+	}
1434
+
1435
+	/**
1436
+	 * @param string $name
1437
+	 * @param string $l1
1438
+	 */
1439
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
+		if ( $name == '' ) {
1441
+			$vars[] = $val;
1442
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1443
+			$vars[ $l1 ] = $val;
1444
+		}
1445
+	}
1446 1446
 
1447 1447
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1448
-        $tooltips = array(
1449
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1451
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1454
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1456
-        );
1457
-
1458
-        if ( ! isset( $tooltips[ $name ] ) ) {
1459
-            return;
1460
-        }
1461
-
1462
-        if ( 'open' == $class ) {
1463
-            echo ' frm_help"';
1464
-        } else {
1465
-            echo ' class="frm_help"';
1466
-        }
1448
+		$tooltips = array(
1449
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1451
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1454
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1456
+		);
1457
+
1458
+		if ( ! isset( $tooltips[ $name ] ) ) {
1459
+			return;
1460
+		}
1461
+
1462
+		if ( 'open' == $class ) {
1463
+			echo ' frm_help"';
1464
+		} else {
1465
+			echo ' class="frm_help"';
1466
+		}
1467 1467
 
1468 1468
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1469 1469
 
1470
-        if ( 'open' != $class ) {
1471
-            echo '"';
1472
-        }
1473
-    }
1470
+		if ( 'open' != $class ) {
1471
+			echo '"';
1472
+		}
1473
+	}
1474 1474
 
1475 1475
 	/**
1476 1476
 	 * Add the current_page class to that page in the form nav
@@ -1486,35 +1486,35 @@  discard block
 block discarded – undo
1486 1486
 		}
1487 1487
 	}
1488 1488
 
1489
-    /**
1490
-     * Prepare and json_encode post content
1491
-     *
1492
-     * @since 2.0
1493
-     *
1494
-     * @param array $post_content
1495
-     * @return string $post_content ( json encoded array )
1496
-     */
1497
-    public static function prepare_and_encode( $post_content ) {
1498
-        //Loop through array to strip slashes and add only the needed ones
1489
+	/**
1490
+	 * Prepare and json_encode post content
1491
+	 *
1492
+	 * @since 2.0
1493
+	 *
1494
+	 * @param array $post_content
1495
+	 * @return string $post_content ( json encoded array )
1496
+	 */
1497
+	public static function prepare_and_encode( $post_content ) {
1498
+		//Loop through array to strip slashes and add only the needed ones
1499 1499
 		foreach ( $post_content as $key => $val ) {
1500 1500
 			// Replace problematic characters (like &quot;)
1501 1501
 			$val = str_replace( '&quot;', '"', $val );
1502 1502
 
1503 1503
 			self::prepare_action_slashes( $val, $key, $post_content );
1504
-            unset( $key, $val );
1505
-        }
1504
+			unset( $key, $val );
1505
+		}
1506 1506
 
1507
-        // json_encode the array
1508
-        $post_content = json_encode( $post_content );
1507
+		// json_encode the array
1508
+		$post_content = json_encode( $post_content );
1509 1509
 
1510
-	    // add extra slashes for \r\n since WP strips them
1510
+		// add extra slashes for \r\n since WP strips them
1511 1511
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1512 1512
 
1513
-        // allow for &quot
1514
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1513
+		// allow for &quot
1514
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1515 1515
 
1516
-        return $post_content;
1517
-    }
1516
+		return $post_content;
1517
+	}
1518 1518
 
1519 1519
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1520 1520
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1537,63 +1537,63 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 	public static function maybe_json_decode( $string ) {
1539 1539
 		if ( is_array( $string ) ) {
1540
-            return $string;
1541
-        }
1540
+			return $string;
1541
+		}
1542 1542
 
1543 1543
 		$new_string = json_decode( $string, true );
1544 1544
 		if ( function_exists( 'json_last_error' ) ) {
1545 1545
 			// php 5.3+
1546
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1547
-                $string = $new_string;
1548
-            }
1546
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1547
+				$string = $new_string;
1548
+			}
1549 1549
 		} elseif ( isset( $new_string ) ) {
1550 1550
 			// php < 5.3 fallback
1551
-            $string = $new_string;
1552
-        }
1553
-        return $string;
1554
-    }
1555
-
1556
-    /**
1557
-     * @since 1.07.10
1558
-     *
1559
-     * @param string $post_type The name of the post type that may need to be highlighted
1560
-     * echo The javascript to open and highlight the Formidable menu
1561
-     */
1551
+			$string = $new_string;
1552
+		}
1553
+		return $string;
1554
+	}
1555
+
1556
+	/**
1557
+	 * @since 1.07.10
1558
+	 *
1559
+	 * @param string $post_type The name of the post type that may need to be highlighted
1560
+	 * echo The javascript to open and highlight the Formidable menu
1561
+	 */
1562 1562
 	public static function maybe_highlight_menu( $post_type ) {
1563
-        global $post;
1563
+		global $post;
1564 1564
 
1565 1565
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1566
-            return;
1567
-        }
1566
+			return;
1567
+		}
1568 1568
 
1569 1569
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1570
-            return;
1571
-        }
1570
+			return;
1571
+		}
1572 1572
 
1573
-        self::load_admin_wide_js();
1574
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
-    }
1573
+		self::load_admin_wide_js();
1574
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
+	}
1576 1576
 
1577
-    /**
1578
-     * Load the JS file on non-Formidable pages in the admin area
1579
-     * @since 2.0
1580
-     */
1577
+	/**
1578
+	 * Load the JS file on non-Formidable pages in the admin area
1579
+	 * @since 2.0
1580
+	 */
1581 1581
 	public static function load_admin_wide_js( $load = true ) {
1582
-        $version = FrmAppHelper::plugin_version();
1582
+		$version = FrmAppHelper::plugin_version();
1583 1583
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1584 1584
 
1585
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1585
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1586 1586
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1587
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1587
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1588 1588
 			'url'          => FrmAppHelper::plugin_url(),
1589 1589
 			'loading'      => __( 'Loading&hellip;' ),
1590 1590
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1591
-        ) );
1591
+		) );
1592 1592
 
1593 1593
 		if ( $load ) {
1594 1594
 			wp_enqueue_script( 'formidable_admin_global' );
1595 1595
 		}
1596
-    }
1596
+	}
1597 1597
 
1598 1598
 	/**
1599 1599
 	 * @since 2.0.9
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1603 1603
 	}
1604 1604
 
1605
-    /**
1606
-     * @param string $location
1607
-     */
1605
+	/**
1606
+	 * @param string $location
1607
+	 */
1608 1608
 	public static function localize_script( $location ) {
1609 1609
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1610 1610
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1664,27 +1664,27 @@  discard block
 block discarded – undo
1664 1664
 		}
1665 1665
 	}
1666 1666
 
1667
-    /**
1667
+	/**
1668 1668
 	 * echo the message on the plugins listing page
1669
-     * @since 1.07.10
1670
-     *
1671
-     * @param float $min_version The version the add-on requires
1672
-     */
1669
+	 * @since 1.07.10
1670
+	 *
1671
+	 * @param float $min_version The version the add-on requires
1672
+	 */
1673 1673
 	public static function min_version_notice( $min_version ) {
1674
-        $frm_version = self::plugin_version();
1674
+		$frm_version = self::plugin_version();
1675 1675
 
1676
-        // check if Formidable meets minimum requirements
1676
+		// check if Formidable meets minimum requirements
1677 1677
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1678
-            return;
1679
-        }
1678
+			return;
1679
+		}
1680 1680
 
1681 1681
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1682 1682
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1683
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1684
-        '</div></td></tr>';
1685
-    }
1683
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1684
+		'</div></td></tr>';
1685
+	}
1686 1686
 
1687
-    public static function locales( $type = 'date' ) {
1687
+	public static function locales( $type = 'date' ) {
1688 1688
 		$locales = array(
1689 1689
 			'en' => __( 'English', 'formidable' ),
1690 1690
 			''   => __( 'English/Western', 'formidable' ),
@@ -1763,8 +1763,8 @@  discard block
 block discarded – undo
1763 1763
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1764 1764
 		$locales = apply_filters( 'frm_locales', $locales );
1765 1765
 
1766
-        return $locales;
1767
-    }
1766
+		return $locales;
1767
+	}
1768 1768
 
1769 1769
 	/**
1770 1770
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.