Completed
Push — master ( 537290...572154 )
by Stephanie
02:56
created
classes/controllers/FrmFormsController.php 1 patch
Indentation   +335 added lines, -335 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' );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public static function new_form( $values = array() ) {
76 76
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
77 77
 
78
-        global $frm_vars;
78
+		global $frm_vars;
79 79
 
80 80
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
81 81
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 		} else if ( $action == 'new' ) {
87 87
 			$frm_field_selection = FrmField::field_selection();
88 88
 			$values = FrmFormsHelper::setup_new_vars( $values );
89
-            $id = FrmForm::create( $values );
89
+			$id = FrmForm::create( $values );
90 90
 			$form = FrmForm::getOne( $id );
91 91
 
92 92
 			self::create_default_email_action( $form );
93 93
 
94 94
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
95 95
 
96
-            $values['id'] = $id;
96
+			$values['id'] = $id;
97 97
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
98
-        }
99
-    }
98
+		}
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * Create the default email action
@@ -105,41 +105,41 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param object $form
107 107
 	 */
108
-    private static function create_default_email_action( $form ) {
109
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
108
+	private static function create_default_email_action( $form ) {
109
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
110 110
 
111
-	    if ( $create_email ) {
112
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
113
-		    $action_control->create( $form->id );
114
-	    }
115
-    }
111
+		if ( $create_email ) {
112
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
113
+			$action_control->create( $form->id );
114
+		}
115
+	}
116 116
 
117 117
 	public static function create( $values = array() ) {
118 118
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
119 119
 
120
-        global $frm_vars;
121
-        if ( empty( $values ) ) {
122
-            $values = $_POST;
123
-        }
120
+		global $frm_vars;
121
+		if ( empty( $values ) ) {
122
+			$values = $_POST;
123
+		}
124 124
 
125
-        //Set radio button and checkbox meta equal to "other" value
126
-        if ( FrmAppHelper::pro_is_installed() ) {
127
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
128
-        }
125
+		//Set radio button and checkbox meta equal to "other" value
126
+		if ( FrmAppHelper::pro_is_installed() ) {
127
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
128
+		}
129 129
 
130 130
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
131 131
 
132
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
133
-            $frm_settings = FrmAppHelper::get_settings();
134
-            $errors = array( 'form' => $frm_settings->admin_permission );
135
-        } else {
132
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
133
+			$frm_settings = FrmAppHelper::get_settings();
134
+			$errors = array( 'form' => $frm_settings->admin_permission );
135
+		} else {
136 136
 			$errors = FrmForm::validate( $values );
137
-        }
137
+		}
138 138
 
139 139
 		if ( count( $errors ) > 0 ) {
140
-            $hide_preview = true;
140
+			$hide_preview = true;
141 141
 			$frm_field_selection = FrmField::field_selection();
142
-            $form = FrmForm::getOne( $id );
142
+			$form = FrmForm::getOne( $id );
143 143
 			$fields = FrmField::get_all_for_form( $id );
144 144
 
145 145
 			$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
@@ -147,30 +147,30 @@  discard block
 block discarded – undo
147 147
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
148 148
 
149 149
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
150
-        } else {
151
-            FrmForm::update( $id, $values, true );
150
+		} else {
151
+			FrmForm::update( $id, $values, true );
152 152
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
153 153
 			die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok.
154
-        }
155
-    }
154
+		}
155
+	}
156 156
 
157
-    public static function edit( $values = false ) {
157
+	public static function edit( $values = false ) {
158 158
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
159 159
 
160 160
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
161 161
 		return self::get_edit_vars( $id );
162
-    }
162
+	}
163 163
 
164
-    public static function settings( $id = false, $message = '' ) {
164
+	public static function settings( $id = false, $message = '' ) {
165 165
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
166 166
 
167 167
 		if ( ! $id || ! is_numeric( $id ) ) {
168 168
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
169
-        }
169
+		}
170 170
 		return self::get_settings_vars( $id, array(), $message );
171
-    }
171
+	}
172 172
 
173
-    public static function update_settings() {
173
+	public static function update_settings() {
174 174
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
175 175
 
176 176
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
@@ -184,39 +184,39 @@  discard block
 block discarded – undo
184 184
 
185 185
 		FrmForm::update( $id, $_POST );
186 186
 
187
-        $message = __( 'Settings Successfully Updated', 'formidable' );
187
+		$message = __( 'Settings Successfully Updated', 'formidable' );
188 188
 		return self::get_settings_vars( $id, array(), $message );
189
-    }
189
+	}
190 190
 
191 191
 	public static function update( $values = array() ) {
192 192
 		if ( empty( $values ) ) {
193
-            $values = $_POST;
194
-        }
193
+			$values = $_POST;
194
+		}
195 195
 
196
-        //Set radio button and checkbox meta equal to "other" value
197
-        if ( FrmAppHelper::pro_is_installed() ) {
198
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
199
-        }
196
+		//Set radio button and checkbox meta equal to "other" value
197
+		if ( FrmAppHelper::pro_is_installed() ) {
198
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
199
+		}
200 200
 
201
-        $errors = FrmForm::validate( $values );
202
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
-        if ( $permission_error !== false ) {
204
-            $errors['form'] = $permission_error;
205
-        }
201
+		$errors = FrmForm::validate( $values );
202
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
+		if ( $permission_error !== false ) {
204
+			$errors['form'] = $permission_error;
205
+		}
206 206
 
207 207
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
208 208
 
209 209
 		if ( count( $errors ) > 0 ) {
210
-            return self::get_edit_vars( $id, $errors );
210
+			return self::get_edit_vars( $id, $errors );
211 211
 		} else {
212
-            FrmForm::update( $id, $values );
213
-            $message = __( 'Form was Successfully Updated', 'formidable' );
214
-            if ( defined( 'DOING_AJAX' ) ) {
212
+			FrmForm::update( $id, $values );
213
+			$message = __( 'Form was Successfully Updated', 'formidable' );
214
+			if ( defined( 'DOING_AJAX' ) ) {
215 215
 				wp_die( esc_html( $message ) );
216
-            }
216
+			}
217 217
 			return self::get_edit_vars( $id, array(), $message );
218
-        }
219
-    }
218
+		}
219
+	}
220 220
 
221 221
 	/**
222 222
 	 * Redirect to the url for creating from a template
@@ -242,30 +242,30 @@  discard block
 block discarded – undo
242 242
 		wp_die();
243 243
 	}
244 244
 
245
-    public static function duplicate() {
245
+	public static function duplicate() {
246 246
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
247 247
 
248 248
 		$params = FrmForm::list_page_params();
249
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
250
-        $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
251
-        if ( $form ) {
249
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
250
+		$message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
251
+		if ( $form ) {
252 252
 			return self::get_edit_vars( $form, array(), $message, true );
253
-        } else {
253
+		} else {
254 254
 			return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
255
-        }
256
-    }
255
+		}
256
+	}
257 257
 
258
-    public static function page_preview() {
258
+	public static function page_preview() {
259 259
 		$params = FrmForm::list_page_params();
260
-        if ( ! $params['form'] ) {
261
-            return;
262
-        }
260
+		if ( ! $params['form'] ) {
261
+			return;
262
+		}
263 263
 
264
-        $form = FrmForm::getOne( $params['form'] );
264
+		$form = FrmForm::getOne( $params['form'] );
265 265
 		if ( $form ) {
266 266
 			return self::show_form( $form->id, '', true, true );
267 267
 		}
268
-    }
268
+	}
269 269
 
270 270
 	/**
271 271
 	 * @since 3.0
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 		echo self::page_preview(); // WPCS: XSS ok.
275 275
 	}
276 276
 
277
-    public static function preview() {
278
-        do_action( 'frm_wp' );
277
+	public static function preview() {
278
+		do_action( 'frm_wp' );
279 279
 
280
-        global $frm_vars;
281
-        $frm_vars['preview'] = true;
280
+		global $frm_vars;
281
+		$frm_vars['preview'] = true;
282 282
 
283 283
 		self::load_wp();
284 284
 
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
393 393
 	}
394 394
 
395
-    public static function untrash() {
395
+	public static function untrash() {
396 396
 		self::change_form_status( 'untrash' );
397
-    }
397
+	}
398 398
 
399 399
 	public static function bulk_untrash( $ids ) {
400 400
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
401 401
 
402
-        $count = FrmForm::set_status( $ids, 'published' );
402
+		$count = FrmForm::set_status( $ids, 'published' );
403 403
 
404 404
 		$message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
405
-        return $message;
406
-    }
405
+		return $message;
406
+	}
407 407
 
408 408
 	/**
409 409
 	 * @since 3.06
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 		wp_die();
417 417
 	}
418 418
 
419
-    public static function trash() {
419
+	public static function trash() {
420 420
 		self::change_form_status( 'trash' );
421
-    }
421
+	}
422 422
 
423 423
 	/**
424 424
 	 * @param string $status
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 	public static function bulk_trash( $ids ) {
472 472
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
473 473
 
474
-        $count = 0;
475
-        foreach ( $ids as $id ) {
476
-            if ( FrmForm::trash( $id ) ) {
477
-                $count++;
478
-            }
479
-        }
474
+		$count = 0;
475
+		foreach ( $ids as $id ) {
476
+			if ( FrmForm::trash( $id ) ) {
477
+				$count++;
478
+			}
479
+		}
480 480
 
481 481
 		$current_page = FrmAppHelper::get_simple_request(
482 482
 			array(
@@ -491,56 +491,56 @@  discard block
 block discarded – undo
491 491
 			'</a>'
492 492
 		);
493 493
 
494
-        return $message;
495
-    }
494
+		return $message;
495
+	}
496 496
 
497
-    public static function destroy() {
497
+	public static function destroy() {
498 498
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
499 499
 
500 500
 		$params = FrmForm::list_page_params();
501 501
 
502
-        //check nonce url
502
+		//check nonce url
503 503
 		check_admin_referer( 'destroy_form_' . $params['id'] );
504 504
 
505
-        $count = 0;
506
-        if ( FrmForm::destroy( $params['id'] ) ) {
507
-            $count++;
508
-        }
505
+		$count = 0;
506
+		if ( FrmForm::destroy( $params['id'] ) ) {
507
+			$count++;
508
+		}
509 509
 
510 510
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
511 511
 
512 512
 		self::display_forms_list( $params, $message );
513
-    }
513
+	}
514 514
 
515 515
 	public static function bulk_destroy( $ids ) {
516 516
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
517 517
 
518
-        $count = 0;
519
-        foreach ( $ids as $id ) {
520
-            $d = FrmForm::destroy( $id );
521
-            if ( $d ) {
522
-                $count++;
523
-            }
524
-        }
518
+		$count = 0;
519
+		foreach ( $ids as $id ) {
520
+			$d = FrmForm::destroy( $id );
521
+			if ( $d ) {
522
+				$count++;
523
+			}
524
+		}
525 525
 
526 526
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
527 527
 
528
-        return $message;
529
-    }
528
+		return $message;
529
+	}
530 530
 
531
-    private static function delete_all() {
532
-        //check nonce url
531
+	private static function delete_all() {
532
+		//check nonce url
533 533
 		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
534
-        if ( $permission_error !== false ) {
534
+		if ( $permission_error !== false ) {
535 535
 			self::display_forms_list( array(), '', array( $permission_error ) );
536
-            return;
537
-        }
536
+			return;
537
+		}
538 538
 
539 539
 		$count = FrmForm::scheduled_delete( time() );
540 540
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
541 541
 
542 542
 		self::display_forms_list( array(), $message );
543
-    }
543
+	}
544 544
 
545 545
 	/**
546 546
 	 * Create a custom template from a form
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
 	}
584 584
 
585 585
 	/**
586
-	* Inserts Formidable button
587
-	* Hook exists since 2.5.0
588
-	*
589
-	* @since 2.0.15
590
-	*/
586
+	 * Inserts Formidable button
587
+	 * Hook exists since 2.5.0
588
+	 *
589
+	 * @since 2.0.15
590
+	 */
591 591
 	public static function insert_form_button() {
592 592
 		if ( current_user_can( 'frm_view_forms' ) ) {
593 593
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -598,45 +598,45 @@  discard block
 block discarded – undo
598 598
 		}
599 599
 	}
600 600
 
601
-    public static function insert_form_popup() {
601
+	public static function insert_form_popup() {
602 602
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
603 603
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
604
-            return;
605
-        }
604
+			return;
605
+		}
606 606
 
607
-        FrmAppHelper::load_admin_wide_js();
607
+		FrmAppHelper::load_admin_wide_js();
608 608
 
609
-        $shortcodes = array(
609
+		$shortcodes = array(
610 610
 			'formidable' => array(
611 611
 				'name'  => __( 'Form', 'formidable' ),
612 612
 				'label' => __( 'Insert a Form', 'formidable' ),
613 613
 			),
614
-        );
614
+		);
615 615
 
616 616
 		$shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
617 617
 
618 618
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
619
-    }
619
+	}
620 620
 
