Completed
Push — master ( ba1cd7...836330 )
by Jamie
02:56
created
classes/models/FrmEntryFormat.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -151,6 +151,7 @@
 block discarded – undo
151 151
 
152 152
 	/**
153 153
 	 * @deprecated 2.03.11
154
+	 * @param string $val
154 155
 	 */
155 156
 	private static function get_field_value( $atts, &$val ) {
156 157
 		_deprecated_function( __FUNCTION__, '2.03.11', 'instance of FrmEntryValues or FrmProEntryValues' );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		self::prepare_field_output( $atts, $val );
99 99
 
100 100
 		if ( $atts['format'] != 'text' ) {
101
-			$values[ $f->field_key ] = $val;
101
+			$values[$f->field_key] = $val;
102 102
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
103
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
103
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
104 104
 				if ( $prev_val != $val ) {
105
-					$values[ $f->field_key . '-value' ] = $prev_val;
105
+					$values[$f->field_key . '-value'] = $prev_val;
106 106
 				}
107 107
 			}
108 108
 		} else {
109
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
109
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
110 110
 		}
111 111
 	}
112 112
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	private static function fill_missing_fields( $atts, &$values ) {
117 117
 		_deprecated_function( __FUNCTION__, '2.03.11', 'instance of FrmEntryValues or FrmProEntryValues' );
118 118
 
119
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
119
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
120 120
 			// In case include_blank is set
121
-			$atts['entry']->metas[ $atts['field']->id ] = '';
121
+			$atts['entry']->metas[$atts['field']->id] = '';
122 122
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
123 123
 			self::fill_values_from_entry( $atts, $values );
124 124
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			'type'  => $f->type,
147 147
 		);
148 148
 
149
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
149
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
150 150
 	}
151 151
 
152 152
 	/**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		$f = $atts['field'];
159 159
 		if ( $atts['entry'] ) {
160
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
160
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
161 161
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
162 162
 
163 163
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
Please login to merge, or discard this patch.
classes/models/FrmEntryFormatter.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @since 2.03.11
332 332
 	 *
333
-	 * @param array $field_values
333
+	 * @param FrmFieldValue[] $field_values
334 334
 	 * @param array $output
335 335
 	 */
336 336
 	protected function push_field_values_to_array( $field_values, &$output ) {
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 * @param mixed $display_value
549 549
 	 * @param string $field_type
550 550
 	 *
551
-	 * @return mixed|string
551
+	 * @return string
552 552
 	 */
553 553
 	protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
554 554
 		$display_value = $this->flatten_array( $display_value );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		if ( is_object( $atts['entry'] ) ) {
110 110
 
111 111
 			if ( isset( $atts['entry']->metas ) ) {
112
-				$this->entry = $atts[ 'entry' ];
112
+				$this->entry = $atts['entry'];
113 113
 			} else {
114 114
 				$this->entry = FrmEntry::getOne( $atts['entry']->id, true );
115 115
 			}
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 		if ( $this->include_field_in_content( $field_value ) ) {
352 352
 
353 353
 			$displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
354
-			$output[ $field_value->get_field_key() ] = $displayed_value;
354
+			$output[$field_value->get_field_key()] = $displayed_value;
355 355
 
356 356
 			if ( $displayed_value !== $field_value->get_saved_value() ) {
357
-				$output[ $field_value->get_field_key() . '-value' ] = $field_value->get_saved_value();
357
+				$output[$field_value->get_field_key() . '-value'] = $field_value->get_saved_value();
358 358
 			}
359 359
 		}
360 360
 	}
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
 			if ( is_array( $value ) ) {
607 607
 				foreach ( $value as $key => $single_value ) {
608
-					$value[ $key ] = $this->strip_html( $single_value );
608
+					$value[$key] = $this->strip_html( $single_value );
609 609
 				}
610 610
 			} else if ( $this->is_plain_text && ! is_array( $value ) ) {
611 611
 				if ( strpos( $value, '<img' ) !== false ) {
Please login to merge, or discard this patch.
classes/models/FrmTableHTMLGenerator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		) );
84 84
 
85 85
 		foreach ( $this->style_settings as $key => $setting ) {
86
-			if ( isset( $atts[ $key ] ) && $atts[ $key ] !== '' ) {
87
-				$this->style_settings[ $key ] = str_replace( '#', '', $atts[ $key ] );
86
+			if ( isset( $atts[$key] ) && $atts[$key] !== '' ) {
87
+				$this->style_settings[$key] = str_replace( '#', '', $atts[$key] );
88 88
 			}
89 89
 		}
90 90
 	}
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	private function init_table_style() {
124 124
 		if ( $this->use_inline_style === true ) {
125 125
 
126
-			$this->table_style = ' style="' . esc_attr( 'font-size:' . $this->style_settings[ 'font_size' ] . ';line-height:135%;' );
127
-			$this->table_style .= esc_attr( 'border-bottom:' . $this->style_settings[ 'border_width' ] . ' solid #' . $this->style_settings[ 'border_color' ] . ';' ) . '"';
126
+			$this->table_style = ' style="' . esc_attr( 'font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' );
127
+			$this->table_style .= esc_attr( 'border-bottom:' . $this->style_settings['border_width'] . ' solid #' . $this->style_settings['border_color'] . ';' ) . '"';
128 128
 
129 129
 		}
130 130
 	}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 		if ( $this->use_inline_style === true ) {
139 139
 
140 140
 			$td_style_attributes = 'text-align:' . ( $this->direction == 'rtl' ? 'right' : 'left' ) . ';';
141
-			$td_style_attributes .= 'color:#' . $this->style_settings[ 'text_color' ] . ';padding:7px 9px;vertical-align:top;';
142
-			$td_style_attributes .= 'border-top:' . $this->style_settings[ 'border_width' ] . ' solid #' . $this->style_settings[ 'border_color' ] . ';';
141
+			$td_style_attributes .= 'color:#' . $this->style_settings['text_color'] . ';padding:7px 9px;vertical-align:top;';
142
+			$td_style_attributes .= 'border-top:' . $this->style_settings['border_width'] . ' solid #' . $this->style_settings['border_color'] . ';';
143 143
 
144 144
 			$this->td_style = ' style="' . $td_style_attributes . '"';
145 145
 		}
Please login to merge, or discard this patch.
classes/models/FrmEntryValues.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	 * @return array
156 156
 	 */
157 157
 	private function prepare_array_property( $index, $atts ) {
158
-		if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) {
158
+		if ( isset( $atts[$index] ) && ! empty( $atts[$index] ) ) {
159 159
 
160
-			if ( is_array( $atts[ $index ] ) ) {
161
-				$property = $atts[ $index ];
160
+			if ( is_array( $atts[$index] ) ) {
161
+				$property = $atts[$index];
162 162
 			} else {
163
-				$property = explode( ',', $atts[ $index ] );
163
+				$property = explode( ',', $atts[$index] );
164 164
 			}
165 165
 
166 166
 		} else {
@@ -294,6 +294,6 @@  discard block
 block discarded – undo
294 294
 	 * @param stdClass $field
295 295
 	 */
296 296
 	protected function add_field_values( $field ) {
297
-		$this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) );
297
+		$this->field_values[$field->id] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) );
298 298
 	}
299 299
 }
300 300
\ No newline at end of file
Please login to merge, or discard this patch.
classes/models/FrmEntryShortcodeFormatter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@
 block discarded – undo
219 219
 			'type'  => $field->type,
220 220
 		);
221 221
 
222
-		$this->array_content[ $field->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
222
+		$this->array_content[$field->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $array, $field );
223 223
 
224 224
 		return $array;
225 225
 	}
Please login to merge, or discard this patch.
classes/models/FrmFieldValue.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @since 2.03.11
81 81
 	 */
82 82
 	protected function init_saved_value() {
83
-		if ( isset( $this->entry->metas[ $this->field->id ] ) ) {
84
-			$this->saved_value = $this->entry->metas[ $this->field->id ];
83
+		if ( isset( $this->entry->metas[$this->field->id] ) ) {
84
+			$this->saved_value = $this->entry->metas[$this->field->id];
85 85
 		} else {
86 86
 			$this->saved_value = '';
87 87
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if ( $this->source === 'entry_formatter' ) {
156 156
 			// Deprecated frm_email_value hook
157
-			$meta                  = array(
157
+			$meta = array(
158 158
 				'item_id'    => $this->entry->id,
159 159
 				'field_id'   => $this->field->id,
160 160
 				'meta_value' => $this->saved_value,
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +575 added lines, -575 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,35 +24,35 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
64
-            $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
63
+			$values = FrmFormsHelper::setup_new_vars($values);
64
+			$id = FrmForm::create( $values );
65
+			$form = FrmForm::getOne($id);
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
69 69
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
70 70
 
71
-            $values['id'] = $id;
71
+			$values['id'] = $id;
72 72
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
73
-        }
74
-    }
73
+		}
74
+	}
75 75
 
76 76
 	/**
77 77
 	 * Create the default email action
@@ -80,87 +80,87 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param object $form
82 82
 	 */
83
-    private static function create_default_email_action( $form ) {
84
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
83
+	private static function create_default_email_action( $form ) {
84
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
85 85
 
86
-	    if ( $create_email ) {
87
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
88
-		    $action_control->create( $form->id );
89
-	    }
90
-    }
86
+		if ( $create_email ) {
87
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
88
+			$action_control->create( $form->id );
89
+		}
90
+	}
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+		FrmAppHelper::permission_check('frm_edit_forms');
94 94
 
95
-        global $frm_vars;
96
-        if ( empty( $values ) ) {
97
-            $values = $_POST;
98
-        }
95
+		global $frm_vars;
96
+		if ( empty( $values ) ) {
97
+			$values = $_POST;
98
+		}
99 99
 
100
-        //Set radio button and checkbox meta equal to "other" value
101
-        if ( FrmAppHelper::pro_is_installed() ) {
102
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
103
-        }
100
+		//Set radio button and checkbox meta equal to "other" value
101
+		if ( FrmAppHelper::pro_is_installed() ) {
102
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
103
+		}
104 104
 
105 105
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
-            $frm_settings = FrmAppHelper::get_settings();
109
-            $errors = array( 'form' => $frm_settings->admin_permission );
110
-        } else {
111
-            $errors = FrmForm::validate($values);
112
-        }
107
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
+			$frm_settings = FrmAppHelper::get_settings();
109
+			$errors = array( 'form' => $frm_settings->admin_permission );
110
+		} else {
111
+			$errors = FrmForm::validate($values);
112
+		}
113 113
 
114
-        if ( count($errors) > 0 ) {
115
-            $hide_preview = true;
114
+		if ( count($errors) > 0 ) {
115
+			$hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117
-            $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
117
+			$form = FrmForm::getOne( $id );
118
+			$fields = FrmField::get_all_for_form($id);
119 119
 
120
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
120
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
121 121
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
122 122
 
123 123
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
124
-        } else {
125
-            FrmForm::update( $id, $values, true );
124
+		} else {
125
+			FrmForm::update( $id, $values, true );
126 126
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
127 127
 			die( FrmAppHelper::js_redirect( $url ) );
128
-        }
129
-    }
128
+		}
129
+	}
130 130
 
131
-    public static function edit( $values = false ) {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function edit( $values = false ) {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
-        return self::get_edit_vars($id);
136
-    }
135
+		return self::get_edit_vars($id);
136
+	}
137 137
 
138
-    public static function settings( $id = false, $message = '' ) {
139
-        FrmAppHelper::permission_check('frm_edit_forms');
138
+	public static function settings( $id = false, $message = '' ) {
139
+		FrmAppHelper::permission_check('frm_edit_forms');
140 140
 
141
-        if ( ! $id || ! is_numeric($id) ) {
141
+		if ( ! $id || ! is_numeric($id) ) {
142 142
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-        }
143
+		}
144 144
 		return self::get_settings_vars( $id, array(), $message );
145
-    }
145
+	}
146 146
 
147
-    public static function update_settings() {
148
-        FrmAppHelper::permission_check('frm_edit_forms');
147
+	public static function update_settings() {
148
+		FrmAppHelper::permission_check('frm_edit_forms');
149 149
 
150 150
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
151 151
 
152
-        $errors = FrmForm::validate($_POST);
153
-        if ( count($errors) > 0 ) {
154
-            return self::get_settings_vars($id, $errors);
155
-        }
152
+		$errors = FrmForm::validate($_POST);
153
+		if ( count($errors) > 0 ) {
154
+			return self::get_settings_vars($id, $errors);
155
+		}
156 156
 
157
-        do_action('frm_before_update_form_settings', $id);
157
+		do_action('frm_before_update_form_settings', $id);
158 158
 
159 159
 		FrmForm::update( $id, $_POST );
160 160
 
161
-        $message = __( 'Settings Successfully Updated', 'formidable' );
161
+		$message = __( 'Settings Successfully Updated', 'formidable' );
162 162
 		return self::get_settings_vars( $id, array(), $message );
163
-    }
163
+	}
164 164
 
165 165
 	public static function edit_key() {
166 166
 		$values = self::edit_in_place_value( 'form_key' );
@@ -190,43 +190,43 @@  discard block
 block discarded – undo
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( $message );
216
-            }
216
+			}
217 217
 			return self::get_edit_vars( $id, array(), $message );
218
-        }
219
-    }
218
+		}
219
+	}
220 220
 
221
-    public static function bulk_create_template( $ids ) {
222
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
221
+	public static function bulk_create_template( $ids ) {
222
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 
224
-        foreach ( $ids as $id ) {
225
-            FrmForm::duplicate( $id, true, true );
226
-        }
224
+		foreach ( $ids as $id ) {
225
+			FrmForm::duplicate( $id, true, true );
226
+		}
227 227
 
228
-        return __( 'Form template was Successfully Created', 'formidable' );
229
-    }
228
+		return __( 'Form template was Successfully Created', 'formidable' );
229
+	}
230 230
 
231 231
 	/**
232 232
 	 * Redirect to the url for creating from a template
@@ -248,45 +248,45 @@  discard block
 block discarded – undo
248 248
 		wp_die();
249 249
 	}
250 250
 
251
-    public static function duplicate() {
252
-        FrmAppHelper::permission_check('frm_edit_forms');
251
+	public static function duplicate() {
252
+		FrmAppHelper::permission_check('frm_edit_forms');
253 253
 
254 254
 		$params = FrmForm::list_page_params();
255
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
-        if ( $form ) {
255
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
+		if ( $form ) {
258 258
 			return self::get_edit_vars( $form, array(), $message, true );
259
-        } else {
260
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
-        }
262
-    }
259
+		} else {
260
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
+		}
262
+	}
263 263
 
264
-    public static function page_preview() {
264
+	public static function page_preview() {
265 265
 		$params = FrmForm::list_page_params();
266
-        if ( ! $params['form'] ) {
267
-            return;
268
-        }
269
-
270
-        $form = FrmForm::getOne( $params['form'] );
271
-        if ( ! $form ) {
272
-            return;
273
-        }
274
-        return self::show_form( $form->id, '', true, true );
275
-    }
276
-
277
-    public static function preview() {
278
-        do_action( 'frm_wp' );
279
-
280
-        global $frm_vars;
281
-        $frm_vars['preview'] = true;
282
-
283
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
-            global $wp;
285
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
266
+		if ( ! $params['form'] ) {
267
+			return;
268
+		}
269
+
270
+		$form = FrmForm::getOne( $params['form'] );
271
+		if ( ! $form ) {
272
+			return;
273
+		}
274
+		return self::show_form( $form->id, '', true, true );
275
+	}
276
+
277
+	public static function preview() {
278
+		do_action( 'frm_wp' );
279
+
280
+		global $frm_vars;
281
+		$frm_vars['preview'] = true;
282
+
283
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
+			global $wp;
285
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
286 286
 			include_once( $root . '/wp-config.php' );
287
-            $wp->init();
288
-            $wp->register_globals();
289
-        }
287
+			$wp->init();
288
+			$wp->register_globals();
289
+		}
290 290
 
291 291
 		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
292 292
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
299 299
 		if ( empty( $form ) ) {
300 300
 			$form = FrmForm::getAll( array(), '', 1 );
301
-        }
301
+		}
302 302
 
303 303
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
304
-        wp_die();
305
-    }
304
+		wp_die();
305
+	}
306 306
 
307 307
 	public static function register_pro_scripts() {
308 308
 		_deprecated_function( __FUNCTION__, '2.03', 'FrmProEntriesController::register_scripts' );
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 	}
313 313
 
314
-    public static function untrash() {
314
+	public static function untrash() {
315 315
 		self::change_form_status( 'untrash' );
316
-    }
316
+	}
317 317
 
318 318
 	public static function bulk_untrash( $ids ) {
319
-        FrmAppHelper::permission_check('frm_edit_forms');
319
+		FrmAppHelper::permission_check('frm_edit_forms');
320 320
 
321
-        $count = FrmForm::set_status( $ids, 'published' );
321
+		$count = FrmForm::set_status( $ids, 'published' );
322 322
 
323
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
-        return $message;
325
-    }
323
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
+		return $message;
325
+	}
326 326
 
327
-    public static function trash() {
327
+	public static function trash() {
328 328
 		self::change_form_status( 'trash' );
329
-    }
329
+	}
330 330
 
331 331
 	/**
332 332
 	 * @param string $status
@@ -364,68 +364,68 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 
366 366
 	public static function bulk_trash( $ids ) {
367
-        FrmAppHelper::permission_check('frm_delete_forms');
367
+		FrmAppHelper::permission_check('frm_delete_forms');
368 368
 
369
-        $count = 0;
370
-        foreach ( $ids as $id ) {
371
-            if ( FrmForm::trash( $id ) ) {
372
-                $count++;
373
-            }
374
-        }
369
+		$count = 0;
370
+		foreach ( $ids as $id ) {
371
+			if ( FrmForm::trash( $id ) ) {
372
+				$count++;
373
+			}
374
+		}
375 375
 
376
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
376
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
377 377
 		$message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
378 378
 
379
-        return $message;
380
-    }
379
+		return $message;
380
+	}
381 381
 
382
-    public static function destroy() {
383
-        FrmAppHelper::permission_check('frm_delete_forms');
382
+	public static function destroy() {
383
+		FrmAppHelper::permission_check('frm_delete_forms');
384 384
 
385 385
 		$params = FrmForm::list_page_params();
386 386
 
387
-        //check nonce url
388
-        check_admin_referer('destroy_form_' . $params['id']);
387
+		//check nonce url
388
+		check_admin_referer('destroy_form_' . $params['id']);
389 389
 
390
-        $count = 0;
391
-        if ( FrmForm::destroy( $params['id'] ) ) {
392
-            $count++;
393
-        }
390
+		$count = 0;
391
+		if ( FrmForm::destroy( $params['id'] ) ) {
392
+			$count++;
393
+		}
394 394
 
395
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
395
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
396 396
 
397 397
 		self::display_forms_list( $params, $message );
398
-    }
398
+	}
399 399
 
400 400
 	public static function bulk_destroy( $ids ) {
401
-        FrmAppHelper::permission_check('frm_delete_forms');
401
+		FrmAppHelper::permission_check('frm_delete_forms');
402 402
 
403
-        $count = 0;
404
-        foreach ( $ids as $id ) {
405
-            $d = FrmForm::destroy( $id );
406
-            if ( $d ) {
407
-                $count++;
408
-            }
409
-        }
403
+		$count = 0;
404
+		foreach ( $ids as $id ) {
405
+			$d = FrmForm::destroy( $id );
406
+			if ( $d ) {
407
+				$count++;
408
+			}
409
+		}
410 410
 
411
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
411
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412 412
 
413
-        return $message;
414
-    }
413
+		return $message;
414
+	}
415 415
 
416
-    private static function delete_all() {
417
-        //check nonce url
418
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
419
-        if ( $permission_error !== false ) {
416
+	private static function delete_all() {
417
+		//check nonce url
418
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
419
+		if ( $permission_error !== false ) {
420 420
 			self::display_forms_list( array(), '', array( $permission_error ) );
421
-            return;
422
-        }
421
+			return;
422
+		}
423 423
 
424 424
 		$count = FrmForm::scheduled_delete( time() );
425
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
425
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
426 426
 
427 427
 		self::display_forms_list( array(), $message );
428
-    }
428
+	}
429 429
 
430 430
 	public static function scheduled_delete( $delete_timestamp = '' ) {
431 431
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 	}
434 434
 
435 435
 	/**
436
-	* Inserts Formidable button
437
-	* Hook exists since 2.5.0
438
-	*
439
-	* @since 2.0.15
440
-	*/
436
+	 * Inserts Formidable button
437
+	 * Hook exists since 2.5.0
438
+	 *
439
+	 * @since 2.0.15
440
+	 */
441 441
 	public static function insert_form_button() {
442 442
 		if ( current_user_can('frm_view_forms') ) {
443 443
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -448,49 +448,49 @@  discard block
 block discarded – undo
448 448
 		}
449 449
 	}
450 450
 
451
-    public static function insert_form_popup() {
451
+	public static function insert_form_popup() {
452 452
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
453 453
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
454
-            return;
455
-        }
454
+			return;
455
+		}
456 456
 
457
-        FrmAppHelper::load_admin_wide_js();
457
+		FrmAppHelper::load_admin_wide_js();
458 458
 
459
-        $shortcodes = array(
459
+		$shortcodes = array(
460 460
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
461
-        );
461
+		);
462 462
 
463
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
463
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
464 464
 
465 465
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
466
-    }
466
+	}
467 467
 
468
-    public static function get_shortcode_opts() {
468
+	public static function get_shortcode_opts() {
469 469
 		FrmAppHelper::permission_check('frm_view_forms');
470
-        check_ajax_referer( 'frm_ajax', 'nonce' );
470
+		check_ajax_referer( 'frm_ajax', 'nonce' );
471 471
 
472 472
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
473
-        if ( empty($shortcode) ) {
474
-            wp_die();
475
-        }
473
+		if ( empty($shortcode) ) {
474
+			wp_die();
475
+		}
476 476
 
477 477
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
478 478
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
479 479
 
480
-        $form_id = '';
481
-        $opts = array();
480
+		$form_id = '';
481
+		$opts = array();
482 482
 		switch ( $shortcode ) {
483
-            case 'formidable':
484
-                $opts = array(
483
+			case 'formidable':
484
+				$opts = array(
485 485
 					'form_id'       => 'id',
486
-                    //'key' => ',
486
+					//'key' => ',
487 487
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
488 488
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
489 489
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
490
-                );
491
-            break;
492
-        }
493
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
490
+				);
491
+			break;
492
+		}
493
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
494 494
 
495 495
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
496 496
 			// allow other shortcodes to use the required form id option
@@ -500,61 +500,61 @@  discard block
 block discarded – undo
500 500
 
501 501
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
502 502
 
503
-        echo '</div>';
503
+		echo '</div>';
504 504
 
505
-        wp_die();
506
-    }
505
+		wp_die();
506
+	}
507 507
 
508 508
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
509
-        FrmAppHelper::permission_check( 'frm_view_forms' );
509
+		FrmAppHelper::permission_check( 'frm_view_forms' );
510 510
 		if ( ! empty( $deprecated_errors ) ) {
511 511
 			$errors = $deprecated_errors;
512 512
 			_deprecated_argument( 'errors', '2.0.8' );
513 513
 		}
514 514
 
515
-        global $wpdb, $frm_vars;
515
+		global $wpdb, $frm_vars;
516 516
 
517 517
 		if ( empty( $params ) ) {
518 518
 			$params = FrmForm::list_page_params();
519
-        }
519
+		}
520 520
 
521
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
521
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
522 522
 
523
-        $pagenum = $wp_list_table->get_pagenum();
523
+		$pagenum = $wp_list_table->get_pagenum();
524 524
 
525
-        $wp_list_table->prepare_items();
525
+		$wp_list_table->prepare_items();
526 526
 
527
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
528
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
527
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
528
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
529 529
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
530
-            die();
531
-        }
530
+			die();
531
+		}
532 532
 
533 533
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
534
-    }
534
+	}
535 535
 
536 536
 	public static function get_columns( $columns ) {
537
-	    $columns['cb'] = '<input type="checkbox" />';
538
-	    $columns['id'] = 'ID';
537
+		$columns['cb'] = '<input type="checkbox" />';
538
+		$columns['id'] = 'ID';
539 539
 
540
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
540
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
541 541
 
542
-        if ( 'template' == $type ) {
543
-            $columns['name']        = __( 'Template Name', 'formidable' );
544
-            $columns['type']        = __( 'Type', 'formidable' );
545
-            $columns['form_key']    = __( 'Key', 'formidable' );
546
-        } else {
547
-            $columns['name']        = __( 'Form Title', 'formidable' );
548
-            $columns['entries']     = __( 'Entries', 'formidable' );
549
-            $columns['form_key']    = __( 'Key', 'formidable' );
550
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
551
-        }
542
+		if ( 'template' == $type ) {
543
+			$columns['name']        = __( 'Template Name', 'formidable' );
544
+			$columns['type']        = __( 'Type', 'formidable' );
545
+			$columns['form_key']    = __( 'Key', 'formidable' );
546
+		} else {
547
+			$columns['name']        = __( 'Form Title', 'formidable' );
548
+			$columns['entries']     = __( 'Entries', 'formidable' );
549
+			$columns['form_key']    = __( 'Key', 'formidable' );
550
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
551
+		}
552 552
 
553
-        $columns['created_at'] = __( 'Date', 'formidable' );
553
+		$columns['created_at'] = __( 'Date', 'formidable' );
554 554
 
555 555
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
556 556
 
557
-        return $columns;
557
+		return $columns;
558 558
 	}
559 559
 
560 560
 	public static function get_sortable_columns() {
@@ -579,83 +579,83 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	public static function save_per_page( $save, $option, $value ) {
582
-        if ( $option == 'formidable_page_formidable_per_page' ) {
583
-            $save = (int) $value;
584
-        }
585
-        return $save;
586
-    }
582
+		if ( $option == 'formidable_page_formidable_per_page' ) {
583
+			$save = (int) $value;
584
+		}
585
+		return $save;
586
+	}
587 587
 
588 588
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
589
-        global $frm_vars;
589
+		global $frm_vars;
590 590
 
591
-        $form = FrmForm::getOne( $id );
592
-        if ( ! $form ) {
593
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
-        }
591
+		$form = FrmForm::getOne( $id );
592
+		if ( ! $form ) {
593
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
+		}
595 595
 
596
-        if ( $form->parent_form_id ) {
596
+		if ( $form->parent_form_id ) {
597 597
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
598
-        }
598
+		}
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+		$fields = FrmField::get_all_for_form($form->id);
602 602
 
603
-        // Automatically add end section fields if they don't exist (2.0 migration)
604
-        $reset_fields = false;
605
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
603
+		// Automatically add end section fields if they don't exist (2.0 migration)
604
+		$reset_fields = false;
605
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
606 606
 
607
-        if ( $reset_fields ) {
608
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
-        }
607
+		if ( $reset_fields ) {
608
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
+		}
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+		unset($end_section_values, $last_order, $open, $reset_fields);
612 612
 
613 613
 		$args = array( 'parent_form_id' => $form->id );
614
-        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
614
+		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
615 615
 
616
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
-        if ( $form->is_template && $message == $edit_message ) {
618
-            $message = __( 'Template was Successfully Updated', 'formidable' );
619
-        }
616
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
617
+		if ( $form->is_template && $message == $edit_message ) {
618
+			$message = __( 'Template was Successfully Updated', 'formidable' );
619
+		}
620 620
 
621 621
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
622 622
 
623
-        if ( $form->default_template ) {
624
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
625
-        } else if ( defined('DOING_AJAX') ) {
626
-            wp_die();
627
-        } else if ( $create_link ) {
623
+		if ( $form->default_template ) {
624
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
625
+		} else if ( defined('DOING_AJAX') ) {
626
+			wp_die();
627
+		} else if ( $create_link ) {
628 628
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
629
-        } else {
629
+		} else {
630 630
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
631
-        }
632
-    }
631
+		}
632
+	}
633 633
 
634 634
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
635 635
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
636 636
 
637
-        global $frm_vars;
637
+		global $frm_vars;
638 638
 
639
-        $form = FrmForm::getOne( $id );
639
+		$form = FrmForm::getOne( $id );
640 640
 
641
-        $fields = FrmField::get_all_for_form($id);
642
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
641
+		$fields = FrmField::get_all_for_form($id);
642
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
643 643
 
644
-        if ( isset($values['default_template']) && $values['default_template'] ) {
645
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
646
-        }
644
+		if ( isset($values['default_template']) && $values['default_template'] ) {
645
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
646
+		}
647 647
 
648 648
 		self::clean_submit_html( $values );
649 649
 
650
-        $action_controls = FrmFormActionsController::get_form_actions();
650
+		$action_controls = FrmFormActionsController::get_form_actions();
651 651
 
652
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
652
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
654 654
 
655
-        $styles = apply_filters('frm_get_style_opts', array());
655
+		$styles = apply_filters('frm_get_style_opts', array());
656 656
 
657 657
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
658
-    }
658
+	}
659 659
 
660 660
 	/**
661 661
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -670,11 +670,11 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 	}
672 672
 
673
-    public static function mb_tags_box( $form_id, $class = '' ) {
674
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
675
-        $linked_forms = array();
676
-        $col = 'one';
677
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
673
+	public static function mb_tags_box( $form_id, $class = '' ) {
674
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
675
+		$linked_forms = array();
676
+		$col = 'one';
677
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
678 678
 
679 679
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
680 680
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
683 683
 
684 684
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
685
-    }
685
+	}
686 686
 
687 687
 	/**
688 688
 	 * Get an array of the options to display in the advanced tab
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			''          => '',
724 724
 			'siteurl'   => __( 'Site URL', 'formidable' ),
725 725
 			'sitename'  => __( 'Site Name', 'formidable' ),
726
-        );
726
+		);
727 727
 
728 728
 		if ( ! FrmAppHelper::pro_is_installed() ) {
729 729
 			unset( $entry_shortcodes['post_id'] );
@@ -751,39 +751,39 @@  discard block
 block discarded – undo
751 751
 		return $entry_shortcodes;
752 752
 	}
753 753
 
754
-    // Insert the form class setting into the form
754
+	// Insert the form class setting into the form
755 755
 	public static function form_classes( $form ) {
756
-        if ( isset($form->options['form_class']) ) {
756
+		if ( isset($form->options['form_class']) ) {
757 757
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
758
-        }
759
-    }
758
+		}
759
+	}
760 760
 
761
-    public static function get_email_html() {
761
+	public static function get_email_html() {
762 762
 		FrmAppHelper::permission_check('frm_view_forms');
763
-        check_ajax_referer( 'frm_ajax', 'nonce' );
763
+		check_ajax_referer( 'frm_ajax', 'nonce' );
764 764
 		echo FrmEntriesController::show_entry_shortcode( array(
765 765
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
766
-	        'default_email' => true,
766
+			'default_email' => true,
767 767
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
768
-	    ) );
769
-	    wp_die();
768
+		) );
769
+		wp_die();
770 770
 	}
771 771
 
772
-    public static function filter_content( $content, $form, $entry = false ) {
772
+	public static function filter_content( $content, $form, $entry = false ) {
773 773
 		self::get_entry_by_param( $entry );
774
-        if ( ! $entry ) {
775
-            return $content;
776
-        }
774
+		if ( ! $entry ) {
775
+			return $content;
776
+		}
777 777
 
778
-        if ( is_object( $form ) ) {
779
-            $form = $form->id;
780
-        }
778
+		if ( is_object( $form ) ) {
779
+			$form = $form->id;
780
+		}
781 781
 
782
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
783
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
782
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
783
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
784 784
 
785
-        return $content;
786
-    }
785
+		return $content;
786
+	}
787 787
 
788 788
 	private static function get_entry_by_param( &$entry ) {
789 789
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -795,282 +795,282 @@  discard block
 block discarded – undo
795 795
 		}
796 796
 	}
797 797
 
798
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
799
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
800
-    }
798
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
799
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
800
+	}
801 801
 
802
-    public static function process_bulk_form_actions( $errors ) {
803
-        if ( ! $_REQUEST ) {
804
-            return $errors;
805
-        }
802
+	public static function process_bulk_form_actions( $errors ) {
803
+		if ( ! $_REQUEST ) {
804
+			return $errors;
805
+		}
806 806
 
807 807
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
808
-        if ( $bulkaction == -1 ) {
808
+		if ( $bulkaction == -1 ) {
809 809
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
810
-        }
811
-
812
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
813
-            FrmAppHelper::remove_get_action();
814
-
815
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
816
-        }
817
-
818
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
819
-        if ( empty( $ids ) ) {
820
-            $errors[] = __( 'No forms were specified', 'formidable' );
821
-            return $errors;
822
-        }
823
-
824
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
825
-        if ( $permission_error !== false ) {
826
-            $errors[] = $permission_error;
827
-            return $errors;
828
-        }
829
-
830
-        if ( ! is_array( $ids ) ) {
831
-            $ids = explode( ',', $ids );
832
-        }
833
-
834
-        switch ( $bulkaction ) {
835
-            case 'delete':
836
-                $message = self::bulk_destroy( $ids );
837
-            break;
838
-            case 'trash':
839
-                $message = self::bulk_trash( $ids );
840
-            break;
841
-            case 'untrash':
842
-                $message = self::bulk_untrash( $ids );
843
-            break;
844
-            case 'create_template':
845
-                $message = self::bulk_create_template( $ids );
846
-            break;
847
-        }
848
-
849
-        if ( isset( $message ) && ! empty( $message ) ) {
810
+		}
811
+
812
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
813
+			FrmAppHelper::remove_get_action();
814
+
815
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
816
+		}
817
+
818
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
819
+		if ( empty( $ids ) ) {
820
+			$errors[] = __( 'No forms were specified', 'formidable' );
821
+			return $errors;
822
+		}
823
+
824
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
825
+		if ( $permission_error !== false ) {
826
+			$errors[] = $permission_error;
827
+			return $errors;
828
+		}
829
+
830
+		if ( ! is_array( $ids ) ) {
831
+			$ids = explode( ',', $ids );
832
+		}
833
+
834
+		switch ( $bulkaction ) {
835
+			case 'delete':
836
+				$message = self::bulk_destroy( $ids );
837
+			break;
838
+			case 'trash':
839
+				$message = self::bulk_trash( $ids );
840
+			break;
841
+			case 'untrash':
842
+				$message = self::bulk_untrash( $ids );
843
+			break;
844
+			case 'create_template':
845
+				$message = self::bulk_create_template( $ids );
846
+			break;
847
+		}
848
+
849
+		if ( isset( $message ) && ! empty( $message ) ) {
850 850
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>';
851
-        }
851
+		}
852 852
 
853
-        return $errors;
854
-    }
853
+		return $errors;
854
+	}
855 855
 
856
-    public static function add_default_templates( $path, $default = true, $template = true ) {
857
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
856
+	public static function add_default_templates( $path, $default = true, $template = true ) {
857
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
858 858
 
859
-        $path = untrailingslashit(trim($path));
859
+		$path = untrailingslashit(trim($path));
860 860
 		$templates = glob( $path . '/*.php' );
861 861
 
862 862
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
863 863
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
864 864
 			$template_query = array( 'form_key' => $filename );
865
-            if ( $template ) {
866
-                $template_query['is_template'] = 1;
867
-            }
868
-            if ( $default ) {
869
-                $template_query['default_template'] = 1;
870
-            }
865
+			if ( $template ) {
866
+				$template_query['is_template'] = 1;
867
+			}
868
+			if ( $default ) {
869
+				$template_query['default_template'] = 1;
870
+			}
871 871
 			$form = FrmForm::getAll( $template_query, '', 1 );
872 872
 
873
-            $values = FrmFormsHelper::setup_new_vars();
874
-            $values['form_key'] = $filename;
875
-            $values['is_template'] = $template;
876
-            $values['status'] = 'published';
877
-            if ( $default ) {
878
-                $values['default_template'] = 1;
879
-            }
880
-
881
-            include( $templates[ $i ] );
882
-
883
-            //get updated form
884
-            if ( isset($form) && ! empty($form) ) {
885
-                $old_id = $form->id;
886
-                $form = FrmForm::getOne($form->id);
887
-            } else {
888
-                $old_id = false;
873
+			$values = FrmFormsHelper::setup_new_vars();
874
+			$values['form_key'] = $filename;
875
+			$values['is_template'] = $template;
876
+			$values['status'] = 'published';
877
+			if ( $default ) {
878
+				$values['default_template'] = 1;
879
+			}
880
+
881
+			include( $templates[ $i ] );
882
+
883
+			//get updated form
884
+			if ( isset($form) && ! empty($form) ) {
885
+				$old_id = $form->id;
886
+				$form = FrmForm::getOne($form->id);
887
+			} else {
888
+				$old_id = false;
889 889
 				$form = FrmForm::getAll( $template_query, '', 1 );
890
-            }
890
+			}
891 891
 
892
-            if ( $form ) {
892
+			if ( $form ) {
893 893
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
894
-            }
895
-        }
896
-    }
894
+			}
895
+		}
896
+	}
897 897
 
898
-    public static function route() {
899
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
900
-        $vars = array();
898
+	public static function route() {
899
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
900
+		$vars = array();
901 901
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
902 902
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
903 903
 
904
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
905
-            $json_vars = json_decode($json_vars, true);
906
-            if ( empty($json_vars) ) {
907
-                // json decoding failed so we should return an error message
904
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
905
+			$json_vars = json_decode($json_vars, true);
906
+			if ( empty($json_vars) ) {
907
+				// json decoding failed so we should return an error message
908 908
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
909
-                if ( 'edit' == $action ) {
910
-                    $action = 'update';
911
-                }
912
-
913
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
914
-            } else {
915
-                $vars = FrmAppHelper::json_to_array($json_vars);
916
-                $action = $vars[ $action ];
909
+				if ( 'edit' == $action ) {
910
+					$action = 'update';
911
+				}
912
+
913
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
914
+			} else {
915
+				$vars = FrmAppHelper::json_to_array($json_vars);
916
+				$action = $vars[ $action ];
917 917
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
918 918
 				$_REQUEST = array_merge( $_REQUEST, $vars );
919 919
 				$_POST = array_merge( $_POST, $_REQUEST );
920
-            }
921
-        } else {
920
+			}
921
+		} else {
922 922
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
923
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
924
-                // override the action for this page
925
-    			$action = 'delete_all';
926
-            }
927
-        }
923
+			if ( isset( $_REQUEST['delete_all'] ) ) {
924
+				// override the action for this page
925
+				$action = 'delete_all';
926
+			}
927
+		}
928 928
 
929 929
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
930
-        FrmAppHelper::trigger_hook_load( 'form' );
931
-
932
-        switch ( $action ) {
933
-            case 'new':
934
-                return self::new_form($vars);
935
-            case 'create':
936
-            case 'edit':
937
-            case 'update':
938
-            case 'duplicate':
939
-            case 'trash':
940
-            case 'untrash':
941
-            case 'destroy':
942
-            case 'delete_all':
943
-            case 'settings':
944
-            case 'update_settings':
930
+		FrmAppHelper::trigger_hook_load( 'form' );
931
+
932
+		switch ( $action ) {
933
+			case 'new':
934
+				return self::new_form($vars);
935
+			case 'create':
936
+			case 'edit':
937
+			case 'update':
938
+			case 'duplicate':
939
+			case 'trash':
940
+			case 'untrash':
941
+			case 'destroy':
942
+			case 'delete_all':
943
+			case 'settings':
944
+			case 'update_settings':
945 945
 				return self::$action( $vars );
946
-            default:
946
+			default:
947 947
 				do_action( 'frm_form_action_' . $action );
948 948
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
949
-                    return;
950
-                }
949
+					return;
950
+				}
951 951
 
952 952
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
953
-                if ( $action == -1 ) {
953
+				if ( $action == -1 ) {
954 954
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
955
-                }
955
+				}
956 956
 
957
-                if ( strpos($action, 'bulk_') === 0 ) {
958
-                    FrmAppHelper::remove_get_action();
959
-                    return self::list_form();
960
-                }
957
+				if ( strpos($action, 'bulk_') === 0 ) {
958
+					FrmAppHelper::remove_get_action();
959
+					return self::list_form();
960
+				}
961 961
 
962
-                return self::display_forms_list();
963
-        }
964
-    }
962
+				return self::display_forms_list();
963
+		}
964
+	}
965 965
 
966
-    public static function json_error( $errors ) {
967
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
968
-        return $errors;
969
-    }
966
+	public static function json_error( $errors ) {
967
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
968
+		return $errors;
969
+	}
970 970
 
971 971
 
972
-    /* FRONT-END FORMS */
973
-    public static function admin_bar_css() {
972
+	/* FRONT-END FORMS */
973
+	public static function admin_bar_css() {
974 974
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
975
-            return;
976
-        }
975
+			return;
976
+		}
977 977
 