621
-    public static function get_shortcode_opts() {
621
+	public static function get_shortcode_opts() {
622 622
 		FrmAppHelper::permission_check( 'frm_view_forms' );
623
-        check_ajax_referer( 'frm_ajax', 'nonce' );
623
+		check_ajax_referer( 'frm_ajax', 'nonce' );
624 624
 
625 625
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
626 626
 		if ( empty( $shortcode ) ) {
627
-            wp_die();
628
-        }
627
+			wp_die();
628
+		}
629 629
 
630 630
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
631 631
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
632 632
 
633
-        $form_id = '';
634
-        $opts = array();
633
+		$form_id = '';
634
+		$opts = array();
635 635
 		switch ( $shortcode ) {
636
-            case 'formidable':
637
-                $opts = array(
636
+			case 'formidable':
637
+				$opts = array(
638 638
 					'form_id'       => 'id',
639
-                    //'key' => ',
639
+					//'key' => ',
640 640
 					'title'         => array(
641 641
 						'val'   => 1,
642 642
 						'label' => __( 'Display form title', 'formidable' ),
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
 						'val'   => 1,
650 650
 						'label' => __( 'Minimize form HTML', 'formidable' ),
651 651
 					),
652
-                );
653
-        }
652
+				);
653
+		}
654 654
 		$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
655 655
 
656 656
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
@@ -661,38 +661,38 @@  discard block
 block discarded – undo
661 661
 
662 662
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
663 663
 
664
-        echo '</div>';
664
+		echo '</div>';
665 665
 
666
-        wp_die();
667
-    }
666
+		wp_die();
667
+	}
668 668
 
669 669
 	public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
670
-        FrmAppHelper::permission_check( 'frm_view_forms' );
670
+		FrmAppHelper::permission_check( 'frm_view_forms' );
671 671
 
672
-        global $wpdb, $frm_vars;
672
+		global $wpdb, $frm_vars;
673 673
 
674 674
 		if ( empty( $params ) ) {
675 675
 			$params = FrmForm::list_page_params();
676
-        }
676
+		}
677 677
 
678
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
678
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
679 679
 
680
-        $pagenum = $wp_list_table->get_pagenum();
680
+		$pagenum = $wp_list_table->get_pagenum();
681 681
 
682
-        $wp_list_table->prepare_items();
682
+		$wp_list_table->prepare_items();
683 683
 
684
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
685
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
684
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
685
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
686 686
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
687
-            die();
688
-        }
687
+			die();
688
+		}
689 689
 
690 690
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
691
-    }
691
+	}
692 692
 
693 693
 	public static function get_columns( $columns ) {
694
-	    $columns['cb'] = '<input type="checkbox" />';
695
-	    $columns['id'] = 'ID';
694
+		$columns['cb'] = '<input type="checkbox" />';
695
+		$columns['id'] = 'ID';
696 696
 
697 697
 		$type = FrmAppHelper::get_simple_request(
698 698
 			array(
@@ -702,18 +702,18 @@  discard block
 block discarded – undo
702 702
 			)
703 703
 		);
704 704
 
705
-        if ( 'template' == $type ) {
706
-            $columns['name']        = __( 'Template Name', 'formidable' );
707
-            $columns['type']        = __( 'Type', 'formidable' );
708
-            $columns['form_key']    = __( 'Key', 'formidable' );
709
-        } else {
710
-            $columns['name']        = __( 'Form Title', 'formidable' );
711
-            $columns['entries']     = __( 'Entries', 'formidable' );
712
-            $columns['form_key']    = __( 'Key', 'formidable' );
713
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
714
-        }
705
+		if ( 'template' == $type ) {
706
+			$columns['name']        = __( 'Template Name', 'formidable' );
707
+			$columns['type']        = __( 'Type', 'formidable' );
708
+			$columns['form_key']    = __( 'Key', 'formidable' );
709
+		} else {
710
+			$columns['name']        = __( 'Form Title', 'formidable' );
711
+			$columns['entries']     = __( 'Entries', 'formidable' );
712
+			$columns['form_key']    = __( 'Key', 'formidable' );
713
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
714
+		}
715 715
 
716
-        $columns['created_at'] = __( 'Date', 'formidable' );
716
+		$columns['created_at'] = __( 'Date', 'formidable' );
717 717
 
718 718
 		add_screen_option(
719 719
 			'per_page',
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 			)
725 725
 		);
726 726
 
727
-        return $columns;
727
+		return $columns;
728 728
 	}
729 729
 
730 730
 	public static function get_sortable_columns() {
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
 	}
755 755
 
756 756
 	public static function save_per_page( $save, $option, $value ) {
757
-        if ( $option == 'formidable_page_formidable_per_page' ) {
758
-            $save = (int) $value;
759
-        }
760
-        return $save;
761
-    }
757
+		if ( $option == 'formidable_page_formidable_per_page' ) {
758
+			$save = (int) $value;
759
+		}
760
+		return $save;
761
+	}
762 762
 
763 763
 	/**
764 764
 	 * Show the template listing page
@@ -804,27 +804,27 @@  discard block
 block discarded – undo
804 804
 	}
805 805
 
806 806
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
807
-        global $frm_vars;
807
+		global $frm_vars;
808 808
 
809
-        $form = FrmForm::getOne( $id );
810
-        if ( ! $form ) {
811
-            wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
812
-        }
809
+		$form = FrmForm::getOne( $id );
810
+		if ( ! $form ) {
811
+			wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
812
+		}
813 813
 
814
-        if ( $form->parent_form_id ) {
814
+		if ( $form->parent_form_id ) {
815 815
 			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>' ) );
816
-        }
816
+		}
817 817
 
818 818
 		$frm_field_selection = FrmField::field_selection();
819 819
 		$fields = FrmField::get_all_for_form( $form->id );
820 820
 
821
-        // Automatically add end section fields if they don't exist (2.0 migration)
822
-        $reset_fields = false;
823
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
821
+		// Automatically add end section fields if they don't exist (2.0 migration)
822
+		$reset_fields = false;
823
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
824 824
 
825
-        if ( $reset_fields ) {
826
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
827
-        }
825
+		if ( $reset_fields ) {
826
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
827
+		}
828 828
 
829 829
 		unset( $end_section_values, $last_order, $open, $reset_fields );
830 830
 
@@ -832,45 +832,45 @@  discard block
 block discarded – undo
832 832
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
833 833
 		$values['fields'] = $fields;
834 834
 
835
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
836
-        if ( $form->is_template && $message == $edit_message ) {
837
-            $message = __( 'Template was Successfully Updated', 'formidable' );
838
-        }
835
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
836
+		if ( $form->is_template && $message == $edit_message ) {
837
+			$message = __( 'Template was Successfully Updated', 'formidable' );
838
+		}
839 839
 
840 840
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
841 841
 
842 842
 		if ( defined( 'DOING_AJAX' ) ) {
843
-            wp_die();
844
-        } else if ( $create_link ) {
843
+			wp_die();
844
+		} else if ( $create_link ) {
845 845
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
846
-        } else {
846
+		} else {
847 847
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
848
-        }
849
-    }
848
+		}
849
+	}
850 850
 
851 851
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
852 852
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
853 853
 
854
-        global $frm_vars;
854
+		global $frm_vars;
855 855
 
856
-        $form = FrmForm::getOne( $id );
856
+		$form = FrmForm::getOne( $id );
857 857
 
858 858
 		$fields = FrmField::get_all_for_form( $id );
859 859
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
860 860
 
861 861
 		self::clean_submit_html( $values );
862 862
 
863
-        $action_controls = FrmFormActionsController::get_form_actions();
863
+		$action_controls = FrmFormActionsController::get_form_actions();
864 864
 
865 865
 		$sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
866
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
866
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
867 867
 
868 868
 		$styles = apply_filters( 'frm_get_style_opts', array() );
869 869
 
870 870
 		$first_h3 = 'frm_first_h3';
871 871
 
872 872
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
873
-    }
873
+	}
874 874
 
875 875
 	/**
876 876
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -885,10 +885,10 @@  discard block
 block discarded – undo
885 885
 		}
886 886
 	}
887 887
 
888
-    public static function mb_tags_box( $form_id, $class = '' ) {
888
+	public static function mb_tags_box( $form_id, $class = '' ) {
889 889
 		$fields = FrmField::get_all_for_form( $form_id, '', 'include' );
890
-        $linked_forms = array();
891
-        $col = 'one';
890
+		$linked_forms = array();
891
+		$col = 'one';
892 892
 		$settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
893 893
 
894 894
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 		$advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
898 898
 
899 899
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
900
-    }
900
+	}
901 901
 
902 902
 	/**
903 903
 	 * @since 3.04.01
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			''          => '',
992 992
 			'siteurl'   => __( 'Site URL', 'formidable' ),
993 993
 			'sitename'  => __( 'Site Name', 'formidable' ),
994
-        );
994
+		);
995 995
 
996 996
 		if ( ! FrmAppHelper::pro_is_installed() ) {
997 997
 			unset( $entry_shortcodes['post_id'] );
@@ -1041,21 +1041,21 @@  discard block
 block discarded – undo
1041 1041
 		wp_die();
1042 1042
 	}
1043 1043
 
1044
-    public static function filter_content( $content, $form, $entry = false ) {
1044
+	public static function filter_content( $content, $form, $entry = false ) {
1045 1045
 		self::get_entry_by_param( $entry );
1046
-        if ( ! $entry ) {
1047
-            return $content;
1048
-        }
1046
+		if ( ! $entry ) {
1047
+			return $content;
1048
+		}
1049 1049
 
1050
-        if ( is_object( $form ) ) {
1051
-            $form = $form->id;
1052
-        }
1050
+		if ( is_object( $form ) ) {
1051
+			$form = $form->id;
1052
+		}
1053 1053
 
1054
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1055
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1054
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1055
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1056 1056
 
1057
-        return $content;
1058
-    }
1057
+		return $content;
1058
+	}
1059 1059
 
1060 1060
 	private static function get_entry_by_param( &$entry ) {
1061 1061
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -1067,153 +1067,153 @@  discard block
 block discarded – undo
1067 1067
 		}
1068 1068
 	}
1069 1069
 
1070
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1071
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1072
-    }
1070
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1071
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1072
+	}
1073 1073
 
1074
-    public static function process_bulk_form_actions( $errors ) {
1075
-        if ( ! $_REQUEST ) {
1076
-            return $errors;
1077
-        }
1074
+	public static function process_bulk_form_actions( $errors ) {
1075
+		if ( ! $_REQUEST ) {
1076
+			return $errors;
1077
+		}
1078 1078
 
1079 1079
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1080
-        if ( $bulkaction == -1 ) {
1080
+		if ( $bulkaction == -1 ) {
1081 1081
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1082
-        }
1082
+		}
1083 1083
 
1084
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
1085
-            FrmAppHelper::remove_get_action();
1084
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
1085
+			FrmAppHelper::remove_get_action();
1086 1086
 
1087
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
1088
-        }
1087
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
1088
+		}
1089 1089
 
1090 1090
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
1091
-        if ( empty( $ids ) ) {
1092
-            $errors[] = __( 'No forms were specified', 'formidable' );
1093
-            return $errors;
1094
-        }
1095
-
1096
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
1097
-        if ( $permission_error !== false ) {
1098
-            $errors[] = $permission_error;
1099
-            return $errors;
1100
-        }
1101
-
1102
-        if ( ! is_array( $ids ) ) {
1103
-            $ids = explode( ',', $ids );
1104
-        }
1105
-
1106
-        switch ( $bulkaction ) {
1107
-            case 'delete':
1108
-                $message = self::bulk_destroy( $ids );
1091
+		if ( empty( $ids ) ) {
1092
+			$errors[] = __( 'No forms were specified', 'formidable' );
1093
+			return $errors;
1094
+		}
1095
+
1096
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
1097
+		if ( $permission_error !== false ) {
1098
+			$errors[] = $permission_error;
1099
+			return $errors;
1100
+		}
1101
+
1102
+		if ( ! is_array( $ids ) ) {
1103
+			$ids = explode( ',', $ids );
1104
+		}
1105
+
1106
+		switch ( $bulkaction ) {
1107
+			case 'delete':
1108
+				$message = self::bulk_destroy( $ids );
1109 1109
 				break;
1110
-            case 'trash':
1111
-                $message = self::bulk_trash( $ids );
1110
+			case 'trash':
1111
+				$message = self::bulk_trash( $ids );
1112 1112
 				break;
1113
-            case 'untrash':
1114
-                $message = self::bulk_untrash( $ids );
1115
-        }
1113
+			case 'untrash':
1114
+				$message = self::bulk_untrash( $ids );
1115
+		}
1116 1116
 
1117
-        if ( isset( $message ) && ! empty( $message ) ) {
1117
+		if ( isset( $message ) && ! empty( $message ) ) {
1118 1118
 			$errors['message'] = $message;
1119
-        }
1119
+		}
1120 1120
 
1121
-        return $errors;
1122
-    }
1121
+		return $errors;
1122
+	}
1123 1123
 
1124
-    public static function route() {
1124
+	public static function route() {
1125 1125
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1126
-        $vars = array();
1126
+		$vars = array();
1127 1127
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
1128 1128
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
1129 1129
 
1130 1130
 			$json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
1131 1131
 			$json_vars = json_decode( $json_vars, true );
1132 1132
 			if ( empty( $json_vars ) ) {
1133
-                // json decoding failed so we should return an error message
1133
+				// json decoding failed so we should return an error message
1134 1134
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1135
-                if ( 'edit' == $action ) {
1136
-                    $action = 'update';
1137
-                }
1135
+				if ( 'edit' == $action ) {
1136
+					$action = 'update';
1137
+				}
1138 1138
 
1139 1139
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1140
-            } else {
1140
+			} else {
1141 1141
 				$vars = FrmAppHelper::json_to_array( $json_vars );
1142
-                $action = $vars[ $action ];
1142
+				$action = $vars[ $action ];
1143 1143
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1144 1144
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1145 1145
 				$_POST = array_merge( $_POST, $_REQUEST );
1146
-            }
1147
-        } else {
1146
+			}
1147
+		} else {
1148 1148
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1149
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
1150
-                // override the action for this page
1151
-    			$action = 'delete_all';
1152
-            }
1153
-        }
1149
+			if ( isset( $_REQUEST['delete_all'] ) ) {
1150
+				// override the action for this page
1151
+				$action = 'delete_all';
1152
+			}
1153
+		}
1154 1154
 
1155 1155
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1156
-        FrmAppHelper::trigger_hook_load( 'form' );
1156
+		FrmAppHelper::trigger_hook_load( 'form' );
1157 1157
 
1158
-        switch ( $action ) {
1159
-            case 'new':
1158
+		switch ( $action ) {
1159
+			case 'new':
1160 1160
 				return self::new_form( $vars );
1161 1161
 			case 'add_new':
1162 1162
 			case 'list_templates':
1163
-            case 'create':
1164
-            case 'edit':
1165
-            case 'update':
1166
-            case 'duplicate':
1167
-            case 'trash':
1168
-            case 'untrash':
1169
-            case 'destroy':
1170
-            case 'delete_all':
1171
-            case 'settings':
1172
-            case 'update_settings':
1163
+			case 'create':
1164
+			case 'edit':
1165
+			case 'update':
1166
+			case 'duplicate':
1167
+			case 'trash':
1168
+			case 'untrash':
1169
+			case 'destroy':
1170
+			case 'delete_all':
1171
+			case 'settings':
1172
+			case 'update_settings':
1173 1173
 				return self::$action( $vars );
1174
-            default:
1174
+			default:
1175 1175
 				do_action( 'frm_form_action_' . $action );
1176 1176
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1177
-                    return;
1178
-                }
1177
+					return;
1178
+				}
1179 1179
 
1180 1180
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1181
-                if ( $action == -1 ) {
1181
+				if ( $action == -1 ) {
1182 1182
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1183
-                }
1183
+				}
1184 1184
 
1185 1185
 				if ( strpos( $action, 'bulk_' ) === 0 ) {
1186
-                    FrmAppHelper::remove_get_action();
1187
-                    return self::list_form();
1188
-                }
1186
+					FrmAppHelper::remove_get_action();
1187
+					return self::list_form();
1188
+				}
1189 1189
 
1190
-                return self::display_forms_list();
1191
-        }
1192
-    }
1190
+				return self::display_forms_list();
1191
+		}
1192
+	}
1193 1193
 
1194
-    public static function json_error( $errors ) {
1195
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1196
-        return $errors;
1197
-    }
1194
+	public static function json_error( $errors ) {
1195
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1196
+		return $errors;
1197
+	}
1198 1198
 
1199 1199
 
1200
-    /* FRONT-END FORMS */
1201
-    public static function admin_bar_css() {
1200
+	/* FRONT-END FORMS */
1201
+	public static function admin_bar_css() {
1202 1202
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1203
-            return;
1204
-        }
1203
+			return;
1204
+		}
1205 1205
 
1206 1206
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1207 1207
 		FrmAppHelper::load_font_style();
1208 1208
 	}
1209 1209
 
1210 1210
 	public static function admin_bar_configure() {
1211
-        global $frm_vars;
1211
+		global $frm_vars;
1212 1212
 		if ( empty( $frm_vars['forms_loaded'] ) ) {
1213
-            return;
1214
-        }
1213
+			return;
1214
+		}
1215 1215
 
1216
-        $actions = array();
1216
+		$actions = array();
1217 1217
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1218 1218
 			if ( is_object( $form ) ) {
1219 1219
 				$actions[ $form->id ] = $form->name;
@@ -1268,18 +1268,18 @@  discard block
 block discarded – undo
1268 1268
 		}
1269 1269
 	}
1270 1270
 
1271
-    //formidable shortcode
1271
+	//formidable shortcode
1272 1272
 	public static function get_form_shortcode( $atts ) {
1273
-        global $frm_vars;
1273
+		global $frm_vars;
1274 1274
 		if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1275
-            $sc = '[formidable';
1275
+			$sc = '[formidable';
1276 1276
 			if ( ! empty( $atts ) ) {
1277 1277
 				foreach ( $atts as $k => $v ) {
1278 1278
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1279 1279
 				}
1280 1280
 			}
1281 1281
 			return $sc . ']';
1282
-        }
1282
+		}
1283 1283
 
1284 1284
 		$shortcode_atts = shortcode_atts(
1285 1285
 			array(
@@ -1297,27 +1297,27 @@  discard block
 block discarded – undo
1297 1297
 		);
1298 1298
 		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1299 1299
 
1300
-        return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1301
-    }
1300
+		return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1301
+	}
1302 1302
 
1303
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1304
-        if ( empty( $id ) ) {
1305
-            $id = $key;
1306
-        }
1303
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1304
+		if ( empty( $id ) ) {
1305
+			$id = $key;
1306
+		}
1307 1307
 
1308
-        $form = self::maybe_get_form_to_show( $id );
1309
-        if ( ! $form ) {
1310
-            return __( 'Please select a valid form', 'formidable' );
1311
-        }
1308
+		$form = self::maybe_get_form_to_show( $id );
1309
+		if ( ! $form ) {
1310
+			return __( 'Please select a valid form', 'formidable' );
1311
+		}
1312 1312
 
1313 1313
 		FrmAppController::maybe_update_styles();
1314 1314
 
1315 1315
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1316
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1316
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1317 1317
 
1318
-        $form = apply_filters( 'frm_pre_display_form', $form );
1318
+		$form = apply_filters( 'frm_pre_display_form', $form );
1319 1319
 
1320
-        $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1320
+		$frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
1321 1321
 
1322 1322
 		if ( self::is_viewable_draft_form( $form ) ) {
1323 1323
 			// don't show a draft form on a page
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 		}
1341 1341
 
1342 1342
 		return $form;
1343
-    }
1343
+	}
1344 1344
 
1345 1345
 	private static function maybe_get_form_to_show( $id ) {
1346 1346
 		$form = false;
@@ -1369,21 +1369,21 @@  discard block
 block discarded – undo
1369 1369
 		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'] );
1370 1370
 	}
1371 1371
 
1372
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1372
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1373 1373
 		ob_start();
1374 1374
 
1375 1375
 		do_action( 'frm_before_get_form', $atts );
1376 1376
 
1377
-        self::get_form_contents( $form, $title, $description, $atts );
1377
+		self::get_form_contents( $form, $title, $description, $atts );
1378 1378
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1379 1379
 
1380
-        $contents = ob_get_contents();
1381
-        ob_end_clean();
1380
+		$contents = ob_get_contents();
1381
+		ob_end_clean();
1382 1382
 
1383 1383
 		self::maybe_minimize_form( $atts, $contents );
1384 1384
 
1385
-        return $contents;
1386
-    }
1385
+		return $contents;
1386
+	}
1387 1387
 
1388 1388
 	public static function enqueue_scripts( $params ) {
1389 1389
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1736,10 +1736,10 @@  discard block
 block discarded – undo
1736 1736
 	}
1737 1737
 
1738 1738
 	public static function defer_script_loading( $tag, $handle ) {
1739
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1740
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1739
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1740
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1741 1741
 		}
1742
-	    return $tag;
1742
+		return $tag;
1743 1743
 	}
1744 1744
 
1745 1745
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +548 added lines, -548 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.06';
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
 	}
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 		return add_query_arg( $query_args, $page ) . $anchor;
108 108
 	}
109 109
 
110
-    /**
111
-     * Get the Formidable settings
112
-     *
113
-     * @since 2.0
114
-     *
115
-     * @param array $args - May include the form id when values need translation.
116
-     * @return FrmSettings $frm_setings
117
-     */
110
+	/**
111
+	 * Get the Formidable settings
112
+	 *
113
+	 * @since 2.0
114
+	 *
115
+	 * @param array $args - May include the form id when values need translation.
116
+	 * @return FrmSettings $frm_setings
117
+	 */
118 118
 	public static function get_settings( $args = array() ) {
119 119
 		global $frm_settings;
120 120
 		if ( empty( $frm_settings ) ) {
@@ -179,50 +179,50 @@  discard block
 block discarded – undo
179 179
 		return $is_formidable;
180 180
 	}
181 181
 
182
-    /**
183
-     * Check for certain page in Formidable settings
184
-     *
185
-     * @since 2.0
186
-     *
187
-     * @param string $page The name of the page to check
188
-     * @return boolean
189
-     */
182
+	/**
183
+	 * Check for certain page in Formidable settings
184
+	 *
185
+	 * @since 2.0
186
+	 *
187
+	 * @param string $page The name of the page to check
188
+	 * @return boolean
189
+	 */
190 190
 	public static function is_admin_page( $page = 'formidable' ) {
191
-        global $pagenow;
191
+		global $pagenow;
192 192
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
193
-        if ( $pagenow ) {
193
+		if ( $pagenow ) {
194 194
 			// allow this to be true during ajax load i.e. ajax form builder loading
195 195
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
196
-        }
196
+		}
197 197
 
198 198
 		return is_admin() && $get_page == $page;
199
-    }
200
-
201
-    /**
202
-     * Check for the form preview page
203
-     *
204
-     * @since 2.0
205
-     *
206
-     * @param None
207
-     * @return boolean
208
-     */
209
-    public static function is_preview_page() {
210
-        global $pagenow;
199
+	}
200
+
201
+	/**
202
+	 * Check for the form preview page
203
+	 *
204
+	 * @since 2.0
205
+	 *
206
+	 * @param None
207
+	 * @return boolean
208
+	 */
209
+	public static function is_preview_page() {
210
+		global $pagenow;
211 211
 		$action = self::simple_get( 'action', 'sanitize_title' );
212 212
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
213
-    }
214
-
215
-    /**
216
-     * Check for ajax except the form preview page
217
-     *
218
-     * @since 2.0
219
-     *
220
-     * @param None
221
-     * @return boolean
222
-     */
223
-    public static function doing_ajax() {
224
-        return self::wp_doing_ajax() && ! self::is_preview_page();
225
-    }
213
+	}
214
+
215
+	/**
216
+	 * Check for ajax except the form preview page
217
+	 *
218
+	 * @since 2.0
219
+	 *
220
+	 * @param None
221
+	 * @return boolean
222
+	 */
223
+	public static function doing_ajax() {
224
+		return self::wp_doing_ajax() && ! self::is_preview_page();
225
+	}
226 226
 
227 227
 	public static function js_suffix() {
228 228
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -250,81 +250,81 @@  discard block
 block discarded – undo
250 250
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
251 251
 	}
252 252
 
253
-    /**
254
-     * Check if on an admin page
255
-     *
256
-     * @since 2.0
257
-     *
258
-     * @param None
259
-     * @return boolean
260
-     */
261
-    public static function is_admin() {
262
-        return is_admin() && ! self::wp_doing_ajax();
263
-    }
264
-
265
-    /**
266
-     * Check if value contains blank value or empty array
267
-     *
268
-     * @since 2.0
269
-     * @param mixed $value - value to check
253
+	/**
254
+	 * Check if on an admin page
255
+	 *
256
+	 * @since 2.0
257
+	 *
258
+	 * @param None
259
+	 * @return boolean
260
+	 */
261
+	public static function is_admin() {
262
+		return is_admin() && ! self::wp_doing_ajax();
263
+	}
264
+
265
+	/**
266
+	 * Check if value contains blank value or empty array
267
+	 *
268
+	 * @since 2.0
269
+	 * @param mixed $value - value to check
270 270
 	 * @param string
271
-     * @return boolean
272
-     */
273
-    public static function is_empty_value( $value, $empty = '' ) {
274
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
275
-    }
276
-
277
-    public static function is_not_empty_value( $value, $empty = '' ) {
278
-        return ! self::is_empty_value( $value, $empty );
279
-    }
280
-
281
-    /**
282
-     * Get any value from the $_SERVER
283
-     *
284
-     * @since 2.0
285
-     * @param string $value
286
-     * @return string
287
-     */
271
+	 * @return boolean
272
+	 */
273
+	public static function is_empty_value( $value, $empty = '' ) {
274
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
275
+	}
276
+
277
+	public static function is_not_empty_value( $value, $empty = '' ) {
278
+		return ! self::is_empty_value( $value, $empty );
279
+	}
280
+
281
+	/**
282
+	 * Get any value from the $_SERVER
283
+	 *
284
+	 * @since 2.0
285
+	 * @param string $value
286
+	 * @return string
287
+	 */
288 288
 	public static function get_server_value( $value ) {
289
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
290
-    }
291
-
292
-    /**
293
-     * Check for the IP address in several places
294
-     * Used by [ip] shortcode
295
-     *
296
-     * @return string The IP address of the current user
297
-     */
298
-    public static function get_ip_address() {
289
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
290
+	}
291
+
292
+	/**
293
+	 * Check for the IP address in several places
294
+	 * Used by [ip] shortcode
295
+	 *
296
+	 * @return string The IP address of the current user
297
+	 */
298
+	public static function get_ip_address() {
299 299
 		$ip = '';
300 300
 		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 ) {
301
-            if ( ! isset( $_SERVER[ $key ] ) ) {
302
-                continue;
303
-            }
301
+			if ( ! isset( $_SERVER[ $key ] ) ) {
302
+				continue;
303
+			}
304 304
 
305
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
305
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
306 306
 				$ip = trim( $ip ); // just to be safe
307 307
 
308 308
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
309
-                    return sanitize_text_field( $ip );
310
-                }
311
-            }
312
-        }
309
+					return sanitize_text_field( $ip );
310
+				}
311
+			}
312
+		}
313 313
 
314 314
 		return sanitize_text_field( $ip );
315
-    }
315
+	}
316 316
 