978 978
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
979 979
 		FrmAppHelper::load_font_style();
980 980
 	}
981 981
 
982 982
 	public static function admin_bar_configure() {
983
-        global $frm_vars;
984
-        if ( empty($frm_vars['forms_loaded']) ) {
985
-            return;
986
-        }
987
-
988
-        $actions = array();
989
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
990
-            if ( is_object($form) ) {
991
-                $actions[ $form->id ] = $form->name;
992
-            }
993
-            unset($form);
994
-        }
995
-
996
-        if ( empty($actions) ) {
997
-            return;
998
-        }
999
-
1000
-        asort($actions);
1001
-
1002
-        global $wp_admin_bar;
1003
-
1004
-        if ( count($actions) == 1 ) {
1005
-            $wp_admin_bar->add_menu( array(
1006
-                'title' => 'Edit Form',
983
+		global $frm_vars;
984
+		if ( empty($frm_vars['forms_loaded']) ) {
985
+			return;
986
+		}
987
+
988
+		$actions = array();
989
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
990
+			if ( is_object($form) ) {
991
+				$actions[ $form->id ] = $form->name;
992
+			}
993
+			unset($form);
994
+		}
995
+
996
+		if ( empty($actions) ) {
997
+			return;
998
+		}
999
+
1000
+		asort($actions);
1001
+
1002
+		global $wp_admin_bar;
1003
+
1004
+		if ( count($actions) == 1 ) {
1005
+			$wp_admin_bar->add_menu( array(
1006
+				'title' => 'Edit Form',
1007 1007
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
1008
-                'id'    => 'frm-forms',
1009
-            ) );
1010
-        } else {
1011
-            $wp_admin_bar->add_menu( array(
1012
-        		'id'    => 'frm-forms',
1013
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
1008
+				'id'    => 'frm-forms',
1009
+			) );
1010
+		} else {
1011
+			$wp_admin_bar->add_menu( array(
1012
+				'id'    => 'frm-forms',
1013
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
1014 1014
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
1015
-        		'meta'  => array(
1015
+				'meta'  => array(
1016 1016
 					'title' => __( 'Edit Forms', 'formidable' ),
1017
-        		),
1018
-        	) );
1017
+				),
1018
+			) );
1019 1019
 
1020
-        	foreach ( $actions as $form_id => $name ) {
1020
+			foreach ( $actions as $form_id => $name ) {
1021 1021
 
1022
-        		$wp_admin_bar->add_menu( array(
1023
-        			'parent'    => 'frm-forms',
1022
+				$wp_admin_bar->add_menu( array(
1023
+					'parent'    => 'frm-forms',
1024 1024
 					'id'        => 'edit_form_' . $form_id,
1025
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1025
+					'title'     => empty($name) ? __( '(no title)') : $name,
1026 1026
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1027
-        		) );
1028
-        	}
1029
-        }
1030
-    }
1027
+				) );
1028
+			}
1029
+		}
1030
+	}
1031 1031
 
1032
-    //formidable shortcode
1032
+	//formidable shortcode
1033 1033
 	public static function get_form_shortcode( $atts ) {
1034
-        global $frm_vars;
1035
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1036
-            $sc = '[formidable';
1034
+		global $frm_vars;
1035
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1036
+			$sc = '[formidable';
1037 1037
 			if ( ! empty( $atts ) ) {
1038 1038
 				foreach ( $atts as $k => $v ) {
1039 1039
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1040 1040
 				}
1041 1041
 			}
1042 1042
 			return $sc . ']';
1043
-        }
1044
-
1045
-        $shortcode_atts = shortcode_atts( array(
1046
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1047
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1048
-            'exclude_fields' => array(), 'minimize' => false,
1049
-        ), $atts);
1050
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1051
-
1052
-        return self::show_form(
1053
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1054
-            $shortcode_atts['description'], $atts
1055
-        );
1056
-    }
1057
-
1058
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1059
-        if ( empty( $id ) ) {
1060
-            $id = $key;
1061
-        }
1062
-
1063
-        $form = self::maybe_get_form_to_show( $id );
1064
-        if ( ! $form ) {
1065
-            return __( 'Please select a valid form', 'formidable' );
1066
-        }
1043
+		}
1044
+
1045
+		$shortcode_atts = shortcode_atts( array(
1046
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1047
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1048
+			'exclude_fields' => array(), 'minimize' => false,
1049
+		), $atts);
1050
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1051
+
1052
+		return self::show_form(
1053
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1054
+			$shortcode_atts['description'], $atts
1055
+		);
1056
+	}
1057
+
1058
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1059
+		if ( empty( $id ) ) {
1060
+			$id = $key;
1061
+		}
1062
+
1063
+		$form = self::maybe_get_form_to_show( $id );
1064
+		if ( ! $form ) {
1065
+			return __( 'Please select a valid form', 'formidable' );
1066
+		}
1067 1067
 
1068 1068
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1069
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1069
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1070 1070
 
1071
-        $form = apply_filters( 'frm_pre_display_form', $form );
1071
+		$form = apply_filters( 'frm_pre_display_form', $form );
1072 1072
 
1073
-        $frm_settings = FrmAppHelper::get_settings();
1073
+		$frm_settings = FrmAppHelper::get_settings();
1074 1074
 
1075 1075
 		if ( self::is_viewable_draft_form( $form ) ) {
1076 1076
 			// don't show a draft form on a page
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 		}
1092 1092
 
1093 1093
 		return $form;
1094
-    }
1094
+	}
1095 1095
 
1096 1096
 	private static function maybe_get_form_to_show( $id ) {
1097 1097
 		$form = false;
@@ -1120,99 +1120,99 @@  discard block
 block discarded – undo
1120 1120
 		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'] );
1121 1121
 	}
1122 1122
 
1123
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1124
-        ob_start();
1123
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1124
+		ob_start();
1125 1125
 
1126
-        self::get_form_contents( $form, $title, $description, $atts );
1126
+		self::get_form_contents( $form, $title, $description, $atts );
1127 1127
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1128 1128
 
1129
-        $contents = ob_get_contents();
1130
-        ob_end_clean();
1129
+		$contents = ob_get_contents();
1130
+		ob_end_clean();
1131 1131
 
1132 1132
 		self::maybe_minimize_form( $atts, $contents );
1133 1133
 
1134
-        return $contents;
1135
-    }
1134
+		return $contents;
1135
+	}
1136 1136
 
1137 1137
 	public static function enqueue_scripts( $params ) {
1138 1138
 		do_action( 'frm_enqueue_form_scripts', $params );
1139 1139
 	}
1140 1140
 
1141 1141
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1142
-        global $frm_vars;
1142
+		global $frm_vars;
1143 1143
 
1144
-        $frm_settings = FrmAppHelper::get_settings();
1144
+		$frm_settings = FrmAppHelper::get_settings();
1145 1145
 
1146
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1146
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1147 1147
 
1148
-        $user_ID = get_current_user_id();
1148
+		$user_ID = get_current_user_id();
1149 1149
 		$params = FrmForm::get_params( $form );
1150 1150
 		$message = '';
1151 1151
 		$errors = array();
1152 1152
 
1153
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1154
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1155
-        }
1153
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1154
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1155
+		}
1156 1156
 
1157 1157
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1158 1158
 		$fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
1159 1159
 
1160
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1161
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1162
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1163
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1160
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1161
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1162
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1163
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1164 1164
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1165
-            }
1166
-            return;
1167
-        }
1165
+			}
1166
+			return;
1167
+		}
1168 1168
 
1169
-        if ( ! empty($errors) ) {
1170
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1169
+		if ( ! empty($errors) ) {
1170
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1171 1171
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1172
-            return;
1173
-        }
1172
+			return;
1173
+		}
1174 1174
 
1175
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1176
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1177
-            return;
1178
-        }
1175
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1176
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1177
+			return;
1178
+		}
1179 1179
 
1180
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1181
-        $created = self::just_created_entry( $form->id );
1182
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create');
1180
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1181
+		$created = self::just_created_entry( $form->id );
1182
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, 'create');
1183 1183
 
1184
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1185
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1184
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1185
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1186 1186
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1187
-            return;
1188
-        }
1187
+			return;
1188
+		}
1189 1189
 
1190
-        if ( $created && is_numeric($created) ) {
1191
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1192
-            $class = 'frm_message';
1193
-        } else {
1194
-            $message = $frm_settings->failed_msg;
1195
-            $class = FrmFormsHelper::form_error_class();
1196
-        }
1190
+		if ( $created && is_numeric($created) ) {
1191
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1192
+			$class = 'frm_message';
1193
+		} else {
1194
+			$message = $frm_settings->failed_msg;
1195
+			$class = FrmFormsHelper::form_error_class();
1196
+		}
1197 1197
 
1198 1198
 		$message = FrmFormsHelper::get_success_message( array(
1199 1199
 			'message' => $message, 'form' => $form,
1200 1200
 			'entry_id' => $created, 'class' => $class,
1201 1201
 		) );
1202
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1202
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1203 1203
 
1204
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1204
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1205 1205
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1206
-        } else {
1207
-            global $frm_vars;
1206
+		} else {
1207
+			global $frm_vars;
1208 1208
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1209 1209
 
1210 1210
 			$include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1211 1211
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1212
-        }
1212
+		}
1213 1213
 
1214 1214
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1215
-    }
1215
+	}
1216 1216
 
1217 1217
 	/**
1218 1218
 	 * @since 2.2.7
@@ -1249,10 +1249,10 @@  discard block
 block discarded – undo
1249 1249
 	}
1250 1250
 
1251 1251
 	public static function defer_script_loading( $tag, $handle ) {
1252
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1253
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1252
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1253
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1254 1254
 		}
1255
-	    return $tag;
1255
+		return $tag;
1256 1256
 	}
1257 1257
 
1258 1258
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,36 +33,36 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-			self::create($values);
59
+			self::create( $values );
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
63
+            $values = FrmFormsHelper::setup_new_vars( $values );
64 64
             $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
65
+            $form = FrmForm::getOne( $id );
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     }
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
94 94
 
95 95
         global $frm_vars;
96 96
         if ( empty( $values ) ) {
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
103 103
         }
104 104
 
105
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
105
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107 107
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108 108
             $frm_settings = FrmAppHelper::get_settings();
109 109
             $errors = array( 'form' => $frm_settings->admin_permission );
110 110
         } else {
111
-            $errors = FrmForm::validate($values);
111
+            $errors = FrmForm::validate( $values );
112 112
         }
113 113
 
114
-        if ( count($errors) > 0 ) {
114
+        if ( count( $errors ) > 0 ) {
115 115
             $hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117 117
             $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
118
+            $fields = FrmField::get_all_for_form( $id );
119 119
 
120
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
120
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
121 121
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
122 122
 
123 123
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -129,32 +129,32 @@  discard block
 block discarded – undo
129 129
     }
130 130
 
131 131
     public static function edit( $values = false ) {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
133 133
 
134 134
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
-        return self::get_edit_vars($id);
135
+        return self::get_edit_vars( $id );
136 136
     }
137 137
 
138 138
     public static function settings( $id = false, $message = '' ) {
139
-        FrmAppHelper::permission_check('frm_edit_forms');
139
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
140 140
 
141
-        if ( ! $id || ! is_numeric($id) ) {
141
+        if ( ! $id || ! is_numeric( $id ) ) {
142 142
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143 143
         }
144 144
 		return self::get_settings_vars( $id, array(), $message );
145 145
     }
146 146
 
147 147
     public static function update_settings() {
148
-        FrmAppHelper::permission_check('frm_edit_forms');
148
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
149 149
 
150 150
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
151 151
 
152
-        $errors = FrmForm::validate($_POST);
153
-        if ( count($errors) > 0 ) {
154
-            return self::get_settings_vars($id, $errors);
152
+        $errors = FrmForm::validate( $_POST );
153
+        if ( count( $errors ) > 0 ) {
154
+            return self::get_settings_vars( $id, $errors );
155 155
         }
156 156
 
157
-        do_action('frm_before_update_form_settings', $id);
157
+        do_action( 'frm_before_update_form_settings', $id );
158 158
 
159 159
 		FrmForm::update( $id, $_POST );
160 160
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 	private static function edit_in_place_value( $field ) {
178 178
 		check_ajax_referer( 'frm_ajax', 'nonce' );
179
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
179
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
180 180
 
181 181
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
182 182
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @since 2.0
235 235
 	 */
236 236
 	public static function _create_from_template() {
237
-		FrmAppHelper::permission_check('frm_edit_forms');
237
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
238 238
 		check_ajax_referer( 'frm_ajax', 'nonce' );
239 239
 
240 240
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
     public static function duplicate() {
252
-        FrmAppHelper::permission_check('frm_edit_forms');
252
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
253 253
 
254 254
 		$params = FrmForm::list_page_params();
255 255
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
256
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257 257
         if ( $form ) {
258 258
 			return self::get_edit_vars( $form, array(), $message, true );
259 259
         } else {
260
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
260
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
261 261
         }
262 262
     }
263 263
 
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
     }
317 317
 
318 318
 	public static function bulk_untrash( $ids ) {
319
-        FrmAppHelper::permission_check('frm_edit_forms');
319
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
320 320
 
321 321
         $count = FrmForm::set_status( $ids, 'published' );
322 322
 
323
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
323
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324 324
         return $message;
325 325
     }
326 326
 
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
340 340
 		);
341 341
 
342
-		if ( ! isset( $available_status[ $status ] ) ) {
342
+		if ( ! isset( $available_status[$status] ) ) {
343 343
 			return;
344 344
 		}
345 345
 
346
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
346
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
347 347
 
348 348
 		$params = FrmForm::list_page_params();
349 349
 
@@ -351,25 +351,25 @@  discard block
 block discarded – undo
351 351
 		check_admin_referer( $status . '_form_' . $params['id'] );
352 352
 
353 353
 		$count = 0;
354
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
355
-			$count++;
354
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
355
+			$count ++;
356 356
 		}
357 357
 
358
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
358
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
359 359
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
360 360
 
361
-		$message = $available_status[ $status ]['message'];
361
+		$message = $available_status[$status]['message'];
362 362
 
363 363
 		self::display_forms_list( $params, $message );
364 364
 	}
365 365
 
366 366
 	public static function bulk_trash( $ids ) {
367
-        FrmAppHelper::permission_check('frm_delete_forms');
367
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
368 368
 
369 369
         $count = 0;
370 370
         foreach ( $ids as $id ) {
371 371
             if ( FrmForm::trash( $id ) ) {
372
-                $count++;
372
+                $count ++;
373 373
             }
374 374
         }
375 375
 
@@ -380,49 +380,49 @@  discard block
 block discarded – undo
380 380
     }
381 381
 
382 382
     public static function destroy() {
383
-        FrmAppHelper::permission_check('frm_delete_forms');
383
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
384 384
 
385 385
 		$params = FrmForm::list_page_params();
386 386
 
387 387
         //check nonce url
388
-        check_admin_referer('destroy_form_' . $params['id']);
388
+        check_admin_referer( 'destroy_form_' . $params['id'] );
389 389
 
390 390
         $count = 0;
391 391
         if ( FrmForm::destroy( $params['id'] ) ) {
392
-            $count++;
392
+            $count ++;
393 393
         }
394 394
 
395
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
395
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
396 396
 
397 397
 		self::display_forms_list( $params, $message );
398 398
     }
399 399
 
400 400
 	public static function bulk_destroy( $ids ) {
401
-        FrmAppHelper::permission_check('frm_delete_forms');
401
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
402 402
 
403 403
         $count = 0;
404 404
         foreach ( $ids as $id ) {
405 405
             $d = FrmForm::destroy( $id );
406 406
             if ( $d ) {
407
-                $count++;
407
+                $count ++;
408 408
             }
409 409
         }
410 410
 
411
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
411
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
412 412
 
413 413
         return $message;
414 414
     }
415 415
 
416 416
     private static function delete_all() {
417 417
         //check nonce url
418
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
418
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
419 419
         if ( $permission_error !== false ) {
420 420
 			self::display_forms_list( array(), '', array( $permission_error ) );
421 421
             return;
422 422
         }
423 423
 
424 424
 		$count = FrmForm::scheduled_delete( time() );
425
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
425
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
426 426
 
427 427
 		self::display_forms_list( array(), $message );
428 428
     }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	* @since 2.0.15
440 440
 	*/
441 441
 	public static function insert_form_button() {
442
-		if ( current_user_can('frm_view_forms') ) {
442
+		if ( current_user_can( 'frm_view_forms' ) ) {
443 443
 			$menu_name = FrmAppHelper::get_menu_name();
444 444
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
445 445
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
461 461
         );
462 462
 
463
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
463
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
464 464
 
465 465
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
466 466
     }
467 467
 
468 468
     public static function get_shortcode_opts() {
469
-		FrmAppHelper::permission_check('frm_view_forms');
469
+		FrmAppHelper::permission_check( 'frm_view_forms' );
470 470
         check_ajax_referer( 'frm_ajax', 'nonce' );
471 471
 
472 472
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
473
-        if ( empty($shortcode) ) {
473
+        if ( empty( $shortcode ) ) {
474 474
             wp_die();
475 475
         }
476 476
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
                 );
491 491
             break;
492 492
         }
493
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
493
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
494 494
 
495 495
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
496 496
 			// allow other shortcodes to use the required form id option
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
         }
595 595
 
596 596
         if ( $form->parent_form_id ) {
597
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ));
597
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
598 598
         }
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+        $fields = FrmField::get_all_for_form( $form->id );
602 602
 
603 603
         // Automatically add end section fields if they don't exist (2.0 migration)
604 604
         $reset_fields = false;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609 609
         }
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+        unset( $end_section_values, $last_order, $open, $reset_fields );
612 612
 
613 613
 		$args = array( 'parent_form_id' => $form->id );
614 614
         $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
622 622
 
623 623
         if ( $form->default_template ) {
624
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
625
-        } else if ( defined('DOING_AJAX') ) {
624
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
625
+        } else if ( defined( 'DOING_AJAX' ) ) {
626 626
             wp_die();
627 627
         } else if ( $create_link ) {
628 628
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -638,21 +638,21 @@  discard block
 block discarded – undo
638 638
 
639 639
         $form = FrmForm::getOne( $id );
640 640
 
641
-        $fields = FrmField::get_all_for_form($id);
642
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
641
+        $fields = FrmField::get_all_for_form( $id );
642
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
643 643
 
644
-        if ( isset($values['default_template']) && $values['default_template'] ) {
645
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
644
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
645
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
646 646
         }
647 647
 
648 648
 		self::clean_submit_html( $values );
649 649
 
650 650
         $action_controls = FrmFormActionsController::get_form_actions();
651 651
 
652
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
652
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
653 653
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
654 654
 
655
-        $styles = apply_filters('frm_get_style_opts', array());
655
+        $styles = apply_filters( 'frm_get_style_opts', array() );
656 656
 
657 657
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
658 658
     }
@@ -671,10 +671,10 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 
673 673
     public static function mb_tags_box( $form_id, $class = '' ) {
674
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
674
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
675 675
         $linked_forms = array();
676 676
         $col = 'one';
677
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
677
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
678 678
 
679 679
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
680 680
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -753,13 +753,13 @@  discard block
 block discarded – undo
753 753
 
754 754
     // Insert the form class setting into the form
755 755
 	public static function form_classes( $form ) {
756
-        if ( isset($form->options['form_class']) ) {
756
+        if ( isset( $form->options['form_class'] ) ) {
757 757
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
758 758
         }
759 759
     }
760 760
 
761 761
     public static function get_email_html() {
762
-		FrmAppHelper::permission_check('frm_view_forms');
762
+		FrmAppHelper::permission_check( 'frm_view_forms' );
763 763
         check_ajax_referer( 'frm_ajax', 'nonce' );
764 764
 		echo FrmEntriesController::show_entry_shortcode( array(
765 765
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
     public static function add_default_templates( $path, $default = true, $template = true ) {
857 857
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
858 858
 
859
-        $path = untrailingslashit(trim($path));
859
+        $path = untrailingslashit( trim( $path ) );
860 860
 		$templates = glob( $path . '/*.php' );
861 861
 
862
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
863
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
862
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
863
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
864 864
 			$template_query = array( 'form_key' => $filename );
865 865
             if ( $template ) {
866 866
                 $template_query['is_template'] = 1;
@@ -878,12 +878,12 @@  discard block
 block discarded – undo
878 878
                 $values['default_template'] = 1;
879 879
             }
880 880
 
881
-            include( $templates[ $i ] );
881
+            include( $templates[$i] );
882 882
 
883 883
             //get updated form
884
-            if ( isset($form) && ! empty($form) ) {
884
+            if ( isset( $form ) && ! empty( $form ) ) {
885 885
                 $old_id = $form->id;
886
-                $form = FrmForm::getOne($form->id);
886
+                $form = FrmForm::getOne( $form->id );
887 887
             } else {
888 888
                 $old_id = false;
889 889
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -896,24 +896,24 @@  discard block
 block discarded – undo
896 896
     }
897 897
 
898 898
     public static function route() {
899
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
899
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
900 900
         $vars = array();
901 901
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
902 902
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
903 903
 
904
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
905
-            $json_vars = json_decode($json_vars, true);
906
-            if ( empty($json_vars) ) {
904
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
905
+            $json_vars = json_decode( $json_vars, true );
906
+            if ( empty( $json_vars ) ) {
907 907
                 // json decoding failed so we should return an error message
908 908
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
909 909
                 if ( 'edit' == $action ) {
910 910
                     $action = 'update';
911 911
                 }
912 912
 
913
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
913
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
914 914
             } else {
915
-                $vars = FrmAppHelper::json_to_array($json_vars);
916
-                $action = $vars[ $action ];
915
+                $vars = FrmAppHelper::json_to_array( $json_vars );
916
+                $action = $vars[$action];
917 917
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
918 918
 				$_REQUEST = array_merge( $_REQUEST, $vars );
919 919
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 
932 932
         switch ( $action ) {
933 933
             case 'new':
934
-                return self::new_form($vars);
934
+                return self::new_form( $vars );
935 935
             case 'create':
936 936
             case 'edit':
937 937
             case 'update':
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
955 955
                 }
956 956
 
957
-                if ( strpos($action, 'bulk_') === 0 ) {
957
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
958 958
                     FrmAppHelper::remove_get_action();
959 959
                     return self::list_form();
960 960
                 }
@@ -981,27 +981,27 @@  discard block
 block discarded – undo
981 981
 
982 982
 	public static function admin_bar_configure() {
983 983
         global $frm_vars;
984
-        if ( empty($frm_vars['forms_loaded']) ) {
984
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
985 985
             return;
986 986
         }
987 987
 
988 988
         $actions = array();
989 989
         foreach ( $frm_vars['forms_loaded'] as $form ) {
990
-            if ( is_object($form) ) {
991
-                $actions[ $form->id ] = $form->name;
990
+            if ( is_object( $form ) ) {
991
+                $actions[$form->id] = $form->name;
992 992
             }
993
-            unset($form);
993
+            unset( $form );
994 994
         }
995 995
 
996
-        if ( empty($actions) ) {
996
+        if ( empty( $actions ) ) {
997 997
             return;
998 998
         }
999 999
 
1000
-        asort($actions);
1000
+        asort( $actions );
1001 1001
 
1002 1002
         global $wp_admin_bar;
1003 1003
 
1004
-        if ( count($actions) == 1 ) {
1004
+        if ( count( $actions ) == 1 ) {
1005 1005
             $wp_admin_bar->add_menu( array(
1006 1006
                 'title' => 'Edit Form',
1007 1007
 				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
         		$wp_admin_bar->add_menu( array(
1023 1023
         			'parent'    => 'frm-forms',
1024 1024
 					'id'        => 'edit_form_' . $form_id,
1025
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1025
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1026 1026
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1027 1027
         		) );
1028 1028
         	}
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
     //formidable shortcode
1033 1033
 	public static function get_form_shortcode( $atts ) {
1034 1034
         global $frm_vars;
1035
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1035
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1036 1036
             $sc = '[formidable';
1037 1037
 			if ( ! empty( $atts ) ) {
1038 1038
 				foreach ( $atts as $k => $v ) {
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1047 1047
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1048 1048
             'exclude_fields' => array(), 'minimize' => false,
1049
-        ), $atts);
1050
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1049
+        ), $atts );
1050
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1051 1051
 
1052 1052
         return self::show_form(
1053 1053
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 
1144 1144
         $frm_settings = FrmAppHelper::get_settings();
1145 1145
 
1146
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1146
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1147 1147
 
1148 1148
         $user_ID = get_current_user_id();
1149 1149
 		$params = FrmForm::get_params( $form );
@@ -1151,44 +1151,44 @@  discard block
 block discarded – undo
1151 1151
 		$errors = array();
1152 1152
 
1153 1153
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1154
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1154
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1155 1155
         }
1156 1156
 
1157 1157
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1158 1158
 		$fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
1159 1159
 
1160 1160
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1161
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1162
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1163
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1161
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1162
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1163
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1164 1164
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1165 1165
             }
1166 1166
             return;
1167 1167
         }
1168 1168
 
1169
-        if ( ! empty($errors) ) {
1170
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1169
+        if ( ! empty( $errors ) ) {
1170
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1171 1171
 			include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1172 1172
             return;
1173 1173
         }
1174 1174
 
1175
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1176
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1175
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1176
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1177 1177
             return;
1178 1178
         }
1179 1179
 
1180
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1180
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1181 1181
         $created = self::just_created_entry( $form->id );
1182
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create');
1182
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, 'create' );
1183 1183
 
1184
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1185
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1184
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1185
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1186 1186
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1187 1187
             return;
1188 1188
         }
1189 1189
 
1190
-        if ( $created && is_numeric($created) ) {
1191
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1190
+        if ( $created && is_numeric( $created ) ) {
1191
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1192 1192
             $class = 'frm_message';
1193 1193
         } else {
1194 1194
             $message = $frm_settings->failed_msg;
@@ -1199,9 +1199,9 @@  discard block
 block discarded – undo
1199 1199
 			'message' => $message, 'form' => $form,
1200 1200
 			'entry_id' => $created, 'class' => $class,
1201 1201
 		) );
1202
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1202
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1203 1203
 
1204
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1204
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1205 1205
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1206 1206
         } else {
1207 1207
             global $frm_vars;
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 	 */
1220 1220
 	public static function just_created_entry( $form_id ) {
1221 1221
 		global $frm_vars;
1222
-		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
1222
+		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0;
1223 1223
 	}
1224 1224
 
1225 1225
 	public static function front_head() {
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -2,70 +2,70 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars;
68
+		global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84 84
 		$columns[ $form_id . '_ip' ] = 'IP';
85 85
 
86
-        $frm_vars['cols'] = $columns;
86
+		$frm_vars['cols'] = $columns;
87 87
 
88 88
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
89 89
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
90 90
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
91
-        }
91
+		}
92 92
 
93
-        return $columns;
94
-    }
93
+		return $columns;
94
+	}
95 95
 
96 96
 	private static function get_columns_for_form( $form_id, &$columns ) {
97 97
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -135,76 +135,76 @@  discard block
 block discarded – undo
135 135
 		$menu_name = FrmAppHelper::get_menu_name();
136 136
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
137 137
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
138
-            return $check;
139
-        }
138
+			return $check;
139
+		}
140 140
 
141 141
 		if ( empty( $prev_value ) ) {
142 142
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
143 143
 		}
144 144
 
145
-        global $frm_vars;
146
-        //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
145
+		global $frm_vars;
146
+		//add a check so we don't create a loop
147
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149
-        return $check;
150
-    }
149
+		return $check;
150
+	}
151 151
 
152
-    //add hidden columns back from other forms
152
+	//add hidden columns back from other forms
153 153
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
154 154
 		$menu_name = FrmAppHelper::get_menu_name();
155 155
 		$sanitized = sanitize_title( $menu_name );
156 156
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
157 157
 		if ( $meta_key != $this_page_name ) {
158
-            return;
159
-        }
160
-
161
-        global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
-            return; //don't continue if there's no previous value
164
-        }
165
-
166
-        foreach ( $meta_value as $mk => $mv ) {
167
-            //remove blank values
168
-            if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
170
-            }
171
-        }
172
-
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
175
-        $cur_form_prefix = $cur_form_prefix[0];
176
-        $save = false;
177
-
178
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
158
+			return;
159
+		}
160
+
161
+		global $frm_vars;
162
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
+			return; //don't continue if there's no previous value
164
+		}
165
+
166
+		foreach ( $meta_value as $mk => $mv ) {
167
+			//remove blank values
168
+			if ( empty( $mv ) ) {
169
+				unset( $meta_value[ $mk ] );
170
+			}
171
+		}
172
+
173
+		$cur_form_prefix = reset($meta_value);
174
+		$cur_form_prefix = explode('_', $cur_form_prefix);
175
+		$cur_form_prefix = $cur_form_prefix[0];
176
+		$save = false;
177
+
178
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
179 179
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
180
-                //don't add blank cols or process included cols
181
-                continue;
182
-            }
180
+				//don't add blank cols or process included cols
181
+				continue;
182
+			}
183 183
 
184 184
 			$form_prefix = explode( '_', $prev_hidden );
185
-            $form_prefix = $form_prefix[0];
186
-            if ( $form_prefix == $cur_form_prefix ) {
187
-                //don't add back columns that are meant to be hidden
188
-                continue;
189
-            }
185
+			$form_prefix = $form_prefix[0];
186
+			if ( $form_prefix == $cur_form_prefix ) {
187
+				//don't add back columns that are meant to be hidden
188
+				continue;
189
+			}
190 190
 
191
-            $meta_value[] = $prev_hidden;
192
-            $save = true;
193
-            unset($form_prefix);
194
-        }
191
+			$meta_value[] = $prev_hidden;
192
+			$save = true;
193
+			unset($form_prefix);
194
+		}
195 195
 
196 196
 		if ( $save ) {
197
-            $user = wp_get_current_user();
197
+			$user = wp_get_current_user();
198 198
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
199
-        }
200
-    }
199
+		}
200
+	}
201 201
 
202 202
 	public static function save_per_page( $save, $option, $value ) {
203
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
-            $save = (int) $value;
205
-        }
206
-        return $save;
207
-    }
203
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
+			$save = (int) $value;
205
+		}
206
+		return $save;
207
+	}
208 208
 
209 209
 	public static function sortable_columns() {
210 210
 		$form_id = FrmForm::get_current_form_id();
@@ -230,46 +230,46 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	public static function hidden_columns( $result ) {
233
-        global $frm_vars;
233
+		global $frm_vars;
234 234
 
235 235
 		$form_id = FrmForm::get_current_form_id();
236 236
 
237
-        $return = false;
238
-        foreach ( (array) $result as $r ) {
239
-            if ( ! empty( $r ) ) {
240
-                $form_prefix = explode( '_', $r );
241
-                $form_prefix = $form_prefix[0];
237
+		$return = false;
238
+		foreach ( (array) $result as $r ) {
239
+			if ( ! empty( $r ) ) {
240
+				$form_prefix = explode( '_', $r );
241
+				$form_prefix = $form_prefix[0];
242 242
 
243
-                if ( (int) $form_prefix == (int) $form_id ) {
244
-                    $return = true;
245
-                    break;
246
-                }
243
+				if ( (int) $form_prefix == (int) $form_id ) {
244
+					$return = true;
245
+					break;
246
+				}
247 247
 
248
-                unset($form_prefix);
249
-            }
250
-        }
248
+				unset($form_prefix);
249
+			}
250
+		}
251 251
 
252
-        if ( $return ) {
252
+		if ( $return ) {
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
-        $max_columns = 8;
258
-        if ( $i <= $max_columns ) {
256
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
+		$max_columns = 8;
258
+		if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262
-        global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
-        }
262
+		global $frm_vars;
263
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
+		}
266 266
 
267 267
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
268 268
 		if ( $has_custom_hidden_columns ) {
269
-            $result = $frm_vars['current_form']->options['hidden_cols'];
270
-        } else {
271
-            $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
269
+			$result = $frm_vars['current_form']->options['hidden_cols'];
270
+		} else {
271
+			$cols = $frm_vars['cols'];
272
+			$cols = array_reverse($cols, true);
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
@@ -277,59 +277,59 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+			$i--;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283
-                if ( $i > $max_columns ) {
283
+				if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286
-                //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
289
-            }
290
-        }
286
+				//remove some columns by default
287
+				$i--;
288
+				unset($col_key, $col);
289
+			}
290
+		}
291 291
 
292
-        return $result;
293
-    }
292
+		return $result;
293
+	}
294 294
 
295 295
 	public static function display_list( $message = '', $errors = array() ) {
296
-        global $wpdb, $frm_vars;
296
+		global $wpdb, $frm_vars;
297 297
 
298 298
 		$form = FrmForm::maybe_get_current_form();
299 299
 		$params = FrmForm::get_admin_params( $form );
300 300
 
301
-        if ( $form ) {
302
-            $params['form'] = $form->id;
303
-            $frm_vars['current_form'] = $form;
301
+		if ( $form ) {
302
+			$params['form'] = $form->id;
303
+			$frm_vars['current_form'] = $form;
304 304
 
305 305
 			self::get_delete_form_time( $form, $errors );
306 306
 		}
307 307
 
308
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
308
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
309 309
 
310
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
310
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
311 311
 
312
-        $pagenum = $wp_list_table->get_pagenum();
312
+		$pagenum = $wp_list_table->get_pagenum();
313 313
 
314
-        $wp_list_table->prepare_items();
314
+		$wp_list_table->prepare_items();
315 315
 
316
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
316
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319
-            if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
321
-            } else {
322
-                wp_redirect( esc_url_raw( $url ) );
323
-            }
324
-            die();
325
-        }
326
-
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
328
-            $message = __( 'Your import is complete', 'formidable' );
329
-        }
319
+			if ( headers_sent() ) {
320
+				echo FrmAppHelper::js_redirect($url);
321
+			} else {
322
+				wp_redirect( esc_url_raw( $url ) );
323
+			}
324
+			die();
325
+		}
326
+
327
+		if ( empty($message) && isset($_GET['import-message']) ) {
328
+			$message = __( 'Your import is complete', 'formidable' );
329
+		}
330 330
 
331 331
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
332
-    }
332
+	}
333 333
 