317
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
317
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
318 318
 		if ( strpos( $param, '[' ) ) {
319 319
 			$params = explode( '[', $param );
320
-            $param = $params[0];
321
-        }
320
+			$param = $params[0];
321
+		}
322 322
 
323 323
 		if ( $src == 'get' ) {
324
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
325
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
326
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
327
-            }
324
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
325
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
326
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
327
+			}
328 328
 			self::sanitize_value( $sanitize, $value );
329 329
 		} else {
330 330
 			$value = self::get_simple_request(
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 			}
349 349
 		}
350 350
 
351
-        return $value;
352
-    }
351
+		return $value;
352
+	}
353 353
 
354 354
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
355 355
 		return self::get_simple_request(
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 	}
418 418
 
419 419
 	/**
420
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
421
-	*
422
-	* @since 2.0.8
423
-	* @param string $value
424
-	* @return string $value
425
-	*/
420
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
421
+	 *
422
+	 * @since 2.0.8
423
+	 * @param string $value
424
+	 * @return string $value
425
+	 */
426 426
 	public static function preserve_backslashes( $value ) {
427 427
 		// If backslashes have already been added, don't add them again
428 428
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -444,14 +444,14 @@  discard block
 block discarded – undo
444 444
 		}
445 445
 	}
446 446
 
447
-    public static function sanitize_request( $sanitize_method, &$values ) {
448
-        $temp_values = $values;
449
-        foreach ( $temp_values as $k => $val ) {
450
-            if ( isset( $sanitize_method[ $k ] ) ) {
447
+	public static function sanitize_request( $sanitize_method, &$values ) {
448
+		$temp_values = $values;
449
+		foreach ( $temp_values as $k => $val ) {
450
+			if ( isset( $sanitize_method[ $k ] ) ) {
451 451
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
452
-            }
453
-        }
454
-    }
452
+			}
453
+		}
454
+	}
455 455
 
456 456
 	/**
457 457
 	 * Sanitize the value, and allow some HTML
@@ -588,40 +588,40 @@  discard block
 block discarded – undo
588 588
 		);
589 589
 	}
590 590
 
591
-    /**
592
-     * Used when switching the action for a bulk action
591
+	/**
592
+	 * Used when switching the action for a bulk action
593 593
 	 *
594
-     * @since 2.0
595
-     */
594
+	 * @since 2.0
595
+	 */
596 596
 	public static function remove_get_action() {
597 597
 		if ( ! isset( $_GET ) ) {
598 598
 			return;
599 599
 		}
600 600
 
601
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
602
-        if ( ! empty( $new_action ) ) {
601
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
602
+		if ( ! empty( $new_action ) ) {
603 603
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
604
-        }
605
-    }
604
+		}
605
+	}
606 606
 
607
-    /**
608
-     * Check the WP query for a parameter
609
-     *
610
-     * @since 2.0
611
-     * @return string|array
612
-     */
613
-    public static function get_query_var( $value, $param ) {
614
-        if ( $value != '' ) {
615
-            return $value;
616
-        }
607
+	/**
608
+	 * Check the WP query for a parameter
609
+	 *
610
+	 * @since 2.0
611
+	 * @return string|array
612
+	 */
613
+	public static function get_query_var( $value, $param ) {
614
+		if ( $value != '' ) {
615
+			return $value;
616
+		}
617 617
 
618
-        global $wp_query;
619
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
620
-            $value = $wp_query->query_vars[ $param ];
621
-        }
618
+		global $wp_query;
619
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
620
+			$value = $wp_query->query_vars[ $param ];
621
+		}
622 622
 
623
-        return $value;
624
-    }
623
+		return $value;
624
+	}
625 625
 
626 626
 	/**
627 627
 	 * @since 3.0
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 		<?php
674 674
 	}
675 675
 
676
-    /**
677
-     * @param string $type
678
-     */
679
-    public static function trigger_hook_load( $type, $object = null ) {
680
-        // only load the form hooks once
676
+	/**
677
+	 * @param string $type
678
+	 */
679
+	public static function trigger_hook_load( $type, $object = null ) {
680
+		// only load the form hooks once
681 681
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
682
-        if ( ! $hooks_loaded ) {
682
+		if ( ! $hooks_loaded ) {
683 683
 			do_action( 'frm_load_' . $type . '_hooks' );
684
-        }
685
-    }
684
+		}
685
+	}
686 686
 
687 687
 	/**
688 688
 	 * Save all front-end js scripts into a single file
@@ -707,18 +707,18 @@  discard block
 block discarded – undo
707 707
 		$new_file->combine_files( $files );
708 708
 	}
709 709
 
710
-    /**
711
-     * Check a value from a shortcode to see if true or false.
712
-     * True when value is 1, true, 'true', 'yes'
713
-     *
714
-     * @since 1.07.10
715
-     *
716
-     * @param string $value The value to compare
717
-     * @return boolean True or False
718
-     */
710
+	/**
711
+	 * Check a value from a shortcode to see if true or false.
712
+	 * True when value is 1, true, 'true', 'yes'
713
+	 *
714
+	 * @since 1.07.10
715
+	 *
716
+	 * @param string $value The value to compare
717
+	 * @return boolean True or False
718
+	 */
719 719
 	public static function is_true( $value ) {
720
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
721
-    }
720
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
721
+	}
722 722
 
723 723
 	public static function get_pages() {
724 724
 		$query = array(
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 		return get_posts( $query );
732 732
 	}
733 733
 
734
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
735
-        $pages = self::get_pages();
734
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
735
+		$pages = self::get_pages();
736 736
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
737
-    ?>
737
+	?>
738 738
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
739 739
             <option value=""> </option>
740 740
             <?php foreach ( $pages as $page ) { ?>
@@ -744,16 +744,16 @@  discard block
 block discarded – undo
744 744
             <?php } ?>
745 745
         </select>
746 746
     <?php
747
-    }
747
+	}
748 748
 
749 749
 	public static function post_edit_link( $post_id ) {
750 750
 		$post = get_post( $post_id );
751
-        if ( $post ) {
751
+		if ( $post ) {
752 752
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
753 753
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
754
-        }
755
-        return '';
756
-    }
754
+		}
755
+		return '';
756
+	}
757 757
 
758 758
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
759 759
 		?>
@@ -764,73 +764,73 @@  discard block
 block discarded – undo
764 764
 	}
765 765
 
766 766
 	public static function roles_options( $capability ) {
767
-        global $frm_vars;
767
+		global $frm_vars;
768 768
 		if ( isset( $frm_vars['editable_roles'] ) ) {
769
-            $editable_roles = $frm_vars['editable_roles'];
770
-        } else {
771
-            $editable_roles = get_editable_roles();
772
-            $frm_vars['editable_roles'] = $editable_roles;
773
-        }
769
+			$editable_roles = $frm_vars['editable_roles'];
770
+		} else {
771
+			$editable_roles = get_editable_roles();
772
+			$frm_vars['editable_roles'] = $editable_roles;
773
+		}
774 774
 
775
-        foreach ( $editable_roles as $role => $details ) {
775
+		foreach ( $editable_roles as $role => $details ) {
776 776
 			$name = translate_user_role( $details['name'] );
777 777
 			?>
778 778
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
779 779
 <?php
780 780
 			unset( $role, $details );
781
-        }
782
-    }
781
+		}
782
+	}
783 783
 
784 784
 	public static function frm_capabilities( $type = 'auto' ) {
785
-        $cap = array(
786
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
787
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
788
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
789
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
790
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
791
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
792
-        );
785
+		$cap = array(
786
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
787
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
788
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
789
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
790
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
791
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
792
+		);
793 793
 
794 794
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
795
-            return $cap;
796
-        }
795
+			return $cap;
796
+		}
797 797
 
798
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
799
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
800
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
801
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
798
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
799
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
800
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
801
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
802 802
 
803
-        return $cap;
804
-    }
803
+		return $cap;
804
+	}
805 805
 
806 806
 	public static function user_has_permission( $needed_role ) {
807
-        if ( $needed_role == '-1' ) {
808
-            return false;
807
+		if ( $needed_role == '-1' ) {
808
+			return false;
809 809
 		}
810 810
 
811
-        // $needed_role will be equal to blank if "Logged-in users" is selected
812
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
813
-            return true;
814
-        }
811
+		// $needed_role will be equal to blank if "Logged-in users" is selected
812
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
813
+			return true;
814
+		}
815 815
 
816
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
817
-        foreach ( $roles as $role ) {
816
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
817
+		foreach ( $roles as $role ) {
818 818
 			if ( current_user_can( $role ) ) {
819
-        		return true;
819
+				return true;
820 820
 			}
821
-        	if ( $role == $needed_role ) {
822
-        		break;
821
+			if ( $role == $needed_role ) {
822
+				break;
823 823
 			}
824
-        }
825
-        return false;
826
-    }
827
-
828
-    /**
829
-     * Make sure administrators can see Formidable menu
830
-     *
831
-     * @since 2.0
832
-     */
833
-    public static function maybe_add_permissions() {
824
+		}
825
+		return false;
826
+	}
827
+
828
+	/**
829
+	 * Make sure administrators can see Formidable menu
830
+	 *
831
+	 * @since 2.0
832
+	 */
833
+	public static function maybe_add_permissions() {
834 834
 		self::force_capability( 'frm_view_entries' );
835 835
 
836 836
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -839,12 +839,12 @@  discard block
 block discarded – undo
839 839
 
840 840
 		$user_id = get_current_user_id();
841 841
 		$user = new WP_User( $user_id );
842
-        $frm_roles = self::frm_capabilities();
843
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
842
+		$frm_roles = self::frm_capabilities();
843
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
844 844
 			$user->add_cap( $frm_role );
845 845
 			unset( $frm_role, $frm_role_description );
846
-        }
847
-    }
846
+		}
847
+	}
848 848
 
849 849
 	/**
850 850
 	 * Make sure admins have permission to see the menu items
@@ -861,30 +861,30 @@  discard block
 block discarded – undo
861 861
 		}
862 862
 	}
863 863
 
864
-    /**
865
-     * Check if the user has permision for action.
866
-     * Return permission message and stop the action if no permission
864
+	/**
865
+	 * Check if the user has permision for action.
866
+	 * Return permission message and stop the action if no permission
867 867
 	 *
868
-     * @since 2.0
869
-     * @param string $permission
870
-     */
868
+	 * @since 2.0
869
+	 * @param string $permission
870
+	 */
871 871
 	public static function permission_check( $permission, $show_message = 'show' ) {
872 872
 		$permission_error = self::permission_nonce_error( $permission );
873
-        if ( $permission_error !== false ) {
874
-            if ( 'hide' == $show_message ) {
875
-                $permission_error = '';
876
-            }
873
+		if ( $permission_error !== false ) {
874
+			if ( 'hide' == $show_message ) {
875
+				$permission_error = '';
876
+			}
877 877
 			wp_die( esc_html( $permission_error ) );
878
-        }
879
-    }
878
+		}
879
+	}
880 880
 
881
-    /**
882
-     * Check user permission and nonce
881
+	/**
882
+	 * Check user permission and nonce
883 883
 	 *
884
-     * @since 2.0
885
-     * @param string $permission
886
-     * @return false|string The permission message or false if allowed
887
-     */
884
+	 * @since 2.0
885
+	 * @param string $permission
886
+	 * @return false|string The permission message or false if allowed
887
+	 */
888 888
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
889 889
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
890 890
 			$frm_settings = self::get_settings();
@@ -893,22 +893,22 @@  discard block
 block discarded – undo
893 893
 
894 894
 		$error = false;
895 895
 		if ( empty( $nonce_name ) ) {
896
-            return $error;
897
-        }
896
+			return $error;
897
+		}
898 898
 
899
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
900
-            $frm_settings = self::get_settings();
901
-            $error = $frm_settings->admin_permission;
902
-        }
899
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
900
+			$frm_settings = self::get_settings();
901
+			$error = $frm_settings->admin_permission;
902
+		}
903 903
 
904
-        return $error;
905
-    }
904
+		return $error;
905
+	}
906 906
 
907
-    public static function checked( $values, $current ) {
907
+	public static function checked( $values, $current ) {
908 908
 		if ( self::check_selected( $values, $current ) ) {
909
-            echo ' checked="checked"';
909
+			echo ' checked="checked"';
910 910
 		}
911
-    }
911
+	}
912 912
 
913 913
 	public static function check_selected( $values, $current ) {
914 914
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -946,24 +946,24 @@  discard block
 block discarded – undo
946 946
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
947 947
 	}
948 948
 
949
-    /**
950
-     * Flatten a multi-dimensional array
951
-     */
949
+	/**
950
+	 * Flatten a multi-dimensional array
951
+	 */
952 952
 	public static function array_flatten( $array, $keys = 'keep' ) {
953
-        $return = array();
954
-        foreach ( $array as $key => $value ) {
953
+		$return = array();
954
+		foreach ( $array as $key => $value ) {
955 955
 			if ( is_array( $value ) ) {
956 956
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
957
-            } else {
957
+			} else {
958 958
 				if ( $keys == 'keep' ) {
959 959
 					$return[ $key ] = $value;
960 960
 				} else {
961 961
 					$return[] = $value;
962 962
 				}
963
-            }
964
-        }
965
-        return $return;
966
-    }
963
+			}
964
+		}
965
+		return $return;
966
+	}
967 967
 
968 968
 	public static function esc_textarea( $text, $is_rich_text = false ) {
969 969
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -974,11 +974,11 @@  discard block
 block discarded – undo
974 974
 		return apply_filters( 'esc_textarea', $safe_text, $text );
975 975
 	}
976 976
 