334 334
 	private static function get_delete_form_time( $form, &$errors ) {
335 335
 		if ( 'trash' == $form->status ) {
@@ -339,19 +339,19 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 	}
341 341
 
342
-    /* Back End CRUD */
342
+	/* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+		FrmAppHelper::permission_check('frm_view_entries');
345 345
 
346
-        if ( ! $id ) {
346
+		if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
348 348
 
349
-            if ( ! $id ) {
349
+			if ( ! $id ) {
350 350
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
351
-            }
352
-        }
351
+			}
352
+		}
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+		$entry = FrmEntry::getOne($id, true);
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,110 +359,110 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+		$data = maybe_unserialize($entry->description);
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
366 366
 
367 367
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
368
-        $to_emails = array();
368
+		$to_emails = array();
369 369
 
370 370
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
371
-    }
371
+	}
372 372
 
373
-    public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
373
+	public static function destroy() {
374
+		FrmAppHelper::permission_check('frm_delete_entries');
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
-            //unlink entry from post
380
-            global $wpdb;
378
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
+			//unlink entry from post
380
+			global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
382
-        }
382
+		}
383 383
 
384
-        $message = '';
385
-        if ( FrmEntry::destroy( $params['id'] ) ) {
386
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
-        }
384
+		$message = '';
385
+		if ( FrmEntry::destroy( $params['id'] ) ) {
386
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
+		}
388 388
 
389
-        self::display_list( $message );
390
-    }
389
+		self::display_list( $message );
390
+	}
391 391
 
392
-    public static function destroy_all() {
393
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
-            $frm_settings = FrmAppHelper::get_settings();
395
-            wp_die( $frm_settings->admin_permission );
396
-        }
392
+	public static function destroy_all() {
393
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
+			$frm_settings = FrmAppHelper::get_settings();
395
+			wp_die( $frm_settings->admin_permission );
396
+		}
397 397
 
398
-        global $wpdb;
398
+		global $wpdb;
399 399
 		$params = FrmForm::get_admin_params();
400
-        $message = '';
401
-        $errors = array();
402
-        $form_id = (int) $params['form'];
400
+		$message = '';
401
+		$errors = array();
402
+		$form_id = (int) $params['form'];
403 403
 
404
-        if ( $form_id ) {
405
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
404
+		if ( $form_id ) {
405
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
406 406
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
407 407
 
408
-            if ( $action ) {
409
-                // this action takes a while, so only trigger it if there are posts to delete
410
-                foreach ( $entry_ids as $entry_id ) {
411
-                    do_action( 'frm_before_destroy_entry', $entry_id );
412
-                    unset( $entry_id );
413
-                }
414
-            }
415
-
416
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
417
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
-            if ( $results ) {
408
+			if ( $action ) {
409
+				// this action takes a while, so only trigger it if there are posts to delete
410
+				foreach ( $entry_ids as $entry_id ) {
411
+					do_action( 'frm_before_destroy_entry', $entry_id );
412
+					unset( $entry_id );
413
+				}
414
+			}
415
+
416
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
417
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
+			if ( $results ) {
419 419
 				FrmEntry::clear_cache();
420
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
-            }
422
-        } else {
423
-            $errors = __( 'No entries were specified', 'formidable' );
424
-        }
425
-
426
-        self::display_list( $message, $errors );
427
-    }
428
-
429
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
-        return FrmFormsController::show_form( $id, $key, $title, $description );
432
-    }
433
-
434
-    public static function get_form( $filename, $form, $title, $description ) {
435
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
-        return FrmFormsController::get_form( $form, $title, $description );
437
-    }
438
-
439
-    public static function process_entry( $errors = '', $ajax = false ) {
420
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
+			}
422
+		} else {
423
+			$errors = __( 'No entries were specified', 'formidable' );
424
+		}
425
+
426
+		self::display_list( $message, $errors );
427
+	}
428
+
429
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
+		return FrmFormsController::show_form( $id, $key, $title, $description );
432
+	}
433
+
434
+	public static function get_form( $filename, $form, $title, $description ) {
435
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
+		return FrmFormsController::get_form( $form, $title, $description );
437
+	}
438
+
439
+	public static function process_entry( $errors = '', $ajax = false ) {
440 440
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
441 441
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
442
-            return;
443
-        }
442
+			return;
443
+		}
444 444
 
445
-        global $frm_vars;
445
+		global $frm_vars;
446 446
 
447 447
 		$form = FrmForm::getOne( $form_id );
448
-        if ( ! $form ) {
449
-            return;
450
-        }
448
+		if ( ! $form ) {
449
+			return;
450
+		}
451 451
 
452 452
 		$params = FrmForm::get_params( $form );
453 453
 
454
-        if ( ! isset( $frm_vars['form_params'] ) ) {
455
-            $frm_vars['form_params'] = array();
456
-        }
454
+		if ( ! isset( $frm_vars['form_params'] ) ) {
455
+			$frm_vars['form_params'] = array();
456
+		}
457 457
 		$frm_vars['form_params'][ $form->id ] = $params;
458 458
 
459 459
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
460
-            return;
461
-        }
460
+			return;
461
+		}
462 462
 
463
-        if ( $errors == '' && ! $ajax ) {
463
+		if ( $errors == '' && ! $ajax ) {
464 464
 			$errors = FrmEntryValidate::validate( $_POST );
465
-        }
465
+		}
466 466
 
467 467
 		/**
468 468
 		 * Use this filter to add trigger actions and add errors after
@@ -473,39 +473,39 @@  discard block
 block discarded – undo
473 473
 
474 474
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
475 475
 
476
-        if ( empty( $errors ) ) {
476
+		if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478
-            if ( $params['action'] == 'create' ) {
478
+			if ( $params['action'] == 'create' ) {
479 479
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480 480
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
481
-                }
482
-            }
481
+				}
482
+			}
483 483
 
484
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
484
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
485 485
 			unset( $_POST['frm_skip_cookie'] );
486
-        }
487
-    }
488
-
489
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
-        self::_delete_entry( $atts['id'], $form );
491
-        return $url;
492
-    }
493
-
494
-    //Delete entry if not redirected
495
-    public static function delete_entry_after_save( $atts ) {
496
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
-    }
498
-
499
-    private static function _delete_entry( $entry_id, $form ) {
500
-        if ( ! $form ) {
501
-            return;
502
-        }
503
-
504
-        $form->options = maybe_unserialize( $form->options );
505
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
-            FrmEntry::destroy( $entry_id );
507
-        }
508
-    }
486
+		}
487
+	}
488
+
489
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
+		self::_delete_entry( $atts['id'], $form );
491
+		return $url;
492
+	}
493
+
494
+	//Delete entry if not redirected
495
+	public static function delete_entry_after_save( $atts ) {
496
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
+	}
498
+
499
+	private static function _delete_entry( $entry_id, $form ) {
500
+		if ( ! $form ) {
501
+			return;
502
+		}
503
+
504
+		$form->options = maybe_unserialize( $form->options );
505
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
+			FrmEntry::destroy( $entry_id );
507
+		}
508
+	}
509 509
 
510 510
 	/**
511 511
 	 * @param $atts
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 	}
561 561
 
562 562
 	public static function entry_sidebar( $entry ) {
563
-        $data = maybe_unserialize($entry->description);
564
-        $date_format = get_option('date_format');
565
-        $time_format = get_option('time_format');
563
+		$data = maybe_unserialize($entry->description);
564
+		$date_format = get_option('date_format');
565
+		$time_format = get_option('time_format');
566 566
 		if ( isset( $data['browser'] ) ) {
567 567
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
568 568
 		}
569 569
 
570 570
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
571
-    }
571
+	}
572 572
 
573 573
 	/***********************************************************************
574 574
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-		$columns[ $form_id . '_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+		$columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
 		if ( $form_id ) {
75 75
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84
-		$columns[ $form_id . '_ip' ] = 'IP';
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84
+		$columns[$form_id . '_ip'] = 'IP';
85 85
 
86 86
         $frm_vars['cols'] = $columns;
87 87
 
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
125 125
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
126 126
 				if ( $has_separate_value && ! $is_post_status ) {
127
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 				}
129
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
129
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
130 130
 			}
131 131
 		}
132 132
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         global $frm_vars;
146 146
         //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149 149
         return $check;
150 150
     }
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
163 163
             return; //don't continue if there's no previous value
164 164
         }
165 165
 
166 166
         foreach ( $meta_value as $mk => $mv ) {
167 167
             //remove blank values
168 168
             if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
169
+                unset( $meta_value[$mk] );
170 170
             }
171 171
         }
172 172
 
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
173
+        $cur_form_prefix = reset( $meta_value );
174
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
175 175
         $cur_form_prefix = $cur_form_prefix[0];
176 176
         $save = false;
177 177
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
             $meta_value[] = $prev_hidden;
192 192
             $save = true;
193
-            unset($form_prefix);
193
+            unset( $form_prefix );
194 194
         }
195 195
 
196 196
 		if ( $save ) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		foreach ( $fields as $field ) {
223 223
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
224 224
 				// Can't sort on checkboxes because they are stored serialized, or post fields
225
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
225
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
226 226
 			}
227 227
 		}
228 228
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     break;
246 246
                 }
247 247
 
248
-                unset($form_prefix);
248
+                unset( $form_prefix );
249 249
             }
250 250
         }
251 251
 
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
257 257
         $max_columns = 8;
258 258
         if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262 262
         global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
263
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
264
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
265 265
         }
266 266
 
267 267
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
             $result = $frm_vars['current_form']->options['hidden_cols'];
270 270
         } else {
271 271
             $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
272
+            $cols = array_reverse( $cols, true );
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
276
-				$i--;
276
+				$i --;
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+            $i --;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283 283
                 if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286 286
                 //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
287
+                $i --;
288
+                unset( $col_key, $col );
289 289
             }
290 290
         }
291 291
 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319 319
             if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
320
+                echo FrmAppHelper::js_redirect( $url );
321 321
             } else {
322 322
                 wp_redirect( esc_url_raw( $url ) );
323 323
             }
324 324
             die();
325 325
         }
326 326
 
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
327
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
328 328
             $message = __( 'Your import is complete', 'formidable' );
329 329
         }
330 330
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     /* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+        FrmAppHelper::permission_check( 'frm_view_entries' );
345 345
 
346 346
         if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+        $entry = FrmEntry::getOne( $id, true );
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+        $data = maybe_unserialize( $entry->description );
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
374
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
379 379
             //unlink entry from post
380 380
             global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
         if ( ! isset( $frm_vars['form_params'] ) ) {
455 455
             $frm_vars['form_params'] = array();
456 456
         }
457
-		$frm_vars['form_params'][ $form->id ] = $params;
457
+		$frm_vars['form_params'][$form->id] = $params;
458 458
 
459
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
459
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
460 460
             return;
461 461
         }
462 462
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 		 */
472 472
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
473 473
 
474
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
474
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
475 475
 
476 476
         if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478 478
             if ( $params['action'] == 'create' ) {
479
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
479
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
480
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
481 481
                 }
482 482
             }
483 483
 
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
 	}
561 561
 
562 562
 	public static function entry_sidebar( $entry ) {
563
-        $data = maybe_unserialize($entry->description);
564
-        $date_format = get_option('date_format');
565
-        $time_format = get_option('time_format');
563
+        $data = maybe_unserialize( $entry->description );
564
+        $date_format = get_option( 'date_format' );
565
+        $time_format = get_option( 'time_format' );
566 566
 		if ( isset( $data['browser'] ) ) {
567 567
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
568 568
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +1017 added lines, -1017 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.03.11a1';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -69,83 +69,83 @@  discard block
 block discarded – undo
69 69
 		return '';
70 70
 	}
71 71
 
72
-    /**
73
-     * Get the Formidable settings
74
-     *
75
-     * @since 2.0
76
-     *
77
-     * @param None
78
-     * @return FrmSettings $frm_setings
79
-     */
80
-    public static function get_settings() {
81
-        global $frm_settings;
82
-        if ( empty($frm_settings) ) {
83
-            $frm_settings = new FrmSettings();
84
-        }
85
-        return $frm_settings;
86
-    }
72
+	/**
73
+	 * Get the Formidable settings
74
+	 *
75
+	 * @since 2.0
76
+	 *
77
+	 * @param None
78
+	 * @return FrmSettings $frm_setings
79
+	 */
80
+	public static function get_settings() {
81
+		global $frm_settings;
82
+		if ( empty($frm_settings) ) {
83
+			$frm_settings = new FrmSettings();
84
+		}
85
+		return $frm_settings;
86
+	}
87 87
 
88 88
 	public static function get_menu_name() {
89 89
 		$frm_settings = FrmAppHelper::get_settings();
90 90
 		return $frm_settings->menu;
91 91
 	}
92 92
 
93
-    /**
94
-     * Show a message in place of pro features
95
-     *
96
-     * @since 2.0
97
-     */
93
+	/**
94
+	 * Show a message in place of pro features
95
+	 *
96
+	 * @since 2.0
97
+	 */
98 98
 	public static function update_message() {
99 99
 		_deprecated_function( __FUNCTION__, '2.0.19' );
100
-    }
101
-
102
-    public static function pro_is_installed() {
103
-        return apply_filters('frm_pro_installed', false);
104
-    }
105
-
106
-    /**
107
-     * Check for certain page in Formidable settings
108
-     *
109
-     * @since 2.0
110
-     *
111
-     * @param string $page The name of the page to check
112
-     * @return boolean
113
-     */
100
+	}
101
+
102
+	public static function pro_is_installed() {
103
+		return apply_filters('frm_pro_installed', false);
104
+	}
105
+
106
+	/**
107
+	 * Check for certain page in Formidable settings
108
+	 *
109
+	 * @since 2.0
110
+	 *
111
+	 * @param string $page The name of the page to check
112
+	 * @return boolean
113
+	 */
114 114
 	public static function is_admin_page( $page = 'formidable' ) {
115
-        global $pagenow;
115
+		global $pagenow;
116 116
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
117
-        if ( $pagenow ) {
117
+		if ( $pagenow ) {
118 118
 			return $pagenow == 'admin.php' && $get_page == $page;
119
-        }
119
+		}
120 120
 
121 121
 		return is_admin() && $get_page == $page;
122
-    }
123
-
124
-    /**
125
-     * Check for the form preview page
126
-     *
127
-     * @since 2.0
128
-     *
129
-     * @param None
130
-     * @return boolean
131
-     */
132
-    public static function is_preview_page() {
133
-        global $pagenow;
122
+	}
123
+
124
+	/**
125
+	 * Check for the form preview page
126
+	 *
127
+	 * @since 2.0
128
+	 *
129
+	 * @param None
130
+	 * @return boolean
131
+	 */
132
+	public static function is_preview_page() {
133
+		global $pagenow;
134 134
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
135 135
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
136
-    }
136
+	}
137 137
 
138
-    /**
139
-     * Check for ajax except the form preview page
140
-     *
141
-     * @since 2.0
142
-     *
143
-     * @param None
144
-     * @return boolean
145
-     */
146
-    public static function doing_ajax() {
147
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
148
-    }
138
+	/**
139
+	 * Check for ajax except the form preview page
140
+	 *
141
+	 * @since 2.0
142
+	 *
143
+	 * @param None
144
+	 * @return boolean
145
+	 */
146
+	public static function doing_ajax() {
147
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
148
+	}
149 149
 
150 150
 	/**
151 151
 	 * @since 2.0.8
@@ -155,102 +155,102 @@  discard block
 block discarded – undo
155 155
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
156 156
 	}
157 157
 
158
-    /**
159
-     * Check if on an admin page
160
-     *
161
-     * @since 2.0
162
-     *
163
-     * @param None
164
-     * @return boolean
165
-     */
166
-    public static function is_admin() {
167
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
168
-    }
169
-
170
-    /**
171
-     * Check if value contains blank value or empty array
172
-     *
173
-     * @since 2.0
174
-     * @param mixed $value - value to check
158
+	/**
159
+	 * Check if on an admin page
160
+	 *
161
+	 * @since 2.0
162
+	 *
163
+	 * @param None
164
+	 * @return boolean
165
+	 */
166
+	public static function is_admin() {
167
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
168
+	}
169
+
170
+	/**
171
+	 * Check if value contains blank value or empty array
172
+	 *
173
+	 * @since 2.0
174
+	 * @param mixed $value - value to check
175 175
 	 * @param string
176
-     * @return boolean
177
-     */
178
-    public static function is_empty_value( $value, $empty = '' ) {
179
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
-    }
181
-
182
-    public static function is_not_empty_value( $value, $empty = '' ) {
183
-        return ! self::is_empty_value( $value, $empty );
184
-    }
185
-
186
-    /**
187
-     * Get any value from the $_SERVER
188
-     *
189
-     * @since 2.0
190
-     * @param string $value
191
-     * @return string
192
-     */
176
+	 * @return boolean
177
+	 */
178
+	public static function is_empty_value( $value, $empty = '' ) {
179
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
+	}
181
+
182
+	public static function is_not_empty_value( $value, $empty = '' ) {
183
+		return ! self::is_empty_value( $value, $empty );
184
+	}
185
+
186
+	/**
187
+	 * Get any value from the $_SERVER
188
+	 *
189
+	 * @since 2.0
190
+	 * @param string $value
191
+	 * @return string
192
+	 */
193 193
 	public static function get_server_value( $value ) {
194
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
-    }
196
-
197
-    /**
198
-     * Check for the IP address in several places
199
-     * Used by [ip] shortcode
200
-     *
201
-     * @return string The IP address of the current user
202
-     */
203
-    public static function get_ip_address() {
194
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
+	}
196
+
197
+	/**
198
+	 * Check for the IP address in several places
199
+	 * Used by [ip] shortcode
200
+	 *
201
+	 * @return string The IP address of the current user
202
+	 */
203
+	public static function get_ip_address() {
204 204
 		$ip = '';
205
-        foreach ( array(
206
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
-        ) as $key ) {
209
-            if ( ! isset( $_SERVER[ $key ] ) ) {
210
-                continue;
211
-            }
212
-
213
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
-                $ip = trim($ip); // just to be safe
215
-
216
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
-                    return $ip;
218
-                }
219
-            }
220
-        }
205
+		foreach ( array(
206
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
+		) as $key ) {
209
+			if ( ! isset( $_SERVER[ $key ] ) ) {
210
+				continue;
211
+			}
212
+
213
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
+				$ip = trim($ip); // just to be safe
215
+
216
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
+					return $ip;
218
+				}
219
+			}
220
+		}
221 221
 
222 222
 		return sanitize_text_field( $ip );
223
-    }
223
+	}
224 224
 
225
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
-        if ( strpos($param, '[') ) {
227
-            $params = explode('[', $param);
228
-            $param = $params[0];
229
-        }
225
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
+		if ( strpos($param, '[') ) {
227
+			$params = explode('[', $param);
228
+			$param = $params[0];
229
+		}
230 230
 
231 231
 		if ( $src == 'get' ) {
232
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
235
-            }
232
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
235
+			}
236 236
 			self::sanitize_value( $sanitize, $value );
237 237
 		} else {
238
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
-        }
238
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
+		}
240 240
 
241 241
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
242
-            foreach ( $params as $k => $p ) {
243
-                if ( ! $k || ! is_array($value) ) {
244
-                    continue;
245
-                }
242
+			foreach ( $params as $k => $p ) {
243
+				if ( ! $k || ! is_array($value) ) {
244
+					continue;
245
+				}
246 246
 
247
-                $p = trim($p, ']');
248
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
-            }
250
-        }
247
+				$p = trim($p, ']');
248
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
+			}
250
+		}
251 251
 
252
-        return $value;
253
-    }
252
+		return $value;
253
+	}
254 254
 
255 255
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
256 256
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
268 268
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
269
-    }
269
+	}
270 270
 
271 271
 	/**
272 272
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 	}
303 303
 
304 304
 	/**
305
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
306
-	*
307
-	* @since 2.0.8
308
-	* @param string $value
309
-	* @return string $value
310
-	*/
305
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
306
+	 *
307
+	 * @since 2.0.8
308
+	 * @param string $value
309
+	 * @return string $value
310
+	 */
311 311
 	public static function preserve_backslashes( $value ) {
312 312
 		// If backslashes have already been added, don't add them again
313 313
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 	}
331 331
 
332
-    public static function sanitize_request( $sanitize_method, &$values ) {
333
-        $temp_values = $values;
334
-        foreach ( $temp_values as $k => $val ) {
335
-            if ( isset( $sanitize_method[ $k ] ) ) {
332
+	public static function sanitize_request( $sanitize_method, &$values ) {
333
+		$temp_values = $values;
334
+		foreach ( $temp_values as $k => $val ) {
335
+			if ( isset( $sanitize_method[ $k ] ) ) {
336 336
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
337
-            }
338
-        }
339
-    }
337
+			}
338
+		}
339
+	}
340 340
 