977
-    /**
978
-     * Add auto paragraphs to text areas
977
+	/**
978
+	 * Add auto paragraphs to text areas
979 979
 	 *
980
-     * @since 2.0
981
-     */
980
+	 * @since 2.0
981
+	 */
982 982
 	public static function use_wpautop( $content ) {
983 983
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
984 984
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -987,26 +987,26 @@  discard block
 block discarded – undo
987 987
 	}
988 988
 
989 989
 	public static function replace_quotes( $val ) {
990
-        //Replace double quotes
990
+		//Replace double quotes
991 991
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
992
-        //Replace single quotes
993
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
994
-        return $val;
995
-    }
996
-
997
-    /**
998
-     * @since 2.0
999
-     * @return string The base Google APIS url for the current version of jQuery UI
1000
-     */
1001
-    public static function jquery_ui_base_url() {
992
+		//Replace single quotes
993
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
994
+		return $val;
995
+	}
996
+
997
+	/**
998
+	 * @since 2.0
999
+	 * @return string The base Google APIS url for the current version of jQuery UI
1000
+	 */
1001
+	public static function jquery_ui_base_url() {
1002 1002
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
1003 1003
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
1004
-        return $url;
1005
-    }
1004
+		return $url;
1005
+	}
1006 1006
 
1007
-    /**
1008
-     * @param string $handle
1009
-     */
1007
+	/**
1008
+	 * @param string $handle
1009
+	 */
1010 1010
 	public static function script_version( $handle, $default = 0 ) {
1011 1011
 		global $wp_scripts;
1012 1012
 		if ( ! $wp_scripts ) {
@@ -1028,12 +1028,12 @@  discard block
 block discarded – undo
1028 1028
 
1029 1029
 	public static function js_redirect( $url ) {
1030 1030
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1031
-    }
1031
+	}
1032 1032
 
1033 1033
 	public static function get_user_id_param( $user_id ) {
1034 1034
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
1035
-            return $user_id;
1036
-        }
1035
+			return $user_id;
1036
+		}
1037 1037
 
1038 1038
 		$user_id = sanitize_text_field( $user_id );
1039 1039
 		if ( $user_id == 'current' ) {
@@ -1045,14 +1045,14 @@  discard block
 block discarded – undo
1045 1045
 				$user = get_user_by( 'login', $user_id );
1046 1046
 			}
1047 1047
 
1048
-            if ( $user ) {
1049
-                $user_id = $user->ID;
1050
-            }
1048
+			if ( $user ) {
1049
+				$user_id = $user->ID;
1050
+			}
1051 1051
 			unset( $user );
1052
-        }
1052
+		}
1053 1053
 
1054
-        return $user_id;
1055
-    }
1054
+		return $user_id;
1055
+	}
1056 1056
 
1057 1057
 	public static function get_file_contents( $filename, $atts = array() ) {
1058 1058
 		if ( ! is_file( $filename ) ) {
@@ -1067,28 +1067,28 @@  discard block
 block discarded – undo
1067 1067
 		return $contents;
1068 1068
 	}
1069 1069
 
1070
-    /**
1071
-     * @param string $table_name
1072
-     * @param string $column
1070
+	/**
1071
+	 * @param string $table_name
1072
+	 * @param string $column
1073 1073
 	 * @param int $id
1074 1074
 	 * @param int $num_chars
1075
-     */
1076
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1077
-        $key = '';
1075
+	 */
1076
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
1077
+		$key = '';
1078 1078
 
1079
-        if ( ! empty( $name ) ) {
1079
+		if ( ! empty( $name ) ) {
1080 1080
 			$key = sanitize_key( $name );
1081
-        }
1081
+		}
1082 1082
 
1083 1083
 		if ( empty( $key ) ) {
1084 1084
 			$max_slug_value = pow( 36, $num_chars );
1085
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
1085
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
1086 1086
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
1087
-        }
1087
+		}
1088 1088
 
1089 1089
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
1090 1090
 			$key = $key . 'a';
1091
-        }
1091
+		}
1092 1092
 
1093 1093
 		$key_check = FrmDb::get_var(
1094 1094
 			$table_name,
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		);
1101 1101
 
1102 1102
 		if ( $key_check || is_numeric( $key_check ) ) {
1103
-            $suffix = 2;
1103
+			$suffix = 2;
1104 1104
 			do {
1105 1105
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1106 1106
 				$key_check = FrmDb::get_var(
@@ -1114,20 +1114,20 @@  discard block
 block discarded – undo
1114 1114
 				$suffix++;
1115 1115
 			} while ( $key_check || is_numeric( $key_check ) );
1116 1116
 			$key = $alt_post_name;
1117
-        }
1118
-        return $key;
1119
-    }
1117
+		}
1118
+		return $key;
1119
+	}
1120 1120
 
1121
-    /**
1122
-     * Editing a Form or Entry
1121
+	/**
1122
+	 * Editing a Form or Entry
1123 1123
 	 *
1124
-     * @param string $table
1125
-     * @return bool|array
1126
-     */
1127
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1128
-        if ( ! $record ) {
1129
-            return false;
1130
-        }
1124
+	 * @param string $table
1125
+	 * @return bool|array
1126
+	 */
1127
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1128
+		if ( ! $record ) {
1129
+			return false;
1130
+		}
1131 1131
 
1132 1132
 		if ( empty( $post_values ) ) {
1133 1133
 			$post_values = stripslashes_deep( $_POST );
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 
1151 1151
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1152 1152
 
1153
-        if ( $table == 'entries' ) {
1154
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1155
-        } else if ( $table == 'forms' ) {
1156
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1157
-        }
1153
+		if ( $table == 'entries' ) {
1154
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1155
+		} else if ( $table == 'forms' ) {
1156
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1157
+		}
1158 1158
 
1159
-        return $values;
1160
-    }
1159
+		return $values;
1160
+	}
1161 1161
 
1162 1162
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1163 1163
 		if ( ! empty( $fields ) ) {
@@ -1170,15 +1170,15 @@  discard block
 block discarded – undo
1170 1170
 	}
1171 1171
 
1172 1172
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1173
-        $post_values = $args['post_values'];
1173
+		$post_values = $args['post_values'];
1174 1174
 
1175
-        if ( $args['default'] ) {
1176
-            $meta_value = $field->default_value;
1177
-        } else {
1175
+		if ( $args['default'] ) {
1176
+			$meta_value = $field->default_value;
1177
+		} else {
1178 1178
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1179 1179
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1180
-                    $field->field_options['custom_field'] = '';
1181
-                }
1180
+					$field->field_options['custom_field'] = '';
1181
+				}
1182 1182
 				$meta_value = FrmProEntryMetaHelper::get_post_value(
1183 1183
 					$record->post_id,
1184 1184
 					$field->field_options['post_field'],
@@ -1190,31 +1190,31 @@  discard block
 block discarded – undo
1190 1190
 						'field' => $field,
1191 1191
 					)
1192 1192
 				);
1193
-            } else {
1193
+			} else {
1194 1194
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1195
-            }
1196
-        }
1195
+			}
1196
+		}
1197 1197
 
1198 1198
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1199
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1199
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1200 1200
 
1201 1201
 		$field_array = self::start_field_array( $field );
1202 1202
 		$field_array['value'] = $new_value;
1203 1203
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1204 1204
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1205 1205
 
1206
-        $args['field_type'] = $field_type;
1206
+		$args['field_type'] = $field_type;
1207 1207
 
1208 1208
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1209 1209
 
1210 1210
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1211
-            $field_array['unique_msg'] = '';
1212
-        }
1211
+			$field_array['unique_msg'] = '';
1212
+		}
1213 1213
 
1214
-        $field_array = array_merge( $field->field_options, $field_array );
1214
+		$field_array = array_merge( $field->field_options, $field_array );
1215 1215
 
1216
-        $values['fields'][ $field->id ] = $field_array;
1217
-    }
1216
+		$values['fields'][ $field->id ] = $field_array;
1217
+	}
1218 1218
 
1219 1219
 	/**
1220 1220
 	 * @since 3.0
@@ -1235,20 +1235,20 @@  discard block
 block discarded – undo
1235 1235
 		);
1236 1236
 	}
1237 1237
 
1238
-    /**
1239
-     * @param string $table
1240
-     */
1238
+	/**
1239
+	 * @param string $table
1240
+	 */
1241 1241
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1242
-        if ( $table == 'entries' ) {
1243
-            $form = $record->form_id;
1242
+		if ( $table == 'entries' ) {
1243
+			$form = $record->form_id;
1244 1244
 			FrmForm::maybe_get_form( $form );
1245
-        } else {
1246
-            $form = $record;
1247
-        }
1245
+		} else {
1246
+			$form = $record;
1247
+		}
1248 1248
 
1249
-        if ( ! $form ) {
1250
-            return;
1251
-        }
1249
+		if ( ! $form ) {
1250
+			return;
1251
+		}
1252 1252
 
1253 1253
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1254 1254
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1257,26 +1257,26 @@  discard block
 block discarded – undo
1257 1257
 			return;
1258 1258
 		}
1259 1259
 
1260
-        foreach ( $form->options as $opt => $value ) {
1261
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1262
-        }
1260
+		foreach ( $form->options as $opt => $value ) {
1261
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1262
+		}
1263 1263
 
1264 1264
 		self::fill_form_defaults( $post_values, $values );
1265
-    }
1265
+	}
1266 1266
 
1267
-    /**
1268
-     * Set to POST value or default
1269
-     */
1267
+	/**
1268
+	 * Set to POST value or default
1269
+	 */
1270 1270
 	private static function fill_form_defaults( $post_values, array &$values ) {
1271
-        $form_defaults = FrmFormsHelper::get_default_opts();
1271
+		$form_defaults = FrmFormsHelper::get_default_opts();
1272 1272
 
1273
-        foreach ( $form_defaults as $opt => $default ) {
1274
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1273
+		foreach ( $form_defaults as $opt => $default ) {
1274
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1275 1275
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1276
-            }
1276
+			}
1277 1277
 
1278 1278
 			unset( $opt, $default );
1279
-        }
1279
+		}
1280 1280
 
1281 1281
 		if ( ! isset( $values['custom_style'] ) ) {
1282 1282
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1285,10 +1285,10 @@  discard block
 block discarded – undo
1285 1285
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1286 1286
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1287 1287
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1288
-            }
1288
+			}
1289 1289
 			unset( $h );
1290
-        }
1291
-    }
1290
+		}
1291
+	}
1292 1292
 
1293 1293
 	/**
1294 1294
 	 * @since 2.2.10
@@ -1311,33 +1311,33 @@  discard block
 block discarded – undo
1311 1311
 		if ( $possible_email_field ) {
1312 1312
 			$class .= 'show_frm_not_email_to';
1313 1313
 		}
1314
-    ?>
1314
+	?>
1315 1315
 <li>
1316 1316
 	<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>
1317 1317
 	<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>
1318 1318
 	<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>
1319 1319
 </li>
1320 1320
     <?php
1321
-    }
1321
+	}
1322 1322
 
1323 1323
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1324
-        if ( is_array( $str ) ) {
1325
-            return '';
1324
+		if ( is_array( $str ) ) {
1325
+			return '';
1326 1326
 		}
1327 1327
 
1328
-        $length = (int) $length;
1328
+		$length = (int) $length;
1329 1329
 		$str = wp_strip_all_tags( $str );
1330 1330
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1331 1331
 
1332 1332
 		if ( $length == 0 ) {
1333
-            return '';
1334
-        } else if ( $length <= 10 ) {
1333
+			return '';
1334
+		} else if ( $length <= 10 ) {
1335 1335
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1336 1336
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1337
-        }
1337
+		}
1338 1338
 
1339
-        $sub = '';
1340
-        $len = 0;
1339
+		$sub = '';
1340
+		$len = 0;
1341 1341
 
1342 1342
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1343 1343
 
@@ -1345,21 +1345,21 @@  discard block
 block discarded – undo
1345 1345
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1346 1346
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1347 1347
 			if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
1348
-                break;
1349
-            }
1348
+				break;
1349
+			}
1350 1350
 
1351
-            $sub .= $part;
1351
+			$sub .= $part;
1352 1352
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1353 1353
 
1354 1354
 			if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) {
1355
-                break;
1356
-            }
1355
+				break;
1356
+			}
1357 1357
 
1358 1358
 			unset( $total_len, $word );
1359
-        }
1359
+		}
1360 1360
 
1361 1361
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1362
-    }
1362
+	}
1363 1363
 
1364 1364
 	public static function mb_function( $function_names, $args ) {
1365 1365
 		$mb_function_name = $function_names[0];
@@ -1372,17 +1372,17 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1374 1374
 		if ( empty( $date ) ) {
1375
-            return $date;
1376
-        }
1375
+			return $date;
1376
+		}
1377 1377
 
1378 1378
 		if ( empty( $date_format ) ) {
1379 1379
 			$date_format = get_option( 'date_format' );
1380 1380
 		}
1381 1381
 
1382 1382
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1383
-            $frmpro_settings = new FrmProSettings();
1383
+			$frmpro_settings = new FrmProSettings();
1384 1384
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1385
-        }
1385
+		}
1386 1386
 
1387 1387
 		$formatted = self::get_localized_date( $date_format, $date );
1388 1388
 
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 			$formatted .= self::add_time_to_date( $time_format, $date );
1392 1392
 		}
1393 1393
 
1394
-        return $formatted;
1395
-    }
1394
+		return $formatted;
1395
+	}
1396 1396
 
1397 1397
 	private static function add_time_to_date( $time_format, $date ) {
1398 1398
 		if ( empty( $time_format ) ) {
@@ -1474,32 +1474,32 @@  discard block
 block discarded – undo
1474 1474
 		);
1475 1475
 	}
1476 1476
 
1477
-    // Pagination Methods
1477
+	// Pagination Methods
1478 1478
 
1479
-    /**
1480
-     * @param integer $current_p
1481
-     */
1479
+	/**
1480
+	 * @param integer $current_p
1481
+	 */
1482 1482
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1483 1483
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1484 1484
 	}