341 341
 	public static function sanitize_array( &$values ) {
342 342
 		$temp_values = $values;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	public static function kses( $value, $allowed = array() ) {
356 356
 		$html = array(
357
-		    'a' => array(
357
+			'a' => array(
358 358
 				'href'  => array(),
359 359
 				'title' => array(),
360 360
 				'id'    => array(),
361 361
 				'class' => array(),
362
-		    ),
362
+			),
363 363
 		);
364 364
 
365 365
 		$allowed_html = array();
@@ -370,77 +370,77 @@  discard block
 block discarded – undo
370 370
 		return wp_kses( $value, $allowed_html );
371 371
 	}
372 372
 
373
-    /**
374
-     * Used when switching the action for a bulk action
375
-     * @since 2.0
376
-     */
377
-    public static function remove_get_action() {
378
-        if ( ! isset($_GET) ) {
379
-            return;
380
-        }
373
+	/**
374
+	 * Used when switching the action for a bulk action
375
+	 * @since 2.0
376
+	 */
377
+	public static function remove_get_action() {
378
+		if ( ! isset($_GET) ) {
379
+			return;
380
+		}
381 381
 
382
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
383
-        if ( ! empty( $new_action ) ) {
382
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
383
+		if ( ! empty( $new_action ) ) {
384 384
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
385
-        }
386
-    }
387
-
388
-    /**
389
-     * Check the WP query for a parameter
390
-     *
391
-     * @since 2.0
392
-     * @return string|array
393
-     */
394
-    public static function get_query_var( $value, $param ) {
395
-        if ( $value != '' ) {
396
-            return $value;
397
-        }
398
-
399
-        global $wp_query;
400
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
401
-            $value = $wp_query->query_vars[ $param ];
402
-        }
403
-
404
-        return $value;
405
-    }
406
-
407
-    /**
408
-     * @param string $type
409
-     */
410
-    public static function trigger_hook_load( $type, $object = null ) {
411
-        // only load the form hooks once
385
+		}
386
+	}
387
+
388
+	/**
389
+	 * Check the WP query for a parameter
390
+	 *
391
+	 * @since 2.0
392
+	 * @return string|array
393
+	 */
394
+	public static function get_query_var( $value, $param ) {
395
+		if ( $value != '' ) {
396
+			return $value;
397
+		}
398
+
399
+		global $wp_query;
400
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
401
+			$value = $wp_query->query_vars[ $param ];
402
+		}
403
+
404
+		return $value;
405
+	}
406
+
407
+	/**
408
+	 * @param string $type
409
+	 */
410
+	public static function trigger_hook_load( $type, $object = null ) {
411
+		// only load the form hooks once
412 412
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
413
-        if ( ! $hooks_loaded ) {
413
+		if ( ! $hooks_loaded ) {
414 414
 			do_action( 'frm_load_' . $type . '_hooks' );
415
-        }
416
-    }
417
-
418
-    /**
419
-     * Check cache before fetching values and saving to cache
420
-     *
421
-     * @since 2.0
422
-     *
423
-     * @param string $cache_key The unique name for this cache
424
-     * @param string $group The name of the cache group
425
-     * @param string $query If blank, don't run a db call
426
-     * @param string $type The wpdb function to use with this query
427
-     * @return mixed $results The cache or query results
428
-     */
429
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
430
-        $results = wp_cache_get($cache_key, $group);
431
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
432
-            return $results;
433
-        }
434
-
435
-        if ( 'get_posts' == $type ) {
436
-            $results = get_posts($query);
415
+		}
416
+	}
417
+
418
+	/**
419
+	 * Check cache before fetching values and saving to cache
420
+	 *
421
+	 * @since 2.0
422
+	 *
423
+	 * @param string $cache_key The unique name for this cache
424
+	 * @param string $group The name of the cache group
425
+	 * @param string $query If blank, don't run a db call
426
+	 * @param string $type The wpdb function to use with this query
427
+	 * @return mixed $results The cache or query results
428
+	 */
429
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
430
+		$results = wp_cache_get($cache_key, $group);
431
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
432
+			return $results;
433
+		}
434
+
435
+		if ( 'get_posts' == $type ) {
436
+			$results = get_posts($query);
437 437
 		} else if ( 'get_associative_results' == $type ) {
438 438
 			global $wpdb;
439 439
 			$results = $wpdb->get_results( $query, OBJECT_K );
440
-        } else {
441
-            global $wpdb;
442
-            $results = $wpdb->{$type}($query);
443
-        }
440
+		} else {
441
+			global $wpdb;
442
+			$results = $wpdb->{$type}($query);
443
+		}
444 444
 
445 445
 		self::set_cache( $cache_key, $results, $group, $time );
446 446
 
@@ -473,44 +473,44 @@  discard block
 block discarded – undo
473 473
 		return $cached;
474 474
 	}
475 475
 
476
-    /**
477
-     * Data that should be stored for a long time can be stored in a transient.
478
-     * First check the cache, then check the transient
479
-     * @since 2.0
480
-     * @return mixed The cached value or false
481
-     */
476
+	/**
477
+	 * Data that should be stored for a long time can be stored in a transient.
478
+	 * First check the cache, then check the transient
479
+	 * @since 2.0
480
+	 * @return mixed The cached value or false
481
+	 */
482 482
 	public static function check_cache_and_transient( $cache_key ) {
483
-        // check caching layer first
484
-        $results = self::check_cache( $cache_key );
485
-        if ( $results ) {
486
-            return $results;
487
-        }
488
-
489
-        // then check the transient
490
-        $results = get_transient($cache_key);
491
-        if ( $results ) {
492
-            wp_cache_set($cache_key, $results);
493
-        }
494
-
495
-        return $results;
496
-    }
497
-
498
-    /**
499
-     * @since 2.0
500
-     * @param string $cache_key
501
-     */
483
+		// check caching layer first
484
+		$results = self::check_cache( $cache_key );
485
+		if ( $results ) {
486
+			return $results;
487
+		}
488
+
489
+		// then check the transient
490
+		$results = get_transient($cache_key);
491
+		if ( $results ) {
492
+			wp_cache_set($cache_key, $results);
493
+		}
494
+
495
+		return $results;
496
+	}
497
+
498
+	/**
499
+	 * @since 2.0
500
+	 * @param string $cache_key
501
+	 */
502 502
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
503 503
 		delete_transient($cache_key);
504 504
 		wp_cache_delete( $cache_key, $group );
505 505
 	}
506 506
 
507
-    /**
508
-     * Delete all caching in a single group
509
-     *
510
-     * @since 2.0
511
-     *
512
-     * @param string $group The name of the cache group
513
-     */
507
+	/**
508
+	 * Delete all caching in a single group
509
+	 *
510
+	 * @since 2.0
511
+	 *
512
+	 * @param string $group The name of the cache group
513
+	 */
514 514
 	public static function cache_delete_group( $group ) {
515 515
 		$cached_keys = self::get_group_cached_keys( $group );
516 516
 
@@ -523,34 +523,34 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 	}
525 525
 
526
-    /**
527
-     * Check a value from a shortcode to see if true or false.
528
-     * True when value is 1, true, 'true', 'yes'
529
-     *
530
-     * @since 1.07.10
531
-     *
532
-     * @param string $value The value to compare
533
-     * @return boolean True or False
534
-     */
526
+	/**
527
+	 * Check a value from a shortcode to see if true or false.
528
+	 * True when value is 1, true, 'true', 'yes'
529
+	 *
530
+	 * @since 1.07.10
531
+	 *
532
+	 * @param string $value The value to compare
533
+	 * @return boolean True or False
534
+	 */
535 535
 	public static function is_true( $value ) {
536
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
537
-    }
536
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
537
+	}
538 538
 
539
-    /**
540
-     * Used to filter shortcode in text widgets
541
-     */
542
-    public static function widget_text_filter_callback( $matches ) {
543
-        return do_shortcode( $matches[0] );
544
-    }
539
+	/**
540
+	 * Used to filter shortcode in text widgets
541
+	 */
542
+	public static function widget_text_filter_callback( $matches ) {
543
+		return do_shortcode( $matches[0] );
544
+	}
545 545
 
546
-    public static function get_pages() {
546
+	public static function get_pages() {
547 547
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
548
-    }
548
+	}
549 549
 
550
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
551
-        $pages = self::get_pages();
550
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
551
+		$pages = self::get_pages();
552 552
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
553
-    ?>
553
+	?>
554 554
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
555 555
             <option value=""> </option>
556 556
             <?php foreach ( $pages as $page ) { ?>
@@ -560,108 +560,108 @@  discard block
 block discarded – undo
560 560
             <?php } ?>
561 561
         </select>
562 562
     <?php
563
-    }
563
+	}
564 564
 
565 565
 	public static function post_edit_link( $post_id ) {
566
-        $post = get_post($post_id);
567
-        if ( $post ) {
566
+		$post = get_post($post_id);
567
+		if ( $post ) {
568 568
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
569 569
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
570
-        }
571
-        return '';
572
-    }
570
+		}
571
+		return '';
572
+	}
573 573
 
574 574
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
575
-    ?>
575
+	?>
576 576
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
577
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
578
-            ?> class="frm_multiselect">
577
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
578
+			?> class="frm_multiselect">
579 579
             <?php self::roles_options($capability); ?>
580 580
         </select>
581 581
     <?php
582
-    }
582
+	}
583 583
 
584 584
 	public static function roles_options( $capability ) {
585
-        global $frm_vars;
586
-        if ( isset($frm_vars['editable_roles']) ) {
587
-            $editable_roles = $frm_vars['editable_roles'];
588
-        } else {
589
-            $editable_roles = get_editable_roles();
590
-            $frm_vars['editable_roles'] = $editable_roles;
591
-        }
592
-
593
-        foreach ( $editable_roles as $role => $details ) {
594
-            $name = translate_user_role($details['name'] ); ?>
585
+		global $frm_vars;
586
+		if ( isset($frm_vars['editable_roles']) ) {
587
+			$editable_roles = $frm_vars['editable_roles'];
588
+		} else {
589
+			$editable_roles = get_editable_roles();
590
+			$frm_vars['editable_roles'] = $editable_roles;
591
+		}
592
+
593
+		foreach ( $editable_roles as $role => $details ) {
594
+			$name = translate_user_role($details['name'] ); ?>
595 595
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
596 596
 <?php
597
-            unset($role, $details);
598
-        }
599
-    }
597
+			unset($role, $details);
598
+		}
599
+	}
600 600
 
601 601
 	public static function frm_capabilities( $type = 'auto' ) {
602
-        $cap = array(
603
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
604
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
605
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
606
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
607
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
608
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
609
-        );
602
+		$cap = array(
603
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
604
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
605
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
606
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
607
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
608
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
609
+		);
610 610
 
611 611
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
612
-            return $cap;
613
-        }
612
+			return $cap;
613
+		}
614 614
 
615
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
616
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
617
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
618
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
615
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
616
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
617
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
618
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
619 619
 
620
-        return $cap;
621
-    }
620
+		return $cap;
621
+	}
622 622
 
623 623
 	public static function user_has_permission( $needed_role ) {
624
-        if ( $needed_role == '-1' ) {
625
-            return false;
624
+		if ( $needed_role == '-1' ) {
625
+			return false;
626 626
 		}
627 627
 
628
-        // $needed_role will be equal to blank if "Logged-in users" is selected
629
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
630
-            return true;
631
-        }
628
+		// $needed_role will be equal to blank if "Logged-in users" is selected
629
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
630
+			return true;
631
+		}
632 632
 
633
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
634
-        foreach ( $roles as $role ) {
633
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
634
+		foreach ( $roles as $role ) {
635 635
 			if ( current_user_can( $role ) ) {
636
-        		return true;
636
+				return true;
637 637
 			}
638
-        	if ( $role == $needed_role ) {
639
-        		break;
638
+			if ( $role == $needed_role ) {
639
+				break;
640 640
 			}
641
-        }
642
-        return false;
643
-    }
644
-
645
-    /**
646
-     * Make sure administrators can see Formidable menu
647
-     *
648
-     * @since 2.0
649
-     */
650
-    public static function maybe_add_permissions() {
641
+		}
642
+		return false;
643
+	}
644
+
645
+	/**
646
+	 * Make sure administrators can see Formidable menu
647
+	 *
648
+	 * @since 2.0
649
+	 */
650
+	public static function maybe_add_permissions() {
651 651
 		self::force_capability( 'frm_view_entries' );
652 652
 
653
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
654
-            return;
655
-        }
653
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
654
+			return;
655
+		}
656 656
 
657 657
 		$user_id = get_current_user_id();
658 658
 		$user = new WP_User( $user_id );
659
-        $frm_roles = self::frm_capabilities();
660
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
659
+		$frm_roles = self::frm_capabilities();
660
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
661 661
 			$user->add_cap( $frm_role );
662
-            unset($frm_role, $frm_role_description);
663
-        }
664
-    }
662
+			unset($frm_role, $frm_role_description);
663
+		}
664
+	}
665 665
 
666 666
 	/**
667 667
 	 * Make sure admins have permission to see the menu items
@@ -677,28 +677,28 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 	}
679 679
 
680
-    /**
681
-     * Check if the user has permision for action.
682
-     * Return permission message and stop the action if no permission
683
-     * @since 2.0
684
-     * @param string $permission
685
-     */
680
+	/**
681
+	 * Check if the user has permision for action.
682
+	 * Return permission message and stop the action if no permission
683
+	 * @since 2.0
684
+	 * @param string $permission
685
+	 */
686 686
 	public static function permission_check( $permission, $show_message = 'show' ) {
687
-        $permission_error = self::permission_nonce_error($permission);
688
-        if ( $permission_error !== false ) {
689
-            if ( 'hide' == $show_message ) {
690
-                $permission_error = '';
691
-            }
692
-            wp_die($permission_error);
693
-        }
694
-    }
695
-
696
-    /**
697
-     * Check user permission and nonce
698
-     * @since 2.0
699
-     * @param string $permission
700
-     * @return false|string The permission message or false if allowed
701
-     */
687
+		$permission_error = self::permission_nonce_error($permission);
688
+		if ( $permission_error !== false ) {
689
+			if ( 'hide' == $show_message ) {
690
+				$permission_error = '';
691
+			}
692
+			wp_die($permission_error);
693
+		}
694
+	}
695
+
696
+	/**
697
+	 * Check user permission and nonce
698
+	 * @since 2.0
699
+	 * @param string $permission
700
+	 * @return false|string The permission message or false if allowed
701
+	 */
702 702
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
703 703
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
704 704
 			$frm_settings = self::get_settings();
@@ -706,23 +706,23 @@  discard block
 block discarded – undo
706 706
 		}
707 707
 
708 708
 		$error = false;
709
-        if ( empty($nonce_name) ) {
710
-            return $error;
711
-        }
709
+		if ( empty($nonce_name) ) {
710
+			return $error;
711
+		}
712 712
 
713
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
714
-            $frm_settings = self::get_settings();
715
-            $error = $frm_settings->admin_permission;
716
-        }
713
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
714
+			$frm_settings = self::get_settings();
715
+			$error = $frm_settings->admin_permission;
716
+		}
717 717
 
718
-        return $error;
719
-    }
718
+		return $error;
719
+	}
720 720
 
721
-    public static function checked( $values, $current ) {
721
+	public static function checked( $values, $current ) {
722 722
 		if ( self::check_selected( $values, $current ) ) {
723
-            echo ' checked="checked"';
723
+			echo ' checked="checked"';
724 724
 		}
725
-    }
725
+	}
726 726
 
727 727
 	public static function check_selected( $values, $current ) {
728 728
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -732,50 +732,50 @@  discard block
 block discarded – undo
732 732
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
733 733
 	}
734 734
 
735
-    /**
736
-    * Check if current field option is an "other" option
737
-    *
738
-    * @since 2.0
739
-    *
740
-    * @param string $opt_key
741
-    * @return boolean Returns true if current field option is an "Other" option
742
-    */
743
-    public static function is_other_opt( $opt_key ) {
744
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
745
-        return FrmFieldsHelper::is_other_opt( $opt_key );
746
-    }
747
-
748
-    /**
749
-    * Get value that belongs in "Other" text box
750
-    *
751
-    * @since 2.0
752
-    *
753
-    * @param string $opt_key
754
-    * @param array $field
755
-    * @return string $other_val
756
-    */
757
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
735
+	/**
736
+	 * Check if current field option is an "other" option
737
+	 *
738
+	 * @since 2.0
739
+	 *
740
+	 * @param string $opt_key
741
+	 * @return boolean Returns true if current field option is an "Other" option
742
+	 */
743
+	public static function is_other_opt( $opt_key ) {
744
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
745
+		return FrmFieldsHelper::is_other_opt( $opt_key );
746
+	}
747
+
748
+	/**
749
+	 * Get value that belongs in "Other" text box
750
+	 *
751
+	 * @since 2.0
752
+	 *
753
+	 * @param string $opt_key
754
+	 * @param array $field
755
+	 * @return string $other_val
756
+	 */
757
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
758 758
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
759 759
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
760
-    }
761
-
762
-    /**
763
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
764
-    * Intended for front-end use
765
-    *
766
-    * @since 2.0
767
-    *
768
-    * @param array $field
769
-    * @param boolean $other_opt
770
-    * @param string $checked
771
-    * @param array $args should include opt_key and field name
772
-    * @return string $other_val
773
-    */
774
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
760
+	}
761
+
762
+	/**
763
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
764
+	 * Intended for front-end use
765
+	 *
766
+	 * @since 2.0
767
+	 *
768
+	 * @param array $field
769
+	 * @param boolean $other_opt
770
+	 * @param string $checked
771
+	 * @param array $args should include opt_key and field name
772
+	 * @return string $other_val
773
+	 */
774
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
775 775
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
776 776
 		$args['field'] = $field;
777 777
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
778
-    }
778
+	}
779 779
 
780 780
 	public static function recursive_function_map( $value, $function ) {
781 781
 		if ( is_array( $value ) ) {
@@ -805,24 +805,24 @@  discard block
 block discarded – undo
805 805
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
806 806
 	}
807 807
 
808
-    /**
809
-     * Flatten a multi-dimensional array
810
-     */
808
+	/**
809
+	 * Flatten a multi-dimensional array
810
+	 */
811 811
 	public static function array_flatten( $array, $keys = 'keep' ) {
812
-        $return = array();
813
-        foreach ( $array as $key => $value ) {
814
-            if ( is_array($value) ) {
812
+		$return = array();
813
+		foreach ( $array as $key => $value ) {
814
+			if ( is_array($value) ) {
815 815
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
816
-            } else {
816
+			} else {
817 817
 				if ( $keys == 'keep' ) {
818 818
 					$return[ $key ] = $value;
819 819
 				} else {
820 820
 					$return[] = $value;
821 821
 				}
822
-            }
823
-        }
824
-        return $return;
825
-    }
822
+			}
823
+		}
824
+		return $return;
825
+	}
826 826
 
827 827
 	public static function esc_textarea( $text, $is_rich_text = false ) {
828 828
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -833,38 +833,38 @@  discard block
 block discarded – undo
833 833
 		return apply_filters( 'esc_textarea', $safe_text, $text );
834 834
 	}
835 835
 
836
-    /**
837
-     * Add auto paragraphs to text areas
838
-     * @since 2.0
839
-     */
836
+	/**
837
+	 * Add auto paragraphs to text areas
838
+	 * @since 2.0
839
+	 */
840 840
 	public static function use_wpautop( $content ) {
841
-        if ( apply_filters('frm_use_wpautop', true) ) {
842
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
843
-        }
844
-        return $content;
845
-    }
841
+		if ( apply_filters('frm_use_wpautop', true) ) {
842
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
843
+		}
844
+		return $content;
845
+	}
846 846
 
847 847
 	public static function replace_quotes( $val ) {
848
-        //Replace double quotes
848
+		//Replace double quotes
849 849
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
850
-        //Replace single quotes
851
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
852
-        return $val;
853
-    }
854
-
855
-    /**
856
-     * @since 2.0
857
-     * @return string The base Google APIS url for the current version of jQuery UI
858
-     */
859
-    public static function jquery_ui_base_url() {
850
+		//Replace single quotes
851
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
852
+		return $val;
853
+	}
854
+
855
+	/**
856
+	 * @since 2.0
857
+	 * @return string The base Google APIS url for the current version of jQuery UI
858
+	 */
859
+	public static function jquery_ui_base_url() {
860 860
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
861
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
862
-        return $url;
863
-    }
861
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
862
+		return $url;
863
+	}
864 864
 
865
-    /**
866
-     * @param string $handle
867
-     */
865
+	/**
866
+	 * @param string $handle
867
+	 */
868 868
 	public static function script_version( $handle, $default = 0 ) {
869 869
 		global $wp_scripts;
870 870
 		if ( ! $wp_scripts ) {
@@ -886,241 +886,241 @@  discard block
 block discarded – undo
886 886
 
887 887
 	public static function js_redirect( $url ) {
888 888
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
889
-    }
889
+	}
890 890
 
891 891
 	public static function get_user_id_param( $user_id ) {
892
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
893
-            return $user_id;
894
-        }
892
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
893
+			return $user_id;
894
+		}
895 895
 
896 896
 		if ( $user_id == 'current' ) {
897 897
 			$user_id = get_current_user_id();
898 898
 		} else {
899
-            if ( is_email($user_id) ) {
900
-                $user = get_user_by('email', $user_id);
901
-            } else {
902
-                $user = get_user_by('login', $user_id);
903
-            }
899
+			if ( is_email($user_id) ) {
900
+				$user = get_user_by('email', $user_id);
901
+			} else {
902
+				$user = get_user_by('login', $user_id);
903
+			}
904 904
 
905
-            if ( $user ) {
906
-                $user_id = $user->ID;
907
-            }
908
-            unset($user);
909
-        }
905
+			if ( $user ) {
906
+				$user_id = $user->ID;
907
+			}
908
+			unset($user);
909
+		}
910 910
 
911
-        return $user_id;
912
-    }
911
+		return $user_id;
912
+	}
913 913
 
914 914
 	public static function get_file_contents( $filename, $atts = array() ) {
915
-        if ( ! is_file($filename) ) {
916
-            return false;
917
-        }
918
-
919
-        extract($atts);
920
-        ob_start();
921
-        include($filename);
922
-        $contents = ob_get_contents();
923
-        ob_end_clean();
924
-        return $contents;
925
-    }
926
-
927
-    /**
928
-     * @param string $table_name
929
-     * @param string $column
915
+		if ( ! is_file($filename) ) {
916
+			return false;
917
+		}
918
+
919
+		extract($atts);
920
+		ob_start();
921
+		include($filename);
922
+		$contents = ob_get_contents();
923
+		ob_end_clean();
924
+		return $contents;
925
+	}
926
+
927
+	/**
928
+	 * @param string $table_name
929
+	 * @param string $column
930 930
 	 * @param int $id
931 931
 	 * @param int $num_chars
932
-     */
933
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
934
-        $key = '';
932
+	 */
933
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
934
+		$key = '';
935 935
 
936
-        if ( ! empty( $name ) ) {
937
-            $key = sanitize_key($name);
938
-        }
936
+		if ( ! empty( $name ) ) {
937
+			$key = sanitize_key($name);
938
+		}
939 939
 
940 940
 		if ( empty( $key ) ) {
941
-            $max_slug_value = pow(36, $num_chars);
942
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
943
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
944
-        }
941
+			$max_slug_value = pow(36, $num_chars);
942
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
943
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
944
+		}
945 945
 
946 946
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
947 947
 			$key = $key . 'a';
948
-        }
948
+		}
949 949
 
950 950
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
951 951
 
952
-        if ( $key_check || is_numeric($key_check) ) {
953
-            $suffix = 2;
952
+		if ( $key_check || is_numeric($key_check) ) {
953
+			$suffix = 2;
954 954
 			do {
955 955
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
956 956
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
957 957
 				$suffix++;
958 958
 			} while ( $key_check || is_numeric( $key_check ) );
959 959
 			$key = $alt_post_name;
960
-        }
961
-        return $key;
962
-    }
963
-
964
-    /**
965
-     * Editing a Form or Entry
966
-     * @param string $table
967
-     * @return bool|array
968
-     */
969
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
970
-        if ( ! $record ) {
971
-            return false;
972
-        }
973
-
974
-        if ( empty($post_values) ) {
975
-            $post_values = stripslashes_deep($_POST);
976
-        }
960
+		}
961
+		return $key;
962
+	}
963
+
964
+	/**
965
+	 * Editing a Form or Entry
966
+	 * @param string $table
967
+	 * @return bool|array
968
+	 */
969
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
970
+		if ( ! $record ) {
971
+			return false;
972
+		}
973
+
974
+		if ( empty($post_values) ) {
975
+			$post_values = stripslashes_deep($_POST);
976
+		}
977 977
 
978 978
 		$values = array( 'id' => $record->id, 'fields' => array() );
979 979
 
980 980
 		foreach ( array( 'name', 'description' ) as $var ) {
981
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
981
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
982 982
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
983
-            unset($var, $default_val);
984
-        }
985
-
986
-        $values['description'] = self::use_wpautop($values['description']);
987
-        $frm_settings = self::get_settings();
988
-        $is_form_builder = self::is_admin_page('formidable' );
989
-
990
-        foreach ( (array) $fields as $field ) {
991
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
992
-            if ( ! $is_form_builder ) {
993
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
994
-            }
983
+			unset($var, $default_val);
984
+		}
985
+
986
+		$values['description'] = self::use_wpautop($values['description']);
987
+		$frm_settings = self::get_settings();
988
+		$is_form_builder = self::is_admin_page('formidable' );
989
+
990
+		foreach ( (array) $fields as $field ) {
991
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
992
+			if ( ! $is_form_builder ) {
993
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
994
+			}
995 995
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
996 996
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
997
-        }
997
+		}
998 998
 
999
-        self::fill_form_opts($record, $table, $post_values, $values);
999
+		self::fill_form_opts($record, $table, $post_values, $values);
1000 1000
 
1001
-        if ( $table == 'entries' ) {
1002
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1003
-        } else if ( $table == 'forms' ) {
1004
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1005
-        }
1001
+		if ( $table == 'entries' ) {
1002
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1003
+		} else if ( $table == 'forms' ) {
1004
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1005
+		}
1006 1006
 
1007
-        return $values;
1008
-    }
1007
+		return $values;
1008
+	}
1009 1009
 
1010 1010
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1011
-        $post_values = $args['post_values'];
1012
-
1013
-        if ( $args['default'] ) {
1014
-            $meta_value = $field->default_value;
1015
-        } else {
1016
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1017
-                if ( ! isset($field->field_options['custom_field']) ) {
1018
-                    $field->field_options['custom_field'] = '';
1019
-                }
1011
+		$post_values = $args['post_values'];
1012
+
1013
+		if ( $args['default'] ) {
1014
+			$meta_value = $field->default_value;
1015
+		} else {
1016
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1017
+				if ( ! isset($field->field_options['custom_field']) ) {
1018
+					$field->field_options['custom_field'] = '';
1019
+				}
1020 1020
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
1021
-            } else {
1021
+			} else {
1022 1022
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1023
-            }
1024
-        }
1023
+			}
1024
+		}
1025 1025
 
1026 1026
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1027
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1028
-
1029
-        $field_array = array(
1030
-            'id'            => $field->id,
1031
-            'value'         => $new_value,
1032
-            'default_value' => $field->default_value,
1033
-            'name'          => $field->name,
1034
-            'description'   => $field->description,
1035
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1036
-            'options'       => $field->options,
1037
-            'required'      => $field->required,
1038
-            'field_key'     => $field->field_key,
1039
-            'field_order'   => $field->field_order,
1040
-            'form_id'       => $field->form_id,
1027
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1028
+
1029
+		$field_array = array(
1030
+			'id'            => $field->id,
1031
+			'value'         => $new_value,
1032
+			'default_value' => $field->default_value,
1033
+			'name'          => $field->name,
1034
+			'description'   => $field->description,
1035
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1036
+			'options'       => $field->options,
1037
+			'required'      => $field->required,
1038
+			'field_key'     => $field->field_key,
1039
+			'field_order'   => $field->field_order,
1040
+			'form_id'       => $field->form_id,
1041 1041
 			'parent_form_id' => $args['parent_form_id'],
1042
-        );
1042
+		);
1043 1043
 
1044
-        $args['field_type'] = $field_type;
1045
-        self::fill_field_opts($field, $field_array, $args);
1044
+		$args['field_type'] = $field_type;
1045
+		self::fill_field_opts($field, $field_array, $args);
1046 1046
 		// Track the original field's type
1047 1047
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1048 1048
 
1049
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1049
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1050 1050
 
1051
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1052
-            $field_array['unique_msg'] = '';
1053
-        }
1051
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1052
+			$field_array['unique_msg'] = '';
1053
+		}
1054 1054
 
1055
-        $field_array = array_merge( $field->field_options, $field_array );
1055
+		$field_array = array_merge( $field->field_options, $field_array );
1056 1056
 
1057
-        $values['fields'][ $field->id ] = $field_array;
1058
-    }
1057
+		$values['fields'][ $field->id ] = $field_array;
1058
+	}
1059 1059
 
1060 1060
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1061
-        $post_values = $args['post_values'];
1062
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1061
+		$post_values = $args['post_values'];
1062
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1063 1063
 
1064
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1064
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1065 1065
 			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1066
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1067
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1068
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1069
-                if ( $args['field_type'] == 'captcha' ) {
1070
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1071
-                } else {
1072
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1073
-                }
1074
-            }
1075
-        }
1076
-
1077
-        if ( $field_array['custom_html'] == '' ) {
1078
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1079
-        }
1080
-    }
1081
-
1082
-    /**
1083
-     * @param string $table
1084
-     */
1066
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1067
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1068
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1069
+				if ( $args['field_type'] == 'captcha' ) {
1070
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1071
+				} else {
1072
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1073
+				}
1074
+			}
1075
+		}
1076
+
1077
+		if ( $field_array['custom_html'] == '' ) {
1078
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1079
+		}
1080
+	}
1081
+
1082
+	/**
1083
+	 * @param string $table
1084
+	 */
1085 1085
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1086
-        if ( $table == 'entries' ) {
1087
-            $form = $record->form_id;
1086
+		if ( $table == 'entries' ) {
1087
+			$form = $record->form_id;
1088 1088
 			FrmForm::maybe_get_form( $form );
1089
-        } else {
1090
-            $form = $record;
1091
-        }
1089
+		} else {
1090
+			$form = $record;
1091
+		}
1092 1092
 
1093
-        if ( ! $form ) {
1094
-            return;
1095
-        }
1093
+		if ( ! $form ) {
1094
+			return;
1095
+		}
1096 1096
 
1097
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1097
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1098 1098
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1099 1099
 
1100
-        if ( ! is_array($form->options) ) {
1101
-            return;
1102
-        }
1100
+		if ( ! is_array($form->options) ) {
1101
+			return;
1102
+		}
1103 1103
 
1104
-        foreach ( $form->options as $opt => $value ) {
1105
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1106
-        }
1104
+		foreach ( $form->options as $opt => $value ) {
1105
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1106
+		}
1107 1107
 
1108
-        self::fill_form_defaults($post_values, $values);
1109
-    }
1108
+		self::fill_form_defaults($post_values, $values);
1109
+	}
1110 1110
 
1111
-    /**
1112
-     * Set to POST value or default
1113
-     */
1111
+	/**
1112
+	 * Set to POST value or default
1113
+	 */
1114 1114
 	private static function fill_form_defaults( $post_values, array &$values ) {
1115
-        $form_defaults = FrmFormsHelper::get_default_opts();
1115
+		$form_defaults = FrmFormsHelper::get_default_opts();
1116 1116
 
1117
-        foreach ( $form_defaults as $opt => $default ) {
1118
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1117
+		foreach ( $form_defaults as $opt => $default ) {
1118
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1119 1119
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1120
-            }
1120
+			}
1121 1121
 
1122
-            unset($opt, $defaut);
1123
-        }
1122
+			unset($opt, $defaut);
1123
+		}
1124 1124
 
1125 1125
 		if ( ! isset( $values['custom_style'] ) ) {
1126 1126
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1129,10 +1129,10 @@  discard block
 block discarded – undo
1129 1129
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1130 1130
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1131 1131
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1132
-            }
1133
-            unset($h);
1134
-        }
1135
-    }
1132
+			}
1133
+			unset($h);
1134
+		}
1135
+	}
1136 1136
 
1137 1137
 	/**
1138 1138
 	 * @since 2.2.10
@@ -1155,59 +1155,59 @@  discard block
 block discarded – undo
1155 1155
 	}
1156 1156
 
1157 1157
 	public static function insert_opt_html( $args ) {
1158
-        $class = '';
1159
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1160
-            $class .= 'show_frm_not_email_to';
1161
-        }
1162
-    ?>
1158
+		$class = '';
1159
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1160
+			$class .= 'show_frm_not_email_to';
1161
+		}
1162
+	?>
1163 1163
 <li>
1164 1164
     <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>
1165 1165
     <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>
1166 1166
     <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>
1167 1167
 </li>
1168 1168
     <?php
1169
-    }
1169
+	}
1170 1170
 
1171 1171
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1172
-        if ( is_array( $str ) ) {
1173
-            return '';
1172
+		if ( is_array( $str ) ) {
1173
+			return '';
1174 1174
 		}
1175 1175
 
1176
-        $length = (int) $length;
1176
+		$length = (int) $length;
1177 1177
 		$str = wp_strip_all_tags( $str );
1178 1178
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1179 1179
 
1180 1180
 		if ( $length == 0 ) {
1181
-            return '';
1182
-        } else if ( $length <= 10 ) {
1181
+			return '';
1182
+		} else if ( $length <= 10 ) {
1183 1183
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1184
-            return $sub . (($length < $original_len) ? $continue : '');
1185
-        }
1184
+			return $sub . (($length < $original_len) ? $continue : '');
1185
+		}
1186 1186
 
1187
-        $sub = '';
1188
-        $len = 0;
1187
+		$sub = '';
1188
+		$len = 0;
1189 1189
 
1190 1190
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1191 1191
 
1192 1192
 		foreach ( $words as $word ) {
1193
-            $part = (($sub != '') ? ' ' : '') . $word;
1193
+			$part = (($sub != '') ? ' ' : '') . $word;
1194 1194
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1195
-            if ( $total_len > $length && str_word_count($sub) ) {
1196
-                break;
1197
-            }
1195
+			if ( $total_len > $length && str_word_count($sub) ) {
1196
+				break;
1197
+			}
1198 1198
 
1199
-            $sub .= $part;
1199
+			$sub .= $part;
1200 1200
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1201 1201
 
1202
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1203
-                break;
1204
-            }
1202
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1203
+				break;
1204
+			}
1205 1205
 
1206
-            unset($total_len, $word);
1207
-        }
1206
+			unset($total_len, $word);
1207
+		}
1208 1208
 
1209
-        return $sub . (($len < $original_len) ? $continue : '');
1210
-    }
1209
+		return $sub . (($len < $original_len) ? $continue : '');
1210
+	}
1211 1211
 
1212 1212
 	public static function mb_function( $function_names, $args ) {
1213 1213
 		$mb_function_name = $function_names[0];
@@ -1219,18 +1219,18 @@  discard block
 block discarded – undo
1219 1219
 	}
1220 1220
 
1221 1221
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1222
-        if ( empty($date) ) {
1223
-            return $date;
1224
-        }
1222
+		if ( empty($date) ) {
1223
+			return $date;
1224
+		}
1225 1225
 
1226
-        if ( empty($date_format) ) {
1227
-            $date_format = get_option('date_format');
1228
-        }
1226
+		if ( empty($date_format) ) {
1227
+			$date_format = get_option('date_format');
1228
+		}
1229 1229
 
1230
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1231
-            $frmpro_settings = new FrmProSettings();
1232
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1233
-        }
1230
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1231
+			$frmpro_settings = new FrmProSettings();
1232
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1233
+		}
1234 1234
 
1235 1235
 		$formatted = self::get_localized_date( $date_format, $date );
1236 1236
 
@@ -1239,8 +1239,8 @@  discard block
 block discarded – undo
1239 1239
 			$formatted .= self::add_time_to_date( $time_format, $date );
1240 1240
 		}
1241 1241
 
1242
-        return $formatted;
1243
-    }
1242
+		return $formatted;
1243
+	}
1244 1244
 
1245 1245
 	private static function add_time_to_date( $time_format, $date ) {
1246 1246
 		if ( empty( $time_format ) ) {
@@ -1322,61 +1322,61 @@  discard block
 block discarded – undo
1322 1322
 		);
1323 1323
 	}
1324 1324
 
1325
-    /**
1326
-     * Added for < WP 4.0 compatability
1327
-     *
1328
-     * @since 1.07.10
1329
-     *
1330
-     * @param string $term The value to escape
1331
-     * @return string The escaped value
1332
-     */
1325
+	/**
1326
+	 * Added for < WP 4.0 compatability
1327
+	 *
1328
+	 * @since 1.07.10
1329
+	 *
1330
+	 * @param string $term The value to escape
1331
+	 * @return string The escaped value
1332
+	 */
1333 1333
 	public static function esc_like( $term ) {
1334
-        global $wpdb;
1335
-        if ( method_exists($wpdb, 'esc_like') ) {
1334
+		global $wpdb;
1335
+		if ( method_exists($wpdb, 'esc_like') ) {
1336 1336
 			// WP 4.0
1337
-            $term = $wpdb->esc_like( $term );
1338
-        } else {
1339
-            $term = like_escape( $term );
1340
-        }
1337
+			$term = $wpdb->esc_like( $term );
1338
+		} else {
1339
+			$term = like_escape( $term );
1340
+		}
1341 1341
 
1342
-        return $term;
1343
-    }
1342
+		return $term;
1343
+	}
1344 1344
 