1485 1485
 
1486
-    /**
1487
-     * @param integer $current_p
1488
-     */
1489
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1490
-        if ( $current_p == 1 ) {
1491
-            return 1;
1492
-        } else {
1493
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1494
-        }
1495
-    }
1486
+	/**
1487
+	 * @param integer $current_p
1488
+	 */
1489
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1490
+		if ( $current_p == 1 ) {
1491
+			return 1;
1492
+		} else {
1493
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1494
+		}
1495
+	}
1496 1496
 
1497 1497
 	/**
1498 1498
 	 * @return array
1499 1499
 	 */
1500 1500
 	public static function json_to_array( $json_vars ) {
1501
-        $vars = array();
1502
-        foreach ( $json_vars as $jv ) {
1501
+		$vars = array();
1502
+		foreach ( $json_vars as $jv ) {
1503 1503
 			$jv_name = explode( '[', $jv['name'] );
1504 1504
 			$last = count( $jv_name ) - 1;
1505 1505
 			foreach ( $jv_name as $p => $n ) {
@@ -1516,77 +1516,77 @@  discard block
 block discarded – undo
1516 1516
 					$l3 = $name;
1517 1517
 				}
1518 1518
 
1519
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1519
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1520 1520
 
1521
-                switch ( $p ) {
1522
-                    case 0:
1523
-                        $l1 = $name;
1524
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1521
+				switch ( $p ) {
1522
+					case 0:
1523
+						$l1 = $name;
1524
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1525 1525
 						break;
1526 1526
 
1527
-                    case 1:
1528
-                        $l2 = $name;
1529
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1527
+					case 1:
1528
+						$l2 = $name;
1529
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1530 1530
 						break;
1531 1531
 
1532
-                    case 2:
1533
-                        $l3 = $name;
1534
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1532
+					case 2:
1533
+						$l3 = $name;
1534
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1535 1535
 						break;
1536 1536
 
1537
-                    case 3:
1538
-                        $l4 = $name;
1539
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1540
-                }
1537
+					case 3:
1538
+						$l4 = $name;
1539
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1540
+				}
1541 1541
 
1542 1542
 				unset( $this_val, $n );
1543
-            }
1543
+			}
1544 1544
 
1545 1545
 			unset( $last, $jv );
1546
-        }
1547
-
1548
-        return $vars;
1549
-    }
1550
-
1551
-    /**
1552
-     * @param string $name
1553
-     * @param string $l1
1554
-     */
1555
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1556
-        if ( $name == '' ) {
1557
-            $vars[] = $val;
1558
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1559
-            $vars[ $l1 ] = $val;
1560
-        }
1561
-    }
1546
+		}
1547
+
1548
+		return $vars;
1549
+	}
1550
+
1551
+	/**
1552
+	 * @param string $name
1553
+	 * @param string $l1
1554
+	 */
1555
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1556
+		if ( $name == '' ) {
1557
+			$vars[] = $val;
1558
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1559
+			$vars[ $l1 ] = $val;
1560
+		}
1561
+	}
1562 1562
 
1563 1563
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1564
-        $tooltips = array(
1565
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1566
-            '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' ),
1567
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1568
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1569
-            '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' ),
1570
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1571
-            '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() ) ),
1572
-        );
1573
-
1574
-        if ( ! isset( $tooltips[ $name ] ) ) {
1575
-            return;
1576
-        }
1577
-
1578
-        if ( 'open' == $class ) {
1579
-            echo ' frm_help"';
1580
-        } else {
1581
-            echo ' class="frm_help"';
1582
-        }
1564
+		$tooltips = array(
1565
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1566
+			'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' ),
1567
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1568
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1569
+			'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' ),
1570
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1571
+			'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() ) ),
1572
+		);
1573
+
1574
+		if ( ! isset( $tooltips[ $name ] ) ) {
1575
+			return;
1576
+		}
1577
+
1578
+		if ( 'open' == $class ) {
1579
+			echo ' frm_help"';
1580
+		} else {
1581
+			echo ' class="frm_help"';
1582
+		}
1583 1583
 
1584 1584
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1585 1585
 
1586
-        if ( 'open' != $class ) {
1587
-            echo '"';
1588
-        }
1589
-    }
1586
+		if ( 'open' != $class ) {
1587
+			echo '"';
1588
+		}
1589
+	}
1590 1590
 
1591 1591
 	/**
1592 1592
 	 * Add the current_page class to that page in the form nav
@@ -1602,35 +1602,35 @@  discard block
 block discarded – undo
1602 1602
 		}
1603 1603
 	}
1604 1604
 
1605
-    /**
1606
-     * Prepare and json_encode post content
1607
-     *
1608
-     * @since 2.0
1609
-     *
1610
-     * @param array $post_content
1611
-     * @return string $post_content ( json encoded array )
1612
-     */
1613
-    public static function prepare_and_encode( $post_content ) {
1614
-        //Loop through array to strip slashes and add only the needed ones
1605
+	/**
1606
+	 * Prepare and json_encode post content
1607
+	 *
1608
+	 * @since 2.0
1609
+	 *
1610
+	 * @param array $post_content
1611
+	 * @return string $post_content ( json encoded array )
1612
+	 */
1613
+	public static function prepare_and_encode( $post_content ) {
1614
+		//Loop through array to strip slashes and add only the needed ones
1615 1615
 		foreach ( $post_content as $key => $val ) {
1616 1616
 			// Replace problematic characters (like &quot;)
1617 1617
 			$val = str_replace( '&quot;', '"', $val );
1618 1618
 
1619 1619
 			self::prepare_action_slashes( $val, $key, $post_content );
1620
-            unset( $key, $val );
1621
-        }
1620
+			unset( $key, $val );
1621
+		}
1622 1622
 
1623
-        // json_encode the array
1624
-        $post_content = json_encode( $post_content );
1623
+		// json_encode the array
1624
+		$post_content = json_encode( $post_content );
1625 1625
 
1626
-	    // add extra slashes for \r\n since WP strips them
1626
+		// add extra slashes for \r\n since WP strips them
1627 1627
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1628 1628
 
1629
-        // allow for &quot
1630
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1629
+		// allow for &quot
1630
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1631 1631
 
1632
-        return $post_content;
1633
-    }
1632
+		return $post_content;
1633
+	}
1634 1634
 
1635 1635
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1636 1636
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1653,55 +1653,55 @@  discard block
 block discarded – undo
1653 1653
 
1654 1654
 	public static function maybe_json_decode( $string ) {
1655 1655
 		if ( is_array( $string ) ) {
1656
-            return $string;
1657
-        }
1656
+			return $string;
1657
+		}
1658 1658
 
1659 1659
 		$new_string = json_decode( $string, true );
1660 1660
 		if ( function_exists( 'json_last_error' ) ) {
1661 1661
 			// php 5.3+
1662
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1663
-                $string = $new_string;
1664
-            }
1662
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1663
+				$string = $new_string;
1664
+			}
1665 1665
 		} elseif ( isset( $new_string ) ) {
1666 1666
 			// php < 5.3 fallback
1667
-            $string = $new_string;
1668
-        }
1669
-        return $string;
1670
-    }
1671
-
1672
-    /**
1673
-     * @since 1.07.10
1674
-     *
1675
-     * @param string $post_type The name of the post type that may need to be highlighted
1676
-     * echo The javascript to open and highlight the Formidable menu
1677
-     */
1667
+			$string = $new_string;
1668
+		}
1669
+		return $string;
1670
+	}
1671
+
1672
+	/**
1673
+	 * @since 1.07.10
1674
+	 *
1675
+	 * @param string $post_type The name of the post type that may need to be highlighted
1676
+	 * echo The javascript to open and highlight the Formidable menu
1677
+	 */
1678 1678
 	public static function maybe_highlight_menu( $post_type ) {
1679
-        global $post;
1679
+		global $post;
1680 1680
 
1681 1681
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1682
-            return;
1683
-        }
1682
+			return;
1683
+		}
1684 1684
 
1685 1685
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1686
-            return;
1687
-        }
1686
+			return;
1687
+		}
1688 1688
 
1689
-        self::load_admin_wide_js();
1690
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1691
-    }
1689
+		self::load_admin_wide_js();
1690
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1691
+	}
1692 1692
 
1693
-    /**
1694
-     * Load the JS file on non-Formidable pages in the admin area
1693
+	/**
1694
+	 * Load the JS file on non-Formidable pages in the admin area
1695 1695
 	 *
1696
-     * @since 2.0
1697
-     */
1696
+	 * @since 2.0
1697
+	 */
1698 1698
 	public static function load_admin_wide_js( $load = true ) {
1699 1699
 		$version = self::plugin_version();
1700 1700
 		wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1701 1701
 
1702 1702
 		$global_strings = array(
1703 1703
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1704
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1704
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1705 1705
 			'url'          => self::plugin_url(),
1706 1706
 			'loading'      => __( 'Loading&hellip;', 'formidable' ),
1707 1707
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 		if ( $load ) {
1712 1712
 			wp_enqueue_script( 'formidable_admin_global' );
1713 1713
 		}
1714
-    }
1714
+	}
1715 1715
 
1716 1716
 	/**
1717 1717
 	 * @since 2.0.9
@@ -1720,9 +1720,9 @@  discard block
 block discarded – undo
1720 1720
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1721 1721
 	}
1722 1722
 
1723
-    /**
1724
-     * @param string $location
1725
-     */
1723
+	/**
1724
+	 * @param string $location
1725
+	 */
1726 1726
 	public static function localize_script( $location ) {
1727 1727
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1728 1728
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1788,28 +1788,28 @@  discard block
 block discarded – undo
1788 1788
 		}
1789 1789
 	}
1790 1790
 
1791
-    /**
1791
+	/**
1792 1792
 	 * Echo the message on the plugins listing page
1793 1793
 	 *
1794
-     * @since 1.07.10
1795
-     *
1796
-     * @param float $min_version The version the add-on requires
1797
-     */
1794
+	 * @since 1.07.10
1795
+	 *
1796
+	 * @param float $min_version The version the add-on requires
1797
+	 */
1798 1798
 	public static function min_version_notice( $min_version ) {
1799
-        $frm_version = self::plugin_version();
1799
+		$frm_version = self::plugin_version();
1800 1800
 
1801
-        // check if Formidable meets minimum requirements
1801
+		// check if Formidable meets minimum requirements
1802 1802
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1803
-            return;
1804
-        }
1803
+			return;
1804
+		}
1805 1805
 
1806 1806
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1807 1807
 		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">' .
1808
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1809
-        '</div></td></tr>';
1810
-    }
1808
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1809
+		'</div></td></tr>';
1810
+	}
1811 1811
 
1812
-    public static function locales( $type = 'date' ) {
1812
+	public static function locales( $type = 'date' ) {
1813 1813
 		$locales = array(
1814 1814
 			'en' => __( 'English', 'formidable' ),
1815 1815
 			'af' => __( 'Afrikaans', 'formidable' ),
@@ -1887,8 +1887,8 @@  discard block
 block discarded – undo
1887 1887
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1888 1888
 		$locales = apply_filters( 'frm_locales', $locales );
1889 1889
 
1890
-        return $locales;
1891
-    }
1890
+		return $locales;
1891
+	}
1892 1892
 
1893 1893
 	/**
1894 1894
 	 * Used to filter shortcode in text widgets
Please login to merge, or discard this patch.
classes/models/FrmSettings.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,33 +1,33 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmSettings {
4
-    public $option_name = 'frm_options';
5
-    public $menu;
6
-    public $mu_menu;
7
-    public $use_html;
8
-    public $jquery_css;
9
-    public $accordion_js;
4
+	public $option_name = 'frm_options';
5
+	public $menu;
6
+	public $mu_menu;
7
+	public $use_html;
8
+	public $jquery_css;
9
+	public $accordion_js;
10 10
 	public $fade_form;
11 11
 	public $old_css;
12 12
 
13
-    public $success_msg;
14
-    public $blank_msg;
15
-    public $unique_msg;
16
-    public $invalid_msg;
17
-    public $failed_msg;
18
-    public $submit_value;
19
-    public $login_msg;
20
-    public $admin_permission;
21
-
22
-    public $email_to;
23
-    public $load_style;
24
-    public $custom_style;
25
-
26
-    public $pubkey;
27
-    public $privkey;
28
-    public $re_lang;
13
+	public $success_msg;
14
+	public $blank_msg;
15
+	public $unique_msg;
16
+	public $invalid_msg;
17
+	public $failed_msg;
18
+	public $submit_value;
19
+	public $login_msg;
20
+	public $admin_permission;
21
+
22
+	public $email_to;
23
+	public $load_style;
24
+	public $custom_style;
25
+
26
+	public $pubkey;
27
+	public $privkey;
28
+	public $re_lang;
29 29
 	public $re_type;
30
-    public $re_msg;
30
+	public $re_msg;
31 31
 	public $re_multi;
32 32
 
33 33
 	public $no_ips;
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
 			$settings = $this->translate_settings( $settings );
45 45
 		}
46 46
 
47
-        foreach ( $settings as $setting_name => $setting ) {
48
-            $this->{$setting_name} = $setting;
47
+		foreach ( $settings as $setting_name => $setting ) {
48
+			$this->{$setting_name} = $setting;
49 49
 			unset( $setting_name, $setting );
50
-        }
50
+		}
51 51
 
52
-        $this->set_default_options();
52
+		$this->set_default_options();
53 53
 
54 54
 		$this->maybe_filter_for_form( $args );
55
-    }
55
+	}
56 56
 
57 57
 	private function translate_settings( $settings ) {
58
-        if ( $settings ) { //workaround for W3 total cache conflict
58
+		if ( $settings ) { //workaround for W3 total cache conflict
59 59
 			return unserialize( serialize( $settings ) );
60
-        }
60
+		}
61 61
 
62 62
 		$settings = get_option( $this->option_name );
63 63
 		if ( is_object( $settings ) ) {
@@ -65,97 +65,97 @@  discard block
 block discarded – undo
65 65
 			return $settings;
66 66
 		}
67 67
 
68
-        // If unserializing didn't work
69
-        if ( $settings ) { //workaround for W3 total cache conflict
68
+		// If unserializing didn't work
69
+		if ( $settings ) { //workaround for W3 total cache conflict
70 70
 			$settings = unserialize( serialize( $settings ) );
71
-        } else {
72
-            $settings = $this;
73
-        }
71
+		} else {
72
+			$settings = $this;
73
+		}
74 74
 
75 75
 		update_option( $this->option_name, $settings );
76 76
 		set_transient( $this->option_name, $settings );
77 77
 
78
-        return $settings;
79
-    }
78
+		return $settings;
79
+	}
80 80
 
81
-    /**
82
-     * @return array
83
-     */
81
+	/**
82
+	 * @return array
83
+	 */
84 84
 	public function default_options() {
85
-        return array(
86
-            'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
87
-            'mu_menu'   => 0,
88
-            'use_html'  => true,
89
-            'jquery_css' => false,
90
-            'accordion_js' => false,
85
+		return array(
86
+			'menu'      => apply_filters( 'frm_default_menu', 'Formidable' ),
87
+			'mu_menu'   => 0,
88
+			'use_html'  => true,
89
+			'jquery_css' => false,
90
+			'accordion_js' => false,
91 91
 			'fade_form' => false,
92 92
 			'old_css'   => true,
93 93
 
94 94
 			're_multi'  => 0,
95 95
 
96
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
97
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
98
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
99
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
100
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
101
-            'submit_value' => __( 'Submit', 'formidable' ),
102
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
103
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
96
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
97
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
98
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
99
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
100
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
101
+			'submit_value' => __( 'Submit', 'formidable' ),
102
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
103
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
104 104
 
105
-            'email_to' => '[admin_email]',
105
+			'email_to' => '[admin_email]',
106 106
 			'no_ips'   => 0,
107
-        );
108
-    }
107
+		);
108
+	}
109 109
 
110 110
 	private function set_default_options() {
111
-        $this->fill_recaptcha_settings();
111
+		$this->fill_recaptcha_settings();
112 112
 
113 113
 		if ( ! isset( $this->load_style ) ) {
114 114
 			if ( ! isset( $this->custom_style ) ) {
115
-                $this->custom_style = true;
116
-            }
115
+				$this->custom_style = true;
116
+			}
117 117
 
118
-            $this->load_style = 'all';
119
-        }
118
+			$this->load_style = 'all';
119
+		}
120 120
 
121
-        $this->fill_with_defaults();
121
+		$this->fill_with_defaults();
122 122
 
123
-        if ( is_multisite() && is_admin() ) {
123
+		if ( is_multisite() && is_admin() ) {
124 124
 			$mu_menu = get_site_option( 'frm_admin_menu_name' );
125 125
 			if ( $mu_menu && ! empty( $mu_menu ) ) {
126
-                $this->menu = $mu_menu;
127
-                $this->mu_menu = 1;
128
-            }
129
-        }
126
+				$this->menu = $mu_menu;
127
+				$this->mu_menu = 1;
128
+			}
129
+		}
130 130
 
131 131
 		$frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
132 132
 		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
133 133
 			if ( ! isset( $this->$frm_role ) ) {
134
-                $this->$frm_role = 'administrator';
135
-            }
136
-        }
137
-    }
134
+				$this->$frm_role = 'administrator';
135
+			}
136
+		}
137
+	}
138 138
 
139 139
 	public function fill_with_defaults( $params = array() ) {
140
-        $settings = $this->default_options();
140
+		$settings = $this->default_options();
141 141
 
142
-        foreach ( $settings as $setting => $default ) {
142
+		foreach ( $settings as $setting => $default ) {
143 143
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
144 144
 				$this->{$setting} = $params[ 'frm_' . $setting ];
145 145
 			} elseif ( ! isset( $this->{$setting} ) ) {
146
-                $this->{$setting} = $default;
147
-            }
146
+				$this->{$setting} = $default;
147
+			}
148 148
 
149 149
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
150 150
 				$this->{$setting} = $default;
151 151
 			}
152 152
 
153 153
 			unset( $setting, $default );
154
-        }
155
-    }
154
+		}
155
+	}
156 156
 
157
-    private function fill_recaptcha_settings() {
158
-        $privkey = '';
157
+	private function fill_recaptcha_settings() {
158
+		$privkey = '';
159 159
 		$re_lang = '';
160 160
 
161 161
 		if ( ! isset( $this->pubkey ) ) {
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 		}
168 168
 
169 169
 		if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
170
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
171
-        }
170
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
171
+		}
172 172
 
173 173
 		if ( ! isset( $this->privkey ) ) {
174
-            $this->privkey = $privkey;
175
-        }
174
+			$this->privkey = $privkey;
175
+		}
176 176
 
177 177
 		if ( ! isset( $this->re_lang ) ) {
178
-            $this->re_lang = $re_lang;
179
-        }
178
+			$this->re_lang = $re_lang;
179
+		}
180 180
 
181 181
 		if ( ! isset( $this->re_type ) ) {
182 182
 			$this->re_type = '';
183 183
 		}
184
-    }
184
+	}
185 185
 
186 186
 	/**
187 187
 	 * Get values that may be shown on the front-end without an override in the form settings.
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 		}
212 212
 	}
213 213
 
214
-    public function validate( $params, $errors ) {
215
-        return apply_filters( 'frm_validate_settings', $errors, $params );
216
-    }
214
+	public function validate( $params, $errors ) {
215
+		return apply_filters( 'frm_validate_settings', $errors, $params );
216
+	}
217 217
 
218 218
 	public function update( $params ) {
219 219
 		$this->fill_with_defaults( $params );
@@ -227,25 +227,25 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$this->update_roles( $params );
229 229
 
230
-        do_action( 'frm_update_settings', $params );
230
+		do_action( 'frm_update_settings', $params );
231 231
 
232 232
 		if ( function_exists( 'get_filesystem_method' ) ) {
233 233
 			// save styling settings in case fallback setting changes
234 234
 			$frm_style = new FrmStyle();
235 235
 			$frm_style->update( 'default' );
236 236
 		}
237
-    }
237
+	}
238 238
 
239 239
 	private function update_settings( $params ) {
240 240
 		$this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
241 241
 
242 242
 		$this->pubkey = trim( $params['frm_pubkey'] );
243
-        $this->privkey = $params['frm_privkey'];
243
+		$this->privkey = $params['frm_privkey'];
244 244
 		$this->re_type = $params['frm_re_type'];
245
-        $this->re_lang = $params['frm_re_lang'];
245
+		$this->re_lang = $params['frm_re_lang'];
246 246
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
247 247
 
248
-        $this->load_style = $params['frm_load_style'];
248
+		$this->load_style = $params['frm_load_style'];
249 249
 
250 250
 		$this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
251 251
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
 		$this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0;
254 254
 		$this->old_css   = isset( $params['frm_old_css'] ) ? absint( $params['frm_old_css'] ) : 0;
255 255
 		$this->no_ips = isset( $params['frm_no_ips'] ) ? absint( $params['frm_no_ips'] ) : 0;
256
-    }
256
+	}
257 257
 
258 258
 	private function update_roles( $params ) {
259
-        global $wp_roles;
259
+		global $wp_roles;
260 260
 
261
-        $frm_roles = FrmAppHelper::frm_capabilities();
262
-        $roles = get_editable_roles();
263
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
264
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
261
+		$frm_roles = FrmAppHelper::frm_capabilities();
262
+		$roles = get_editable_roles();
263
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
264
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
265 265
 
266
-            // Make sure administrators always have permissions
267
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
266
+			// Make sure administrators always have permissions
267
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
268 268
 				array_push( $this->$frm_role, 'administrator' );
269
-            }
269
+			}
270 270
 
271
-            foreach ( $roles as $role => $details ) {
271
+			foreach ( $roles as $role => $details ) {
272 272
 				if ( in_array( $role, $this->$frm_role ) ) {
273
-    			    $wp_roles->add_cap( $role, $frm_role );
274
-    			} else {
275
-    			    $wp_roles->remove_cap( $role, $frm_role );
276
-    			}
277
-    		}
273
+					$wp_roles->add_cap( $role, $frm_role );
274
+				} else {
275
+					$wp_roles->remove_cap( $role, $frm_role );
276
+				}
277
+			}
278 278
 		}
279
-    }
279
+	}
280 280
 
281 281
 	public function store() {
282 282
 		// Save the posted value in the database
Please login to merge, or discard this patch.
classes/models/FrmForm.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-    die( 'You are not allowed to call this page directly.' );
3
+	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14 14
 		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
@@ -33,52 +33,52 @@  discard block
 block discarded – undo
33 33
 		$options = apply_filters( 'frm_form_options_before_update', $options, $values );
34 34
 		$new_values['options'] = serialize( $options );
35 35
 
36
-        //if(isset($values['id']) && is_numeric($values['id']))
37
-        //    $new_values['id'] = $values['id'];
36
+		//if(isset($values['id']) && is_numeric($values['id']))
37
+		//    $new_values['id'] = $values['id'];
38 38
 
39 39
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
40 40
 
41
-        $id = $wpdb->insert_id;
41
+		$id = $wpdb->insert_id;
42 42
 
43 43
 		// Clear form caching
44 44
 		self::clear_form_cache();
45 45
 
46
-        return $id;
47
-    }
46
+		return $id;
47
+	}
48 48
 
49
-    /**
50
-     * @return int|boolean ID on success or false on failure
51
-     */
52
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
53
-        global $wpdb;
49
+	/**
50
+	 * @return int|boolean ID on success or false on failure
51
+	 */
52
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
53
+		global $wpdb;
54 54
 
55
-        $values = self::getOne( $id, $blog_id );
56
-        if ( ! $values ) {
57
-            return false;
58
-        }
55
+		$values = self::getOne( $id, $blog_id );
56
+		if ( ! $values ) {
57
+			return false;
58
+		}
59 59
 
60
-        $new_key = $copy_keys ? $values->form_key : '';
60
+		$new_key = $copy_keys ? $values->form_key : '';
61 61
 
62
-        $new_values = array(
62
+		$new_values = array(
63 63
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
64
-            'name'          => $values->name,
65
-            'description'   => $values->description,
66
-            'status'        => $template ? 'published' : 'draft',
67
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
68
-            'editable'      => $values->editable ? $values->editable : 0,
64
+			'name'          => $values->name,
65
+			'description'   => $values->description,
66
+			'status'        => $template ? 'published' : 'draft',
67
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
68
+			'editable'      => $values->editable ? $values->editable : 0,
69 69
 			'created_at'    => current_time( 'mysql', 1 ),
70
-            'is_template'   => $template ? 1 : 0,
71
-        );
70
+			'is_template'   => $template ? 1 : 0,
71
+		);
72 72
 
73
-        if ( $blog_id ) {
74
-            $new_values['status'] = 'published';
73
+		if ( $blog_id ) {
74
+			$new_values['status'] = 'published';
75 75
 			$new_options = maybe_unserialize( $values->options );
76 76
 			$new_options['email_to'] = get_option( 'admin_email' );
77
-            $new_options['copy'] = false;
78
-            $new_values['options'] = $new_options;
79
-        } else {
80
-            $new_values['options'] = $values->options;
81
-        }
77
+			$new_options['copy'] = false;
78
+			$new_values['options'] = $new_options;
79
+		} else {
80
+			$new_values['options'] = $values->options;
81
+		}
82 82
 
83 83
 		if ( is_array( $new_values['options'] ) ) {
84 84
 			$new_values['options'] = serialize( $new_values['options'] );
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
 
87 87
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
88 88
 
89
-        if ( $query_results ) {
89
+		if ( $query_results ) {
90 90
 			// Clear form caching
91 91
 			self::clear_form_cache();
92 92
 
93
-            $form_id = $wpdb->insert_id;
93
+			$form_id = $wpdb->insert_id;
94 94
 			FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
95 95
 
96
-            // update form settings after fields are created
96
+			// update form settings after fields are created
97 97
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
98
-            return $form_id;
99
-        }
98
+			return $form_id;
99
+		}
100 100
 
101
-        return false;
102
-    }
101
+		return false;
102
+	}
103 103
 
104 104
 	public static function after_duplicate( $form_id, $values ) {
105 105
 		$new_opts = maybe_unserialize( $values['options'] );
@@ -111,48 +111,48 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130 130
 		if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134 134
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136 136
 		$new_values = self::set_update_options( array(), $values );
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
138
+		foreach ( $values as $value_key => $value ) {
139 139
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156 156
 		unset( $new_values );
157 157
 
158 158
 		$values = self::update_fields( $id, $values );
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170 170
 		if ( ! isset( $values['options'] ) ) {
171
-            return $new_values;
172
-        }
171
+			return $new_values;
172
+		}
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 		$new_values['options'] = serialize( $options );
184 184
 
185 185
 		return $new_values;
186
-    }
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194 194
 		if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195