1345
-    /**
1346
-     * @param string $order_query
1347
-     */
1345
+	/**
1346
+	 * @param string $order_query
1347
+	 */
1348 1348
 	public static function esc_order( $order_query ) {
1349
-        if ( empty($order_query) ) {
1350
-            return '';
1351
-        }
1352
-
1353
-        // remove ORDER BY before santizing
1354
-        $order_query = strtolower($order_query);
1355
-        if ( strpos($order_query, 'order by') !== false ) {
1356
-            $order_query = str_replace('order by', '', $order_query);
1357
-        }
1358
-
1359
-        $order_query = explode(' ', trim($order_query));
1360
-
1361
-        $order_fields = array(
1362
-            'id', 'form_key', 'name', 'description',
1363
-            'parent_form_id', 'logged_in', 'is_template',
1364
-            'default_template', 'status', 'created_at',
1365
-        );
1366
-
1367
-        $order = trim(trim(reset($order_query), ','));
1368
-        if ( ! in_array($order, $order_fields) ) {
1369
-            return '';
1370
-        }
1371
-
1372
-        $order_by = '';
1373
-        if ( count($order_query) > 1 ) {
1349
+		if ( empty($order_query) ) {
1350
+			return '';
1351
+		}
1352
+
1353
+		// remove ORDER BY before santizing
1354
+		$order_query = strtolower($order_query);
1355
+		if ( strpos($order_query, 'order by') !== false ) {
1356
+			$order_query = str_replace('order by', '', $order_query);
1357
+		}
1358
+
1359
+		$order_query = explode(' ', trim($order_query));
1360
+
1361
+		$order_fields = array(
1362
+			'id', 'form_key', 'name', 'description',
1363
+			'parent_form_id', 'logged_in', 'is_template',
1364
+			'default_template', 'status', 'created_at',
1365
+		);
1366
+
1367
+		$order = trim(trim(reset($order_query), ','));
1368
+		if ( ! in_array($order, $order_fields) ) {
1369
+			return '';
1370
+		}
1371
+
1372
+		$order_by = '';
1373
+		if ( count($order_query) > 1 ) {
1374 1374
 			$order_by = end( $order_query );
1375 1375
 			self::esc_order_by( $order_by );
1376
-        }
1376
+		}
1377 1377
 
1378 1378
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1379
-    }
1379
+	}
1380 1380
 
1381 1381
 	/**
1382 1382
 	 * Make sure this is ordering by either ASC or DESC
@@ -1388,169 +1388,169 @@  discard block
 block discarded – undo
1388 1388
 		}
1389 1389
 	}
1390 1390
 
1391
-    /**
1392
-     * @param string $limit
1393
-     */
1391
+	/**
1392
+	 * @param string $limit
1393
+	 */
1394 1394
 	public static function esc_limit( $limit ) {
1395
-        if ( empty($limit) ) {
1396
-            return '';
1397
-        }
1395
+		if ( empty($limit) ) {
1396
+			return '';
1397
+		}
1398 1398
 
1399
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1400
-        if ( is_numeric($limit) ) {
1399
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1400
+		if ( is_numeric($limit) ) {
1401 1401
 			return ' LIMIT ' . $limit;
1402
-        }
1402
+		}
1403 1403
 
1404
-        $limit = explode(',', trim($limit));
1405
-        foreach ( $limit as $k => $l ) {
1406
-            if ( is_numeric( $l ) ) {
1407
-                $limit[ $k ] = $l;
1408
-            }
1409
-        }
1404
+		$limit = explode(',', trim($limit));
1405
+		foreach ( $limit as $k => $l ) {
1406
+			if ( is_numeric( $l ) ) {
1407
+				$limit[ $k ] = $l;
1408
+			}
1409
+		}
1410 1410
 
1411
-        $limit = implode(',', $limit);
1411
+		$limit = implode(',', $limit);
1412 1412
 		return ' LIMIT ' . $limit;
1413
-    }
1414
-
1415
-    /**
1416
-     * Get an array of values ready to go through $wpdb->prepare
1417
-     * @since 2.0
1418
-     */
1419
-    public static function prepare_array_values( $array, $type = '%s' ) {
1420
-        $placeholders = array_fill(0, count($array), $type);
1421
-        return implode(', ', $placeholders);
1422
-    }
1423
-
1424
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1425
-        if ( empty($where) ) {
1426
-            return '';
1427
-        }
1413
+	}
1414
+
1415
+	/**
1416
+	 * Get an array of values ready to go through $wpdb->prepare
1417
+	 * @since 2.0
1418
+	 */
1419
+	public static function prepare_array_values( $array, $type = '%s' ) {
1420
+		$placeholders = array_fill(0, count($array), $type);
1421
+		return implode(', ', $placeholders);
1422
+	}
1423
+
1424
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1425
+		if ( empty($where) ) {
1426
+			return '';
1427
+		}
1428 1428
 
1429 1429
 		if ( is_array( $where ) ) {
1430
-            global $wpdb;
1431
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1430
+			global $wpdb;
1431
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1432 1432
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1433 1433
 		} else {
1434
-            $where = $starts_with . $where;
1435
-        }
1434
+			$where = $starts_with . $where;
1435
+		}
1436 1436
 
1437
-        return $where;
1438
-    }
1437
+		return $where;
1438
+	}
1439 1439
 
1440
-    // Pagination Methods
1440
+	// Pagination Methods
1441 1441
 
1442
-    /**
1443
-     * @param integer $current_p
1444
-     */
1442
+	/**
1443
+	 * @param integer $current_p
1444
+	 */
1445 1445
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1446 1446
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1447 1447
 	}
1448 1448
 
1449
-    /**
1450
-     * @param integer $current_p
1451
-     */
1452
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1453
-        if ( $current_p == 1 ) {
1454
-            return 1;
1455
-        } else {
1456
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1457
-        }
1458
-    }
1449
+	/**
1450
+	 * @param integer $current_p
1451
+	 */
1452
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1453
+		if ( $current_p == 1 ) {
1454
+			return 1;
1455
+		} else {
1456
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1457
+		}
1458
+	}
1459 1459
 
1460 1460
 	/**
1461 1461
 	 * @return array
1462 1462
 	 */
1463 1463
 	public static function json_to_array( $json_vars ) {
1464
-        $vars = array();
1465
-        foreach ( $json_vars as $jv ) {
1466
-            $jv_name = explode('[', $jv['name']);
1467
-            $last = count($jv_name) - 1;
1468
-            foreach ( $jv_name as $p => $n ) {
1469
-                $name = trim($n, ']');
1470
-                if ( ! isset($l1) ) {
1471
-                    $l1 = $name;
1472
-                }
1473
-
1474
-                if ( ! isset($l2) ) {
1475
-                    $l2 = $name;
1476
-                }
1477
-
1478
-                if ( ! isset($l3) ) {
1479
-                    $l3 = $name;
1480
-                }
1481
-
1482
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1483
-
1484
-                switch ( $p ) {
1485
-                    case 0:
1486
-                        $l1 = $name;
1487
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1488
-                    break;
1489
-
1490
-                    case 1:
1491
-                        $l2 = $name;
1492
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1493
-                    break;
1494
-
1495
-                    case 2:
1496
-                        $l3 = $name;
1497
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1498
-                    break;
1499
-
1500
-                    case 3:
1501
-                        $l4 = $name;
1502
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1503
-                    break;
1504
-                }
1505
-
1506
-                unset($this_val, $n);
1507
-            }
1508
-
1509
-            unset($last, $jv);
1510
-        }
1511
-
1512
-        return $vars;
1513
-    }
1514
-
1515
-    /**
1516
-     * @param string $name
1517
-     * @param string $l1
1518
-     */
1519
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1520
-        if ( $name == '' ) {
1521
-            $vars[] = $val;
1522
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1523
-            $vars[ $l1 ] = $val;
1524
-        }
1525
-    }
1464
+		$vars = array();
1465
+		foreach ( $json_vars as $jv ) {
1466
+			$jv_name = explode('[', $jv['name']);
1467
+			$last = count($jv_name) - 1;
1468
+			foreach ( $jv_name as $p => $n ) {
1469
+				$name = trim($n, ']');
1470
+				if ( ! isset($l1) ) {
1471
+					$l1 = $name;
1472
+				}
1473
+
1474
+				if ( ! isset($l2) ) {
1475
+					$l2 = $name;
1476
+				}
1477
+
1478
+				if ( ! isset($l3) ) {
1479
+					$l3 = $name;
1480
+				}
1481
+
1482
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1483
+
1484
+				switch ( $p ) {
1485
+					case 0:
1486
+						$l1 = $name;
1487
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1488
+					break;
1489
+
1490
+					case 1:
1491
+						$l2 = $name;
1492
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1493
+					break;
1494
+
1495
+					case 2:
1496
+						$l3 = $name;
1497
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1498
+					break;
1499
+
1500
+					case 3:
1501
+						$l4 = $name;
1502
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1503
+					break;
1504
+				}
1505
+
1506
+				unset($this_val, $n);
1507
+			}
1508
+
1509
+			unset($last, $jv);
1510
+		}
1511
+
1512
+		return $vars;
1513
+	}
1514
+
1515
+	/**
1516
+	 * @param string $name
1517
+	 * @param string $l1
1518
+	 */
1519
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1520
+		if ( $name == '' ) {
1521
+			$vars[] = $val;
1522
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1523
+			$vars[ $l1 ] = $val;
1524
+		}
1525
+	}
1526 1526
 
1527 1527
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1528
-        $tooltips = array(
1529
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1530
-            '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' ),
1531
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1532
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1533
-            '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' ),
1534
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1535
-            '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() ) ),
1536
-        );
1537
-
1538
-        if ( ! isset( $tooltips[ $name ] ) ) {
1539
-            return;
1540
-        }
1541
-
1542
-        if ( 'open' == $class ) {
1543
-            echo ' frm_help"';
1544
-        } else {
1545
-            echo ' class="frm_help"';
1546
-        }
1528
+		$tooltips = array(
1529
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1530
+			'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' ),
1531
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1532
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1533
+			'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' ),
1534
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1535
+			'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() ) ),
1536
+		);
1537
+
1538
+		if ( ! isset( $tooltips[ $name ] ) ) {
1539
+			return;
1540
+		}
1541
+
1542
+		if ( 'open' == $class ) {
1543
+			echo ' frm_help"';
1544
+		} else {
1545
+			echo ' class="frm_help"';
1546
+		}
1547 1547
 
1548 1548
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1549 1549
 
1550
-        if ( 'open' != $class ) {
1551
-            echo '"';
1552
-        }
1553
-    }
1550
+		if ( 'open' != $class ) {
1551
+			echo '"';
1552
+		}
1553
+	}
1554 1554
 
1555 1555
 	/**
1556 1556
 	 * Add the current_page class to that page in the form nav
@@ -1566,35 +1566,35 @@  discard block
 block discarded – undo
1566 1566
 		}
1567 1567
 	}
1568 1568
 
1569
-    /**
1570
-     * Prepare and json_encode post content
1571
-     *
1572
-     * @since 2.0
1573
-     *
1574
-     * @param array $post_content
1575
-     * @return string $post_content ( json encoded array )
1576
-     */
1577
-    public static function prepare_and_encode( $post_content ) {
1578
-        //Loop through array to strip slashes and add only the needed ones
1569
+	/**
1570
+	 * Prepare and json_encode post content
1571
+	 *
1572
+	 * @since 2.0
1573
+	 *
1574
+	 * @param array $post_content
1575
+	 * @return string $post_content ( json encoded array )
1576
+	 */
1577
+	public static function prepare_and_encode( $post_content ) {
1578
+		//Loop through array to strip slashes and add only the needed ones
1579 1579
 		foreach ( $post_content as $key => $val ) {
1580 1580
 			// Replace problematic characters (like &quot;)
1581 1581
 			$val = str_replace( '&quot;', '"', $val );
1582 1582
 
1583 1583
 			self::prepare_action_slashes( $val, $key, $post_content );
1584
-            unset( $key, $val );
1585
-        }
1584
+			unset( $key, $val );
1585
+		}
1586 1586
 
1587
-        // json_encode the array
1588
-        $post_content = json_encode( $post_content );
1587
+		// json_encode the array
1588
+		$post_content = json_encode( $post_content );
1589 1589
 
1590
-	    // add extra slashes for \r\n since WP strips them
1590
+		// add extra slashes for \r\n since WP strips them
1591 1591
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1592 1592
 
1593
-        // allow for &quot
1594
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1593
+		// allow for &quot
1594
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1595 1595
 
1596
-        return $post_content;
1597
-    }
1596
+		return $post_content;
1597
+	}
1598 1598
 
1599 1599
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1600 1600
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1662,64 +1662,64 @@  discard block
 block discarded – undo
1662 1662
 	}
1663 1663
 
1664 1664
 	public static function maybe_json_decode( $string ) {
1665
-        if ( is_array($string) ) {
1666
-            return $string;
1667
-        }
1665
+		if ( is_array($string) ) {
1666
+			return $string;
1667
+		}
1668 1668
 
1669
-        $new_string = json_decode($string, true);
1670
-        if ( function_exists('json_last_error') ) {
1669
+		$new_string = json_decode($string, true);
1670
+		if ( function_exists('json_last_error') ) {
1671 1671
 			// php 5.3+
1672
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1673
-                $string = $new_string;
1674
-            }
1675
-        } else if ( isset($new_string) ) {
1672
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1673
+				$string = $new_string;
1674
+			}
1675
+		} else if ( isset($new_string) ) {
1676 1676
 			// php < 5.3 fallback
1677
-            $string = $new_string;
1678
-        }
1679
-        return $string;
1680
-    }
1681
-
1682
-    /**
1683
-     * @since 1.07.10
1684
-     *
1685
-     * @param string $post_type The name of the post type that may need to be highlighted
1686
-     * echo The javascript to open and highlight the Formidable menu
1687
-     */
1677
+			$string = $new_string;
1678
+		}
1679
+		return $string;
1680
+	}
1681
+
1682
+	/**
1683
+	 * @since 1.07.10
1684
+	 *
1685
+	 * @param string $post_type The name of the post type that may need to be highlighted
1686
+	 * echo The javascript to open and highlight the Formidable menu
1687
+	 */
1688 1688
 	public static function maybe_highlight_menu( $post_type ) {
1689
-        global $post;
1689
+		global $post;
1690 1690
 
1691
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1692
-            return;
1693
-        }
1691
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1692
+			return;
1693
+		}
1694 1694
 
1695
-        if ( is_object($post) && $post->post_type != $post_type ) {
1696
-            return;
1697
-        }
1695
+		if ( is_object($post) && $post->post_type != $post_type ) {
1696
+			return;
1697
+		}
1698 1698
 
1699
-        self::load_admin_wide_js();
1700
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1701
-    }
1699
+		self::load_admin_wide_js();
1700
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1701
+	}
1702 1702
 
1703
-    /**
1704
-     * Load the JS file on non-Formidable pages in the admin area
1705
-     * @since 2.0
1706
-     */
1703
+	/**
1704
+	 * Load the JS file on non-Formidable pages in the admin area
1705
+	 * @since 2.0
1706
+	 */
1707 1707
 	public static function load_admin_wide_js( $load = true ) {
1708
-        $version = FrmAppHelper::plugin_version();
1708
+		$version = FrmAppHelper::plugin_version();
1709 1709
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1710 1710
 
1711
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1711
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1712 1712
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1713
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1713
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1714 1714
 			'url'          => FrmAppHelper::plugin_url(),
1715 1715
 			'loading'      => __( 'Loading&hellip;' ),
1716 1716
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1717
-        ) );
1717
+		) );
1718 1718
 
1719 1719
 		if ( $load ) {
1720 1720
 			wp_enqueue_script( 'formidable_admin_global' );
1721 1721
 		}
1722
-    }
1722
+	}
1723 1723
 
1724 1724
 	/**
1725 1725
 	 * @since 2.0.9
@@ -1728,9 +1728,9 @@  discard block
 block discarded – undo
1728 1728
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1729 1729
 	}
1730 1730
 
1731
-    /**
1732
-     * @param string $location
1733
-     */
1731
+	/**
1732
+	 * @param string $location
1733
+	 */
1734 1734
 	public static function localize_script( $location ) {
1735 1735
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1736 1736
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1785,81 +1785,81 @@  discard block
 block discarded – undo
1785 1785
 		}
1786 1786
 	}
1787 1787
 
1788
-    /**
1788
+	/**
1789 1789
 	 * echo the message on the plugins listing page
1790
-     * @since 1.07.10
1791
-     *
1792
-     * @param float $min_version The version the add-on requires
1793
-     */
1790
+	 * @since 1.07.10
1791
+	 *
1792
+	 * @param float $min_version The version the add-on requires
1793
+	 */
1794 1794
 	public static function min_version_notice( $min_version ) {
1795
-        $frm_version = self::plugin_version();
1795
+		$frm_version = self::plugin_version();
1796 1796
 
1797
-        // check if Formidable meets minimum requirements
1798
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1799
-            return;
1800
-        }
1797
+		// check if Formidable meets minimum requirements
1798
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1799
+			return;
1800
+		}
1801 1801
 
1802
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1802
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1803 1803
 		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">' .
1804
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1805
-        '</div></td></tr>';
1806
-    }
1807
-
1808
-    public static function locales( $type = 'date' ) {
1809
-        $locales = array(
1810
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1811
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1812
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1813
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1814
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1815
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1816
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1817
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1818
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1819
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1820
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1821
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1822
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1823
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1824
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1825
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1826
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1827
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1828
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1829
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1830
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1831
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1832
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1833
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1834
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1835
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1836
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1837
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1838
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1839
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1840
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1841
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1842
-        );
1843
-
1844
-        if ( $type == 'captcha' ) {
1845
-            // remove the languages unavailable for the captcha
1846
-            $unset = array(
1847
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1848
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1849
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1850
-            );
1851
-        } else {
1852
-            // remove the languages unavailable for the datepicker
1853
-            $unset = array(
1854
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1855
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1856
-                'es-419', 'tr',
1857
-            );
1858
-        }
1859
-
1860
-        $locales = array_diff_key($locales, array_flip($unset));
1861
-        $locales = apply_filters('frm_locales', $locales);
1862
-
1863
-        return $locales;
1864
-    }
1804
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1805
+		'</div></td></tr>';
1806
+	}
1807
+
1808
+	public static function locales( $type = 'date' ) {
1809
+		$locales = array(
1810
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1811
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1812
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1813
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1814
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1815
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1816
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1817
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1818
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1819
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1820
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1821
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1822
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1823
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1824
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1825
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1826
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1827
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1828
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1829
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1830
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1831
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1832
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1833
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1834
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1835
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1836
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1837
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1838
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1839
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1840
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1841
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1842
+		);
1843
+
1844
+		if ( $type == 'captcha' ) {
1845
+			// remove the languages unavailable for the captcha
1846
+			$unset = array(
1847
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1848
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1849
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1850
+			);
1851
+		} else {
1852
+			// remove the languages unavailable for the datepicker
1853
+			$unset = array(
1854
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1855
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1856
+				'es-419', 'tr',
1857
+			);
1858
+		}
1859
+
1860
+		$locales = array_diff_key($locales, array_flip($unset));
1861
+		$locales = apply_filters('frm_locales', $locales);
1862
+
1863
+		return $locales;
1864
+	}
1865 1865
 }
Please login to merge, or discard this patch.