-            return $values;
196
-        }
195
+			return $values;
196
+		}
197 197
 
198 198
 		$all_fields = FrmField::get_all_for_form( $id );
199 199
 		if ( empty( $all_fields ) ) {
@@ -204,26 +204,26 @@  discard block
 block discarded – undo
204 204
 			$values['item_meta'] = array();
205 205
 		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys( $values['item_meta'] );
209
-        foreach ( $all_fields as $fid ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys( $values['item_meta'] );
209
+		foreach ( $all_fields as $fid ) {
210 210
 			if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
214
+		}
215 215
 		unset( $all_fields );
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
220
+			} else {
221 221
 				$field = FrmField::getOne( $field_id );
222
-            }
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229 229
 			if ( $is_settings_page ) {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 			foreach ( $update_options as $opt => $default ) {
243 243
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? $values['field_options'][ $opt . '_' . $field_id ] : $default;
244 244
 				self::sanitize_field_opt( $opt, $field->field_options[ $opt ] );
245
-            }
245
+			}
246 246
 
247 247
 			$field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
248 248
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 			FrmField::update( $field_id, $new_field );
258 258
 
259 259
 			FrmField::delete_form_transient( $field->form_id );
260
-        }
260
+		}
261 261
 		self::clear_form_cache();
262 262
 
263
-        return $values;
264
-    }
263
+		return $values;
264
+	}
265 265
 
266 266
 	private static function sanitize_field_opt( $opt, &$value ) {
267 267
 		if ( is_string( $value ) ) {
@@ -328,21 +328,21 @@  discard block
 block discarded – undo
328 328
 		return apply_filters( 'frm_form_strings', $strings, $form );
329 329
 	}
330 330
 
331
-    /**
332
-     * @param string $status
333
-     * @return int|boolean
334
-     */
331
+	/**
332
+	 * @param string $status
333
+	 * @return int|boolean
334
+	 */
335 335
 	public static function set_status( $id, $status ) {
336
-        if ( 'trash' == $status ) {
336
+		if ( 'trash' == $status ) {
337 337
 			return self::trash( $id );
338
-        }
338
+		}
339 339
 
340 340
 		$statuses  = array( 'published', 'draft', 'trash' );
341
-        if ( ! in_array( $status, $statuses ) ) {
342
-            return false;
343
-        }
341
+		if ( ! in_array( $status, $statuses ) ) {
342
+			return false;
343
+		}
344 344
 
345
-        global $wpdb;
345
+		global $wpdb;
346 346
 
347 347
 		if ( is_array( $id ) ) {
348 348
 			$where = array(
@@ -354,33 +354,33 @@  discard block
 block discarded – undo
354 354
 			array_unshift( $where['values'], $status );
355 355
 
356 356
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // WPCS: unprepared SQL ok.
357
-        } else {
357
+		} else {
358 358
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
359 359
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
360
-        }
360
+		}
361 361
 
362
-        if ( $query_results ) {
362
+		if ( $query_results ) {
363 363
 			self::clear_form_cache();
364
-        }
364
+		}
365 365
 
366
-        return $query_results;
367
-    }
366
+		return $query_results;
367
+	}
368 368
 
369
-    /**
370
-     * @return int|boolean
371
-     */
369
+	/**
370
+	 * @return int|boolean
371
+	 */
372 372
 	public static function trash( $id ) {
373
-        if ( ! EMPTY_TRASH_DAYS ) {
374
-            return self::destroy( $id );
375
-        }
373
+		if ( ! EMPTY_TRASH_DAYS ) {
374
+			return self::destroy( $id );
375
+		}
376 376
 
377 377
 		$form = self::getOne( $id );
378
-        if ( ! $form ) {
379
-            return false;
380
-        }
378
+		if ( ! $form ) {
379
+			return false;
380
+		}
381 381
 
382
-        $options = $form->options;
383
-        $options['trash_time'] = time();
382
+		$options = $form->options;
383
+		$options['trash_time'] = time();
384 384
 
385 385
 		global $wpdb;
386 386
 		$query_results = $wpdb->update(
@@ -405,39 +405,39 @@  discard block
 block discarded – undo
405 405
 			)
406 406
 		);
407 407
 
408
-        if ( $query_results ) {
408
+		if ( $query_results ) {
409 409
 			self::clear_form_cache();
410
-        }
410
+		}
411 411
 
412
-        return $query_results;
413
-    }
412
+		return $query_results;
413
+	}
414 414
 
415
-    /**
416
-     * @return int|boolean
417
-     */
415
+	/**
416
+	 * @return int|boolean
417
+	 */
418 418
 	public static function destroy( $id ) {
419
-        global $wpdb;
419
+		global $wpdb;
420 420
 
421 421
 		$form = self::getOne( $id );
422
-        if ( ! $form ) {
423
-            return false;
424
-        }
422
+		if ( ! $form ) {
423
+			return false;
424
+		}
425 425
 		$id = $form->id;
426 426
 
427
-        // Disconnect the entries from this form
427
+		// Disconnect the entries from this form
428 428
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
429 429
 		foreach ( $entries as $entry_id ) {
430 430
 			FrmEntry::destroy( $entry_id );
431 431
 			unset( $entry_id );
432 432
 		}
433 433
 
434
-        // Disconnect the fields from this form
434
+		// Disconnect the fields from this form
435 435
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
436 436
 
437 437
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
438
-        if ( $query_results ) {
439
-            // Delete all form actions linked to this form
440
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
438
+		if ( $query_results ) {
439
+			// Delete all form actions linked to this form
440
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
441 441
 			$action_control->destroy( $id, 'all' );
442 442
 
443 443
 			// Clear form caching
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 
446 446
 			do_action( 'frm_destroy_form', $id );
447 447
 			do_action( 'frm_destroy_form_' . $id );
448
-        }
448
+		}
449 449
 
450
-        return $query_results;
451
-    }
450
+		return $query_results;
451
+	}
452 452
 
453 453
 	/**
454 454
 	 * Delete trashed forms based on how long they have been trashed
@@ -481,48 +481,48 @@  discard block
 block discarded – undo
481 481
 		return $count;
482 482
 	}
483 483
 
484
-    /**
485
-     * @return string form name
486
-     */
487
-    public static function getName( $id ) {
484
+	/**
485
+	 * @return string form name
486
+	 */
487
+	public static function getName( $id ) {
488 488
 		$form = FrmDb::check_cache( $id, 'frm_form' );
489
-        if ( $form ) {
489
+		if ( $form ) {
490 490
 			$r = stripslashes( $form->name );
491
-            return $r;
492
-        }
491
+			return $r;
492
+		}
493 493
 
494
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
495
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
494
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
495
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
496 496
 		$r = stripslashes( $r );
497 497
 
498
-        return $r;
499
-    }
498
+		return $r;
499
+	}
500 500
 
501
-    /**
501
+	/**
502 502
 	 * @since 3.0
503
-     * @param string $key
504
-     * @return int form id
505
-     */
503
+	 * @param string $key
504
+	 * @return int form id
505
+	 */
506 506
 	public static function get_id_by_key( $key ) {
507 507
 		return (int) FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
508
-    }
508
+	}
509 509
 
510
-    /**
510
+	/**
511 511
 	 * @since 3.0
512
-     * @param int $id
513
-     * @return string form key
514
-     */
512
+	 * @param int $id
513
+	 * @return string form key
514
+	 */
515 515
 	public static function get_key_by_id( $id ) {
516
-        $id = (int) $id;
516
+		$id = (int) $id;
517 517
 		$cache = FrmDb::check_cache( $id, 'frm_form' );
518
-        if ( $cache ) {
519
-            return $cache->form_key;
520
-        }
518
+		if ( $cache ) {
519
+			return $cache->form_key;
520
+		}
521 521
 
522
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
522
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
523 523
 
524
-        return $key;
525
-    }
524
+		return $key;
525
+	}
526 526
 
527 527
 	/**
528 528
 	 * If $form is numeric, get the form object
@@ -536,47 +536,47 @@  discard block
 block discarded – undo
536 536
 		}
537 537
 	}
538 538
 
539
-    /**
540
-     * @return object form
541
-     */
542
-    public static function getOne( $id, $blog_id = false ) {
543
-        global $wpdb;
539
+	/**
540
+	 * @return object form
541
+	 */
542
+	public static function getOne( $id, $blog_id = false ) {
543
+		global $wpdb;
544 544
 
545
-        if ( $blog_id && is_multisite() ) {
546
-            global $wpmuBaseTablePrefix;
545
+		if ( $blog_id && is_multisite() ) {
546
+			global $wpmuBaseTablePrefix;
547 547
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
548 548
 
549 549
 			$table_name = $prefix . 'frm_forms';
550
-        } else {
550
+		} else {
551 551
 			$table_name = $wpdb->prefix . 'frm_forms';
552 552
 			$cache = wp_cache_get( $id, 'frm_form' );
553
-            if ( $cache ) {
553
+			if ( $cache ) {
554 554
 				if ( isset( $cache->options ) ) {
555 555
 					$cache->options = maybe_unserialize( $cache->options );
556
-                }
556
+				}
557 557
 
558 558
 				return stripslashes_deep( $cache );
559
-            }
560
-        }
559
+			}
560
+		}
561 561
 
562 562
 		if ( is_numeric( $id ) ) {
563
-            $where = array( 'id' => $id );
564
-        } else {
565
-            $where = array( 'form_key' => $id );
566
-        }
563
+			$where = array( 'id' => $id );
564
+		} else {
565
+			$where = array( 'form_key' => $id );
566
+		}
567 567
 
568
-        $results = FrmDb::get_row( $table_name, $where );
568
+		$results = FrmDb::get_row( $table_name, $where );
569 569
 
570 570
 		if ( isset( $results->options ) ) {
571 571
 			FrmDb::set_cache( $results->id, $results, 'frm_form' );
572 572
 			$results->options = maybe_unserialize( $results->options );
573
-        }
573
+		}
574 574
 		return stripslashes_deep( $results );
575
-    }
575
+	}
576 576
 
577
-    /**
578
-     * @return object|array of objects
579
-     */
577
+	/**
578
+	 * @return object|array of objects
579
+	 */
580 580
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
581 581
 		if ( is_array( $where ) && ! empty( $where ) ) {
582 582
 			if ( isset( $where['is_template'] ) && $where['is_template'] && ! isset( $where['status'] ) ) {
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 		}
607 607
 
608 608
 		return stripslashes_deep( $results );
609
-    }
609
+	}
610 610
 
611 611
 	/**
612 612
 	 * Get all published forms
@@ -625,18 +625,18 @@  discard block
 block discarded – undo
625 625
 		return $forms;
626 626
 	}
627 627
 
628
-    /**
629
-     * @return int count of forms
630
-     */
631
-    public static function get_count() {
632
-    	global $wpdb;
628
+	/**
629
+	 * @return int count of forms
630
+	 */
631
+	public static function get_count() {
632
+		global $wpdb;
633 633
 
634
-    	$cache_key = 'frm_form_counts';
634
+		$cache_key = 'frm_form_counts';
635 635
 
636
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
637
-    	if ( false !== $counts ) {
638
-    	    return $counts;
639
-    	}
636
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
637
+		if ( false !== $counts ) {
638
+			return $counts;
639
+		}
640 640
 
641 641
 		$results = (array) FrmDb::get_results(
642 642
 			'frm_forms',
@@ -649,31 +649,31 @@  discard block
 block discarded – undo
649 649
 		);
650 650
 
651 651
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
652
-    	$counts = array_fill_keys( $statuses, 0 );
652
+		$counts = array_fill_keys( $statuses, 0 );
653 653
 
654
-    	foreach ( $results as $row ) {
655
-            if ( 'trash' != $row->status ) {
656
-    	        if ( $row->is_template ) {
654
+		foreach ( $results as $row ) {
655
+			if ( 'trash' != $row->status ) {
656
+				if ( $row->is_template ) {
657 657
 					$counts['template']++;
658
-    	        } else {
658
+				} else {
659 659
 					$counts['published']++;
660
-    	        }
661
-    	    } else {
660
+				}
661
+			} else {
662 662
 				$counts['trash']++;
663
-        	}
663
+			}
664 664
 
665
-    	    if ( 'draft' == $row->status ) {
665
+			if ( 'draft' == $row->status ) {
666 666
 				$counts['draft']++;
667
-    	    }
667
+			}
668 668
 
669 669
 			unset( $row );
670
-    	}
670
+		}
671 671
 
672
-    	$counts = (object) $counts;
672
+		$counts = (object) $counts;
673 673
 		FrmDb::set_cache( $cache_key, $counts, 'frm_form' );
674 674
 
675
-    	return $counts;
676
-    }
675
+		return $counts;
676
+	}
677 677
 
678 678
 	/**
679 679
 	 * Clear form caching
@@ -686,14 +686,14 @@  discard block
 block discarded – undo
686 686
 		FrmDb::cache_delete_group( 'frm_form' );
687 687
 	}
688 688
 
689
-    /**
690
-     * @return array of errors
691
-     */
689
+	/**
690
+	 * @return array of errors
691
+	 */
692 692
 	public static function validate( $values ) {
693
-        $errors = array();
693
+		$errors = array();
694 694
 
695 695
 		return apply_filters( 'frm_validate_form', $errors, $values );
696
-    }
696
+	}
697 697
 
698 698
 	public static function get_params( $form = null ) {
699 699
 		global $frm_vars;
Please login to merge, or discard this patch.