Completed
Push — master ( c2b432...9cac82 )
by Jamie
03:24
created
classes/controllers/FrmXMLController.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -2,109 +2,109 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmXMLController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7
-    }
7
+	}
8 8
 
9
-    public static function add_default_templates() {
9
+	public static function add_default_templates() {
10 10
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
-    		// XML import is not enabled on your server
12
-    		return;
13
-    	}
11
+			// XML import is not enabled on your server
12
+			return;
13
+		}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
16
-        $loader = libxml_disable_entity_loader( true );
15
+		$set_err = libxml_use_internal_errors(true);
16
+		$loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20
-        foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
23
-        }
24
-        /*
20
+		foreach ( (array) $files as $file ) {
21
+			FrmXMLHelper::import_xml($file);
22
+			unset($file);
23
+		}
24
+		/*
25 25
         if(is_wp_error($result))
26 26
             $errors[] = $result->get_error_message();
27 27
         else if($result)
28 28
             $message = $result;
29 29
         */
30 30
 
31
-        unset( $files );
31
+		unset( $files );
32 32
 
33
-        libxml_use_internal_errors( $set_err );
34
-    	libxml_disable_entity_loader( $loader );
35
-    }
33
+		libxml_use_internal_errors( $set_err );
34
+		libxml_disable_entity_loader( $loader );
35
+	}
36 36
 
37
-    public static function route() {
38
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
37
+	public static function route() {
38
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39 39
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40 40
 		if ( $action == 'import_xml' ) {
41
-            return self::import_xml();
41
+			return self::import_xml();
42 42
 		} else if ( $action == 'export_xml' ) {
43
-            return self::export_xml();
44
-        } else {
45
-            if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
-                return self::form();
47
-            }
48
-        }
49
-    }
50
-
51
-    public static function form( $errors = array(), $message = '' ) {
43
+			return self::export_xml();
44
+		} else {
45
+			if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
+				return self::form();
47
+			}
48
+		}
49
+	}
50
+
51
+	public static function form( $errors = array(), $message = '' ) {
52 52
 		$where = array(
53 53
 			'status' => array( null, '', 'published' ),
54 54
 		);
55 55
 		$forms = FrmForm::getAll( $where, 'name' );
56 56
 
57
-        $export_types = apply_filters( 'frm_xml_export_types',
58
-            array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
-        );
57
+		$export_types = apply_filters( 'frm_xml_export_types',
58
+			array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
+		);
60 60
 
61
-        $export_format = apply_filters( 'frm_export_formats', array(
62
-            'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
61
+		$export_format = apply_filters( 'frm_export_formats', array(
62
+			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
63 63
 			'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ),
64
-        ) );
64
+		) );
65 65
 
66 66
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
67
-    }
67
+	}
68 68
 
69
-    public static function import_xml() {
70
-        $errors = array();
71
-        $message = '';
69
+	public static function import_xml() {
70
+		$errors = array();
71
+		$message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
-        if ( $permission_error !== false ) {
75
-            $errors[] = $permission_error;
76
-            self::form($errors);
77
-            return;
78
-        }
73
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
+		if ( $permission_error !== false ) {
75
+			$errors[] = $permission_error;
76
+			self::form($errors);
77
+			return;
78
+		}
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
-            $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
83
-            return;
84
-        }
80
+		if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
+			$errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
+			self::form($errors);
83
+			return;
84
+		}
85 85
 
86
-        $file = $_FILES['frm_import_file']['tmp_name'];
86
+		$file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88
-        if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
90
-            $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
92
-            return;
93
-        }
88
+		if ( ! is_uploaded_file( $file ) ) {
89
+			unset($file);
90
+			$errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
+			self::form($errors);
92
+			return;
93
+		}
94 94
 
95
-        //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
95
+		//add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+		$export_format = apply_filters('frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
-            // allow other file types to be imported
101
+		$file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
+		if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
+			// allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105
-            return;
106
-        }
107
-        unset($file_type);
105
+			return;
106
+		}
107
+		unset($file_type);
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,145 +123,145 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
127
-    }
126
+		self::form($errors, $message);
127
+	}
128 128
 
129
-    public static function export_xml() {
130
-        $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
132
-            wp_die( $error );
133
-        }
129
+	public static function export_xml() {
130
+		$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
+		if ( ! empty($error) ) {
132
+			wp_die( $error );
133
+		}
134 134
 
135 135
 		$ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() );
136 136
 		$type = FrmAppHelper::get_post_param( 'type', array() );
137 137
 		$format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
138 138
 
139
-        if ( ! headers_sent() && ! $type ) {
140
-            wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
-            die();
142
-        }
139
+		if ( ! headers_sent() && ! $type ) {
140
+			wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
+			die();
142
+		}
143 143
 
144
-        if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
144
+		if ( $format == 'xml' ) {
145
+			self::generate_xml($type, compact('ids'));
146 146
 		} if ( $format == 'csv' ) {
147 147
 			self::generate_csv( compact('ids') );
148
-        } else {
148
+		} else {
149 149
 			do_action( 'frm_export_format_' . $format, compact('ids') );
150
-        }
150
+		}
151 151
 
152
-        wp_die();
153
-    }
152
+		wp_die();
153
+	}
154 154
 
155 155
 	public static function generate_xml( $type, $args = array() ) {
156
-    	global $wpdb;
156
+		global $wpdb;
157 157
 
158
-	    self::prepare_types_array( $type );
158
+		self::prepare_types_array( $type );
159 159
 
160
-	    $tables = array(
160
+		$tables = array(
161 161
 			'items'     => $wpdb->prefix . 'frm_items',
162 162
 			'forms'     => $wpdb->prefix . 'frm_forms',
163
-	        'posts'     => $wpdb->posts,
164
-	        'styles'    => $wpdb->posts,
165
-	        'actions'   => $wpdb->posts,
166
-	    );
163
+			'posts'     => $wpdb->posts,
164
+			'styles'    => $wpdb->posts,
165
+			'actions'   => $wpdb->posts,
166
+		);
167 167
 
168 168
 		$defaults = array( 'ids' => false );
169
-	    $args = wp_parse_args( $args, $defaults );
169
+		$args = wp_parse_args( $args, $defaults );
170 170
 
171
-        $sitename = sanitize_key( get_bloginfo( 'name' ) );
171
+		$sitename = sanitize_key( get_bloginfo( 'name' ) );
172 172
 
173
-    	if ( ! empty( $sitename ) ) {
173
+		if ( ! empty( $sitename ) ) {
174 174
 			$sitename .= '.';
175 175
 		}
176
-    	$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
176
+		$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
177 177
 
178
-    	header( 'Content-Description: File Transfer' );
179
-    	header( 'Content-Disposition: attachment; filename=' . $filename );
180
-    	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
178
+		header( 'Content-Description: File Transfer' );
179
+		header( 'Content-Disposition: attachment; filename=' . $filename );
180
+		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
181 181
 
182
-        //make sure ids are numeric
183
-    	if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
-	        $args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
-	    }
182
+		//make sure ids are numeric
183
+		if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
+			$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
+		}
186 186
 
187
-	    $records = array();
187
+		$records = array();
188 188
 
189 189
 		foreach ( $type as $tb_type ) {
190
-            $where = array();
190
+			$where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+			$table = $tables[ $tb_type ];
193 193
 
194 194
 			$select = $table . '.id';
195
-            $query_vars = array();
195
+			$query_vars = array();
196 196
 
197
-            switch ( $tb_type ) {
198
-                case 'forms':
199
-                    //add forms
200
-                    if ( $args['ids'] ) {
197
+			switch ( $tb_type ) {
198
+				case 'forms':
199
+					//add forms
200
+					if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202
-                	} else {
202
+					} else {
203 203
 						$where[ $table . '.status !' ] = 'draft';
204
-                	}
205
-                break;
206
-                case 'actions':
204
+					}
205
+				break;
206
+				case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+					if ( ! empty($args['ids']) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211
-                    }
212
-                break;
213
-                case 'items':
214
-                    //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
-                    if ( $args['ids'] ) {
211
+					}
212
+				break;
213
+				case 'items':
214
+					//$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
+					if ( $args['ids'] ) {
216 216
 						$where[ $table . '.form_id' ] = $args['ids'];
217
-                    }
218
-                break;
219
-                case 'styles':
220
-                    // Loop through all exported forms and get their selected style IDs
217
+					}
218
+				break;
219
+				case 'styles':
220
+					// Loop through all exported forms and get their selected style IDs
221 221
 					$frm_style = new FrmStyle();
222 222
 					$default_style = $frm_style->get_default_style();
223
-                    $form_ids = $args['ids'];
224
-                    $style_ids = array();
225
-                    foreach ( $form_ids as $form_id ) {
226
-                        $form_data = FrmForm::getOne( $form_id );
227
-                        // For forms that have not been updated while running 2.0, check if custom_style is set
228
-                        if ( isset( $form_data->options['custom_style'] ) ) {
223
+					$form_ids = $args['ids'];
224
+					$style_ids = array();
225
+					foreach ( $form_ids as $form_id ) {
226
+						$form_data = FrmForm::getOne( $form_id );
227
+						// For forms that have not been updated while running 2.0, check if custom_style is set
228
+						if ( isset( $form_data->options['custom_style'] ) ) {
229 229
 							if ( $form_data->options['custom_style'] == 1 ) {
230 230
 								$style_ids[] = $default_style->ID;
231 231
 							} else {
232 232
 								$style_ids[] = $form_data->options['custom_style'];
233 233
 							}
234
-                        }
235
-                        unset( $form_id, $form_data );
236
-                    }
234
+						}
235
+						unset( $form_id, $form_data );
236
+					}
237 237
 					$select = $table . '.ID';
238
-                    $where['post_type'] = 'frm_styles';
239
-
240
-                    // Only export selected styles
241
-                    if ( ! empty( $style_ids ) ) {
242
-                        $where['ID'] = $style_ids;
243
-                    }
244
-                break;
245
-                default:
238
+					$where['post_type'] = 'frm_styles';
239
+
240
+					// Only export selected styles
241
+					if ( ! empty( $style_ids ) ) {
242
+						$where['ID'] = $style_ids;
243
+					}
244
+				break;
245
+				default:
246 246
 					$select = $table . '.ID';
247
-                    $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
-                    $where['pm.meta_key'] = 'frm_form_id';
249
-
250
-                    if ( empty($args['ids']) ) {
251
-                        $where['pm.meta_value >'] = 1;
252
-                    } else {
253
-                        $where['pm.meta_value'] = $args['ids'];
254
-                    }
255
-                break;
256
-            }
247
+					$join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
+					$where['pm.meta_key'] = 'frm_form_id';
249
+
250
+					if ( empty($args['ids']) ) {
251
+						$where['pm.meta_value >'] = 1;
252
+					} else {
253
+						$where['pm.meta_value'] = $args['ids'];
254
+					}
255
+				break;
256
+			}
257 257
 
258 258
 			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
260
-        }
259
+			unset($tb_type);
260
+		}
261 261
 
262 262
 		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264
-    }
264
+	}
265 265
 
266 266
 	private static function prepare_types_array( &$type ) {
267 267
 		$type = (array) $type;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	/**
345
-	* Get the fields that should be included in the CSV export
346
-	*
347
-	* @since 2.0.19
348
-	*
349
-	* @param int $form_id
350
-	* @param object $form
351
-	* @return array $csv_fields
352
-	*/
345
+	 * Get the fields that should be included in the CSV export
346
+	 *
347
+	 * @since 2.0.19
348
+	 *
349
+	 * @param int $form_id
350
+	 * @param object $form
351
+	 * @return array $csv_fields
352
+	 */
353 353
 	private static function get_fields_for_csv_export( $form_id, $form ) {
354 354
 		// Phase frm_csv_field_ids out by 2.01.05
355 355
 		$csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) );
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	public static function allow_mime( $mimes ) {
382
-        if ( ! isset( $mimes['csv'] ) ) {
383
-            // allow csv files
384
-            $mimes['csv'] = 'text/csv';
385
-        }
386
-
387
-        if ( ! isset( $mimes['xml'] ) ) {
388
-            // allow xml
389
-            $mimes['xml'] = 'text/xml';
390
-        }
391
-
392
-        return $mimes;
393
-    }
382
+		if ( ! isset( $mimes['csv'] ) ) {
383
+			// allow csv files
384
+			$mimes['csv'] = 'text/csv';
385
+		}
386
+
387
+		if ( ! isset( $mimes['xml'] ) ) {
388
+			// allow xml
389
+			$mimes['xml'] = 'text/xml';
390
+		}
391
+
392
+		return $mimes;
393
+	}
394 394
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -70,41 +70,41 @@  discard block
 block discarded – undo
70 70
         $errors = array();
71 71
         $message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
73
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
74 74
         if ( $permission_error !== false ) {
75 75
             $errors[] = $permission_error;
76
-            self::form($errors);
76
+            self::form( $errors );
77 77
             return;
78 78
         }
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
80
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81 81
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
82
+            self::form( $errors );
83 83
             return;
84 84
         }
85 85
 
86 86
         $file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88 88
         if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
89
+            unset( $file );
90 90
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
91
+            self::form( $errors );
92 92
             return;
93 93
         }
94 94
 
95 95
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+        $export_format = apply_filters( 'frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
101
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
102
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
103 103
             // allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105 105
             return;
106 106
         }
107
-        unset($file_type);
107
+        unset( $file_type );
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
126
+        self::form( $errors, $message );
127 127
     }
128 128
 
129 129
     public static function export_xml() {
130 130
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
131
+        if ( ! empty( $error ) ) {
132 132
             wp_die( $error );
133 133
         }
134 134
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
145
+            self::generate_xml( $type, compact( 'ids' ) );
146 146
 		} if ( $format == 'csv' ) {
147
-			self::generate_csv( compact('ids') );
147
+			self::generate_csv( compact( 'ids' ) );
148 148
         } else {
149
-			do_action( 'frm_export_format_' . $format, compact('ids') );
149
+			do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
150 150
         }
151 151
 
152 152
         wp_die();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		foreach ( $type as $tb_type ) {
190 190
             $where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+            $table = $tables[$tb_type];
193 193
 
194 194
 			$select = $table . '.id';
195 195
             $query_vars = array();
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
                     if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202 202
                 	} else {
203
-						$where[ $table . '.status !' ] = 'draft';
203
+						$where[$table . '.status !'] = 'draft';
204 204
                 	}
205 205
                 break;
206 206
                 case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+                    if ( ! empty( $args['ids'] ) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211 211
                     }
212 212
                 break;
213 213
                 case 'items':
214 214
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215 215
                     if ( $args['ids'] ) {
216
-						$where[ $table . '.form_id' ] = $args['ids'];
216
+						$where[$table . '.form_id'] = $args['ids'];
217 217
                     }
218 218
                 break;
219 219
                 case 'styles':
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248 248
                     $where['pm.meta_key'] = 'frm_form_id';
249 249
 
250
-                    if ( empty($args['ids']) ) {
250
+                    if ( empty( $args['ids'] ) ) {
251 251
                         $where['pm.meta_value >'] = 1;
252 252
                     } else {
253 253
                         $where['pm.meta_value'] = $args['ids'];
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
                 break;
256 256
             }
257 257
 
258
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
258
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
259
+            unset( $tb_type );
260 260
         }
261 261
 
262
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
262
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264 264
     }
265 265
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
298 298
 		}
299 299
 
300
-		set_time_limit(0); //Remove time limit to execute this function
301
-		$mem_limit = str_replace('M', '', ini_get('memory_limit'));
300
+		set_time_limit( 0 ); //Remove time limit to execute this function
301
+		$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
302 302
 		if ( (int) $mem_limit < 256 ) {
303
-			ini_set('memory_limit', '256M');
303
+			ini_set( 'memory_limit', '256M' );
304 304
 		}
305 305
 
306 306
 		global $wpdb;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$no_export_fields = FrmField::no_save_fields();
371 371
 			foreach ( $csv_fields as $k => $f ) {
372 372
 				if ( in_array( $f->type, $no_export_fields ) ) {
373
-					unset( $csv_fields[ $k ] );
373
+					unset( $csv_fields[$k] );
374 374
 				}
375 375
 			}
376 376
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +714 added lines, -714 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71 71
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72
-    }
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
158
-
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
163
-
164
-    /**
165
-     * @since 2.0
166
-     */
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158
+
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 		return $msg;
184 184
 	}
185 185
 
186
-    public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
-        return $fields;
190
-    }
186
+	public static function get_form_fields( $form_id, $error = false ) {
187
+		$fields = FrmField::get_all_for_form($form_id);
188
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
189
+		return $fields;
190
+	}
191 191
 
192 192
 	public static function get_default_html( $type = 'text' ) {
193 193
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
194 194
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
195
-            $for = '';
195
+			$for = '';
196 196
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
197
-                $for = 'for="field_[key]"';
198
-            }
197
+				$for = 'for="field_[key]"';
198
+			}
199 199
 
200
-            $default_html = <<<DEFAULT_HTML
200
+			$default_html = <<<DEFAULT_HTML
201 201
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
202 202
     <label $for class="frm_primary_label">[field_name]
203 203
         <span class="frm_required">[required_label]</span>
@@ -207,138 +207,138 @@  discard block
 block discarded – undo
207 207
     [if error]<div class="frm_error">[error]</div>[/if error]
208 208
 </div>
209 209
 DEFAULT_HTML;
210
-        } else {
210
+		} else {
211 211
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
-        }
212
+		}
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
215
-    }
214
+		return apply_filters('frm_custom_html', $default_html, $type);
215
+	}
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
219 219
 
220
-        $defaults = array(
220
+		$defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
222 222
 			'field_id'      => $field['id'],
223
-            'field_plus_id' => '',
224
-            'section_id'    => '',
225
-        );
226
-        $args = wp_parse_args($args, $defaults);
227
-        $field_name = $args['field_name'];
228
-        $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
223
+			'field_plus_id' => '',
224
+			'section_id'    => '',
225
+		);
226
+		$args = wp_parse_args($args, $defaults);
227
+		$field_name = $args['field_name'];
228
+		$field_id = $args['field_id'];
229
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
232
-            $field_name .= '[]';
233
-        }
231
+		if ( FrmField::is_multiple_select($field) ) {
232
+			$field_name .= '[]';
233
+		}
234 234
 
235
-        //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
235
+		//replace [id]
236
+		$html = str_replace('[id]', $field_id, $html);
237 237
 
238
-        // Remove the for attribute for captcha
239
-        if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
241
-        }
238
+		// Remove the for attribute for captcha
239
+		if ( $field['type'] == 'captcha' ) {
240
+			$html = str_replace(' for="field_[key]"', '', $html);
241
+		}
242 242
 
243
-        // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
243
+		// set the label for
244
+		$html = str_replace('field_[key]', $html_id, $html);
245 245
 
246
-        //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
246
+		//replace [key]
247
+		$html = str_replace('[key]', $field['field_key'], $html);
248 248
 
249
-        //replace [description] and [required_label] and [error]
249
+		//replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251
-        if ( ! is_array( $errors ) ) {
252
-            $errors = array();
253
-        }
251
+		if ( ! is_array( $errors ) ) {
252
+			$errors = array();
253
+		}
254 254
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255 255
 
256
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
-        if ( $field['type'] == 'divider' ) {
258
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
259
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
-            } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
-            }
263
-        }
256
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
+		if ( $field['type'] == 'divider' ) {
258
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
259
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
+			} else {
261
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+			}
263
+		}
264 264
 
265 265
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
266
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
-        }
266
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
+		}
268 268
 
269
-        //replace [required_class]
269
+		//replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+		$html = str_replace('[required_class]', $required_class, $html);
272 272
 
273
-        //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273
+		//replace [label_position]
274
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287
-        //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
-        global $frm_vars;
290
-        $frm_settings = FrmAppHelper::get_settings();
287
+		//replace [input]
288
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
+		global $frm_vars;
290
+		$frm_settings = FrmAppHelper::get_settings();
291 291
 
292
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
292
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
293
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296
-            $replace_with = '';
296
+			$replace_with = '';
297 297
 
298
-            if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
301
-                }
298
+			if ( $tag == 'input' ) {
299
+				if ( isset($atts['opt']) ) {
300
+					$atts['opt']--;
301
+				}
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
306
-                }
303
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
+				if ( isset($atts['class']) ) {
305
+					unset($atts['class']);
306
+				}
307 307
 
308
-                $field['shortcodes'] = $atts;
309
-                ob_start();
308
+				$field['shortcodes'] = $atts;
309
+				ob_start();
310 310
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
311
-                $replace_with = ob_get_contents();
312
-                ob_end_clean();
313
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
315
-            }
311
+				$replace_with = ob_get_contents();
312
+				ob_end_clean();
313
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
315
+			}
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
-        }
317
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
+		}
319 319
 
320 320
 		if ( $form ) {
321
-            $form = (array) $form;
321
+			$form = (array) $form;
322 322
 
323
-            //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
323
+			//replace [form_key]
324
+			$html = str_replace('[form_key]', $form['form_key'], $html);
325 325
 
326
-            //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
328
-        }
329
-        $html .= "\n";
326
+			//replace [form_name]
327
+			$html = str_replace('[form_name]', $form['name'], $html);
328
+		}
329
+		$html .= "\n";
330 330
 
331
-        //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
-            return $html;
334
-        }
331
+		//Return html if conf_field to prevent loop
332
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
+			return $html;
334
+		}
335 335
 
336
-        //If field is in repeating section
337
-        if ( $args['section_id'] ) {
338
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
339
-        } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
-        }
336
+		//If field is in repeating section
337
+		if ( $args['section_id'] ) {
338
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
339
+		} else {
340
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
+		}
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			$html = do_shortcode( $html );
347 347
 		}
348 348
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * Add classes to a field div
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
 		return $classes;
402 402
 	}
403 403
 
404
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
-        if ( $no_vars ) {
404
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
+		if ( $no_vars ) {
406 406
 			$html = str_replace( '[if ' . $code . ']', '', $html );
407 407
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
408
-        } else {
408
+		} else {
409 409
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
410
-        }
410
+		}
411 411
 
412 412
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
413
-    }
413
+	}
414 414
 
415 415
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
416 416
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
417
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
-            $args['conditional_check'] = true;
419
-        }
420
-
421
-        $prefix = '';
422
-        if ( $args['conditional_check'] ) {
423
-            if ( $args['conditional'] ) {
424
-                $prefix = 'if ';
425
-            } else if ( $args['foreach'] ) {
426
-                $prefix = 'foreach ';
427
-            }
428
-        }
429
-
430
-        $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
436
-                $tag = $tags[0];
437
-            }
438
-        } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
-        }
441
-
442
-        return $tag;
443
-    }
417
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
+			$args['conditional_check'] = true;
419
+		}
420
+
421
+		$prefix = '';
422
+		if ( $args['conditional_check'] ) {
423
+			if ( $args['conditional'] ) {
424
+				$prefix = 'if ';
425
+			} else if ( $args['foreach'] ) {
426
+				$prefix = 'foreach ';
427
+			}
428
+		}
429
+
430
+		$with_tags = $args['conditional_check'] ? 3 : 2;
431
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
+			$tag = str_replace(']', '', $tag);
434
+			$tags = explode(' ', $tag);
435
+			if ( is_array($tags) ) {
436
+				$tag = $tags[0];
437
+			}
438
+		} else {
439
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
+		}
441
+
442
+		return $tag;
443
+	}
444 444
 
445 445
 	/**
446 446
 	 * Remove [collapse_this] if it's still included after all processing
@@ -465,51 +465,51 @@  discard block
 block discarded – undo
465 465
 			$class_prefix = 'frm-';
466 466
 		}
467 467
 
468
-        if ( $lang != 'en' ) {
468
+		if ( $lang != 'en' ) {
469 469
 			$api_js_url .= '&hl=' . $lang;
470
-        }
470
+		}
471 471
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
472 472
 
473
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
-        wp_enqueue_script( 'recaptcha-api' );
473
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
474
+		wp_enqueue_script( 'recaptcha-api' );
475 475
 
476 476
 ?>
477 477
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div>
478 478
 <?php
479
-    }
479
+	}
480 480
 
481 481
 	public static function show_single_option( $field ) {
482
-        $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
484
-        foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
482
+		$field_name = $field['name'];
483
+		$html_id = self::get_html_id($field);
484
+		foreach ( $field['options'] as $opt_key => $opt ) {
485
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
487 487
 
488
-            // If this is an "Other" option, get the HTML for it
488
+			// If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
490
-                // Get string for Other text field, if needed
490
+				// Get string for Other text field, if needed
491 491
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
492 492
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
493
-            } else {
493
+			} else {
494 494
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
495
-            }
496
-        }
497
-    }
495
+			}
496
+		}
497
+	}
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
501
-        if ( ! $tax ) {
502
-            return;
503
-        }
500
+		$tax = get_taxonomy($tax_id);
501
+		if ( ! $tax ) {
502
+			return;
503
+		}
504 504
 
505
-        $link = sprintf(
506
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
505
+		$link = sprintf(
506
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508
-        );
509
-        unset($tax);
508
+		);
509
+		unset($tax);
510 510
 
511
-        return $link;
512
-    }
511
+		return $link;
512
+	}
513 513
 
514 514
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
515 515
 		// Remove white space from hide_opt
@@ -520,195 +520,195 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
525
-        }
526
-
527
-        $m = false;
528
-        if ( $cond == '==' ) {
529
-            $m = $observed_value == $hide_opt;
530
-        } else if ( $cond == '!=' ) {
531
-            $m = $observed_value != $hide_opt;
532
-        } else if ( $cond == '>' ) {
533
-            $m = $observed_value > $hide_opt;
534
-        } else if ( $cond == '<' ) {
535
-            $m = $observed_value < $hide_opt;
536
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
538
-            if ( $cond == 'not LIKE' ) {
539
-                $m = ( $m === false ) ? true : false;
540
-            } else {
541
-                $m = ( $m === false ) ? false : true;
542
-            }
543
-        }
544
-        return $m;
545
-    }
523
+		if ( is_array($observed_value) ) {
524
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
525
+		}
526
+
527
+		$m = false;
528
+		if ( $cond == '==' ) {
529
+			$m = $observed_value == $hide_opt;
530
+		} else if ( $cond == '!=' ) {
531
+			$m = $observed_value != $hide_opt;
532
+		} else if ( $cond == '>' ) {
533
+			$m = $observed_value > $hide_opt;
534
+		} else if ( $cond == '<' ) {
535
+			$m = $observed_value < $hide_opt;
536
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
+			$m = stripos($observed_value, $hide_opt);
538
+			if ( $cond == 'not LIKE' ) {
539
+				$m = ( $m === false ) ? true : false;
540
+			} else {
541
+				$m = ( $m === false ) ? false : true;
542
+			}
543
+		}
544
+		return $m;
545
+	}
546 546
 
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548
-        $m = false;
549
-        if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
553
-            } else {
554
-                $m = in_array($hide_opt, $observed_value);
555
-            }
556
-        } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
558
-        } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
560
-            $m = $min > $hide_opt;
561
-        } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
563
-            $m = $max < $hide_opt;
564
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
-            foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
567
-                if ( $m !== false ) {
568
-                    $m = true;
569
-                    break;
570
-                }
571
-            }
572
-
573
-            if ( $cond == 'not LIKE' ) {
574
-                $m = ( $m === false ) ? true : false;
575
-            }
576
-        }
577
-
578
-        return $m;
579
-    }
580
-
581
-    /**
582
-     * Replace a few basic shortcodes and field ids
583
-     * @since 2.0
584
-     * @return string
585
-     */
548
+		$m = false;
549
+		if ( $cond == '==' ) {
550
+			if ( is_array($hide_opt) ) {
551
+				$m = array_intersect($hide_opt, $observed_value);
552
+				$m = empty($m) ? false : true;
553
+			} else {
554
+				$m = in_array($hide_opt, $observed_value);
555
+			}
556
+		} else if ( $cond == '!=' ) {
557
+			$m = ! in_array($hide_opt, $observed_value);
558
+		} else if ( $cond == '>' ) {
559
+			$min = min($observed_value);
560
+			$m = $min > $hide_opt;
561
+		} else if ( $cond == '<' ) {
562
+			$max = max($observed_value);
563
+			$m = $max < $hide_opt;
564
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565
+			foreach ( $observed_value as $ob ) {
566
+				$m = strpos($ob, $hide_opt);
567
+				if ( $m !== false ) {
568
+					$m = true;
569
+					break;
570
+				}
571
+			}
572
+
573
+			if ( $cond == 'not LIKE' ) {
574
+				$m = ( $m === false ) ? true : false;
575
+			}
576
+		}
577
+
578
+		return $m;
579
+	}
580
+
581
+	/**
582
+	 * Replace a few basic shortcodes and field ids
583
+	 * @since 2.0
584
+	 * @return string
585
+	 */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
588
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
590
-        }
587
+		if ( strpos($value, '[sitename]') !== false ) {
588
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
+			$value = str_replace('[sitename]', $new_value, $value);
590
+		}
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+		$value = apply_filters('frm_content', $value, $form, $entry);
593
+		$value = do_shortcode($value);
594 594
 
595
-        return $value;
596
-    }
595
+		return $value;
596
+	}
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599
-        if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
-        }
599
+		if ( FrmAppHelper::pro_is_installed() ) {
600
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
601
+		}
602 602
 
603
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
603
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+		$tagregexp = self::allowed_shortcodes($fields);
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
608 608
 
609
-        return $matches;
610
-    }
609
+		return $matches;
610
+	}
611 611
 
612 612
 	public static function allowed_shortcodes( $fields = array() ) {
613
-        $tagregexp = array(
614
-            'editlink', 'id', 'key', 'ip',
615
-            'siteurl', 'sitename', 'admin_email',
616
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
613
+		$tagregexp = array(
614
+			'editlink', 'id', 'key', 'ip',
615
+			'siteurl', 'sitename', 'admin_email',
616
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
617 617
 			'parent[-|_]id',
618
-        );
618
+		);
619 619
 
620
-        foreach ( $fields as $field ) {
621
-            $tagregexp[] = $field->id;
622
-            $tagregexp[] = $field->field_key;
623
-        }
620
+		foreach ( $fields as $field ) {
621
+			$tagregexp[] = $field->id;
622
+			$tagregexp[] = $field->field_key;
623
+		}
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
626
-        return $tagregexp;
627
-    }
625
+		$tagregexp = implode('|', $tagregexp);
626
+		return $tagregexp;
627
+	}
628 628
 
629 629
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
630
-        $shortcode_values = array(
631
-           'id'     => $entry->id,
632
-           'key'    => $entry->item_key,
633
-           'ip'     => $entry->ip,
634
-        );
630
+		$shortcode_values = array(
631
+		   'id'     => $entry->id,
632
+		   'key'    => $entry->item_key,
633
+		   'ip'     => $entry->ip,
634
+		);
635 635
 
636
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
636
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
637
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
639
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640 640
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
643
-                    $tag = $tags[0];
644
-                }
645
-            } else {
646
-                $tag = $shortcodes[2][ $short_key ];
647
-            }
648
-
649
-            switch ( $tag ) {
650
-                case 'id':
651
-                case 'key':
652
-                case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
654
-                break;
655
-
656
-                case 'user_agent':
657
-                case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
641
+				$tags = explode(' ', $tag);
642
+				if ( is_array($tags) ) {
643
+					$tag = $tags[0];
644
+				}
645
+			} else {
646
+				$tag = $shortcodes[2][ $short_key ];
647
+			}
648
+
649
+			switch ( $tag ) {
650
+				case 'id':
651
+				case 'key':
652
+				case 'ip':
653
+					$replace_with = $shortcode_values[ $tag ];
654
+				break;
655
+
656
+				case 'user_agent':
657
+				case 'user-agent':
658
+					$entry->description = maybe_unserialize($entry->description);
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660
-                break;
661
-
662
-                case 'created_at':
663
-                case 'created-at':
664
-                case 'updated_at':
665
-                case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
667
-                        $time_format = ' ';
668
-                    } else {
669
-                        $atts['format'] = get_option('date_format');
670
-                        $time_format = '';
671
-                    }
672
-
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
676
-                break;
677
-
678
-                case 'created_by':
679
-                case 'created-by':
680
-                case 'updated_by':
681
-                case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
660
+				break;
661
+
662
+				case 'created_at':
663
+				case 'created-at':
664
+				case 'updated_at':
665
+				case 'updated-at':
666
+					if ( isset($atts['format']) ) {
667
+						$time_format = ' ';
668
+					} else {
669
+						$atts['format'] = get_option('date_format');
670
+						$time_format = '';
671
+					}
672
+
673
+					$this_tag = str_replace('-', '_', $tag);
674
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
+					unset($this_tag);
676
+				break;
677
+
678
+				case 'created_by':
679
+				case 'created-by':
680
+				case 'updated_by':
681
+				case 'updated-by':
682
+					$this_tag = str_replace('-', '_', $tag);
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
685
-                break;
686
-
687
-                case 'admin_email':
688
-                case 'siteurl':
689
-                case 'frmurl':
690
-                case 'sitename':
691
-                case 'get':
692
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
693
-                break;
694
-
695
-                default:
696
-                    $field = FrmField::getOne( $tag );
697
-                    if ( ! $field ) {
698
-                        break;
699
-                    }
700
-
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
-
703
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
-
705
-                    $atts['entry_id'] = $entry->id;
706
-                    $atts['entry_key'] = $entry->item_key;
707
-
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
-                        $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
-                        $replace_with = $field->description;
684
+					unset($this_tag);
685
+				break;
686
+
687
+				case 'admin_email':
688
+				case 'siteurl':
689
+				case 'frmurl':
690
+				case 'sitename':
691
+				case 'get':
692
+					$replace_with = self::dynamic_default_values( $tag, $atts );
693
+				break;
694
+
695
+				default:
696
+					$field = FrmField::getOne( $tag );
697
+					if ( ! $field ) {
698
+						break;
699
+					}
700
+
701
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
702
+
703
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704
+
705
+					$atts['entry_id'] = $entry->id;
706
+					$atts['entry_key'] = $entry->item_key;
707
+
708
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
709
+						$replace_with = $field->name;
710
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
711
+						$replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
714 714
 						if ( is_array( $replace_with ) ) {
@@ -722,82 +722,82 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
726
-                break;
727
-            }
725
+					unset($field);
726
+				break;
727
+			}
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
-            }
729
+			if ( isset($replace_with) ) {
730
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
731
+			}
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+			unset($atts, $conditional, $replace_with);
734 734
 		}
735 735
 
736 736
 		return $content;
737
-    }
738
-
739
-    /**
740
-     * Get the value to replace a few standard shortcodes
741
-     *
742
-     * @since 2.0
743
-     * @return string
744
-     */
745
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
-        $new_value = '';
747
-        switch ( $tag ) {
748
-            case 'admin_email':
749
-                $new_value = get_option('admin_email');
750
-                break;
751
-            case 'siteurl':
752
-                $new_value = FrmAppHelper::site_url();
753
-                break;
754
-            case 'frmurl':
755
-                $new_value = FrmAppHelper::plugin_url();
756
-                break;
757
-            case 'sitename':
758
-                $new_value = FrmAppHelper::site_name();
759
-                break;
760
-            case 'get':
761
-                $new_value = self::process_get_shortcode( $atts, $return_array );
762
-                break;
763
-        }
764
-
765
-        return $new_value;
766
-    }
767
-
768
-    /**
769
-     * Process the [get] shortcode
770
-     *
771
-     * @since 2.0
772
-     * @return string|array
773
-     */
774
-    public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
776
-            return '';
777
-        }
778
-
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
-        }
783
-
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
785
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
-
787
-        if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
789
-                $atts['prev_val'] = '';
790
-            }
791
-
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
-        }
794
-
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
797
-        }
798
-
799
-        return $new_value;
800
-    }
737
+	}
738
+
739
+	/**
740
+	 * Get the value to replace a few standard shortcodes
741
+	 *
742
+	 * @since 2.0
743
+	 * @return string
744
+	 */
745
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
746
+		$new_value = '';
747
+		switch ( $tag ) {
748
+			case 'admin_email':
749
+				$new_value = get_option('admin_email');
750
+				break;
751
+			case 'siteurl':
752
+				$new_value = FrmAppHelper::site_url();
753
+				break;
754
+			case 'frmurl':
755
+				$new_value = FrmAppHelper::plugin_url();
756
+				break;
757
+			case 'sitename':
758
+				$new_value = FrmAppHelper::site_name();
759
+				break;
760
+			case 'get':
761
+				$new_value = self::process_get_shortcode( $atts, $return_array );
762
+				break;
763
+		}
764
+
765
+		return $new_value;
766
+	}
767
+
768
+	/**
769
+	 * Process the [get] shortcode
770
+	 *
771
+	 * @since 2.0
772
+	 * @return string|array
773
+	 */
774
+	public static function process_get_shortcode( $atts, $return_array = false ) {
775
+		if ( ! isset($atts['param']) ) {
776
+			return '';
777
+		}
778
+
779
+		if ( strpos($atts['param'], '&#91;') ) {
780
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
782
+		}
783
+
784
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
785
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786
+
787
+		if ( $new_value == '' ) {
788
+			if ( ! isset($atts['prev_val']) ) {
789
+				$atts['prev_val'] = '';
790
+			}
791
+
792
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
793
+		}
794
+
795
+		if ( is_array($new_value) && ! $return_array ) {
796
+			$new_value = implode(', ', $new_value);
797
+		}
798
+
799
+		return $new_value;
800
+	}
801 801
 
802 802
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
803 803
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
813
-                }
814
-                $replace_with = wpautop($replace_with);
815
-            }
808
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
811
+				if ( is_array($replace_with) ) {
812
+					$replace_with = implode("\n", $replace_with);
813
+				}
814
+				$replace_with = wpautop($replace_with);
815
+			}
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
818 818
 			$replace_with = implode( $sep, $replace_with );
@@ -822,58 +822,58 @@  discard block
 block discarded – undo
822 822
 	}
823 823
 
824 824
 	public static function get_field_types( $type ) {
825
-        $single_input = array(
826
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
827
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
828
-            'user_id', 'tag', 'password',
829
-        );
825
+		$single_input = array(
826
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
827
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
828
+			'user_id', 'tag', 'password',
829
+		);
830 830
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
831 831
 		$other_type = array( 'html', 'break' );
832 832
 
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835
-        $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
837
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
839
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
841
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
835
+		$field_types = array();
836
+		if ( in_array($type, $single_input) ) {
837
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
838
+		} else if ( in_array($type, $multiple_input) ) {
839
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
+		} else if ( in_array($type, $other_type) ) {
841
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
842 842
 		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
844
-        }
843
+			$field_types[ $type ] = $field_selection[ $type ];
844
+		}
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
847
-        return $field_types;
848
-    }
849
-
850
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
-        foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
854
-        }
855
-    }
856
-
857
-    /**
858
-    * Check if current field option is an "other" option
859
-    *
860
-    * @since 2.0.6
861
-    *
862
-    * @param string $opt_key
863
-    * @return boolean Returns true if current field option is an "Other" option
864
-    */
865
-    public static function is_other_opt( $opt_key ) {
866
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
-    }
868
-
869
-    /**
870
-    * Get value that belongs in "Other" text box
871
-    *
872
-    * @since 2.0.6
873
-    *
874
-    * @param array $args
875
-    */
876
-    public static function get_other_val( $args ) {
847
+		return $field_types;
848
+	}
849
+
850
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851
+		foreach ( $inputs as $input ) {
852
+			$field_types[ $input ] = $fields[ $input ];
853
+			unset($input);
854
+		}
855
+	}
856
+
857
+	/**
858
+	 * Check if current field option is an "other" option
859
+	 *
860
+	 * @since 2.0.6
861
+	 *
862
+	 * @param string $opt_key
863
+	 * @return boolean Returns true if current field option is an "Other" option
864
+	 */
865
+	public static function is_other_opt( $opt_key ) {
866
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
867
+	}
868
+
869
+	/**
870
+	 * Get value that belongs in "Other" text box
871
+	 *
872
+	 * @since 2.0.6
873
+	 *
874
+	 * @param array $args
875
+	 */
876
+	public static function get_other_val( $args ) {
877 877
 		$defaults = array(
878 878
 			'opt_key' => 0, 'field' => array(),
879 879
 			'parent' => false, 'pointer' => false,
@@ -949,20 +949,20 @@  discard block
 block discarded – undo
949 949
 		}
950 950
 
951 951
 		return $other_val;
952
-    }
953
-
954
-    /**
955
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
-    * Intended for front-end use
957
-    *
958
-    * @since 2.0.6
959
-    *
960
-    * @param array $args should include field, opt_key and field name
961
-    * @param boolean $other_opt
962
-    * @param string $checked
963
-    * @return string $other_val
964
-    */
965
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
952
+	}
953
+
954
+	/**
955
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
956
+	 * Intended for front-end use
957
+	 *
958
+	 * @since 2.0.6
959
+	 *
960
+	 * @param array $args should include field, opt_key and field name
961
+	 * @param boolean $other_opt
962
+	 * @param string $checked
963
+	 * @return string $other_val
964
+	 */
965
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
966 966
 		//Check if this is an "Other" option
967 967
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
968 968
 			return;
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 			$checked = 'checked="checked" ';
979 979
 		}
980 980
 
981
-        return $other_args;
982
-    }
981
+		return $other_args;
982
+	}
983 983
 
984 984
 	/**
985 985
 	 * @param array $args
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
 	 * @since 2.0.6
1029 1029
 	 */
1030 1030
 	public static function include_other_input( $args ) {
1031
-        if ( ! $args['other_opt'] ) {
1032
-        	return;
1031
+		if ( ! $args['other_opt'] ) {
1032
+			return;
1033 1033
 		}
1034 1034
 
1035 1035
 		$classes = array( 'frm_other_input' );
@@ -1050,15 +1050,15 @@  discard block
 block discarded – undo
1050 1050
 	}
1051 1051
 
1052 1052
 	/**
1053
-	* Get the HTML id for an "Other" text field
1054
-	* Note: This does not affect fields in repeating sections
1055
-	*
1056
-	* @since 2.0.08
1057
-	* @param string $type - field type
1058
-	* @param string $html_id
1059
-	* @param string|boolean $opt_key
1060
-	* @return string $other_id
1061
-	*/
1053
+	 * Get the HTML id for an "Other" text field
1054
+	 * Note: This does not affect fields in repeating sections
1055
+	 *
1056
+	 * @since 2.0.08
1057
+	 * @param string $type - field type
1058
+	 * @param string $html_id
1059
+	 * @param string|boolean $opt_key
1060
+	 * @return string $other_id
1061
+	 */
1062 1062
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1063 1063
 		$other_id = $html_id;
1064 1064
 
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
 	}
1117 1117
 
1118 1118
 	public static function switch_field_ids( $val ) {
1119
-        global $frm_duplicate_ids;
1120
-        $replace = array();
1121
-        $replace_with = array();
1122
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1119
+		global $frm_duplicate_ids;
1120
+		$replace = array();
1121
+		$replace_with = array();
1122
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1123 1123
 			$replace[] = '[if ' . $old . ']';
1124 1124
 			$replace_with[] = '[if ' . $new . ']';
1125 1125
 			$replace[] = '[if ' . $old . ' ';
@@ -1134,153 +1134,153 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1138
-        }
1137
+			unset($old, $new);
1138
+		}
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1143
-            }
1144
-        } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1146
-        }
1147
-
1148
-        return $val;
1149
-    }
1150
-
1151
-    public static function get_us_states() {
1152
-        return apply_filters( 'frm_us_states', array(
1153
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
-            'DC' => 'District of Columbia',
1156
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
-        ) );
1168
-    }
1169
-
1170
-    public static function get_countries() {
1171
-        return apply_filters( 'frm_countries', array(
1172
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
-            __( 'Zimbabwe', 'formidable' ),
1245
-        ) );
1246
-    }
1141
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
+				unset($k, $v);
1143
+			}
1144
+		} else {
1145
+			$val = str_replace($replace, $replace_with, $val);
1146
+		}
1147
+
1148
+		return $val;
1149
+	}
1150
+
1151
+	public static function get_us_states() {
1152
+		return apply_filters( 'frm_us_states', array(
1153
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1154
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1155
+			'DC' => 'District of Columbia',
1156
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1159
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1162
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1163
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1164
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1165
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1166
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1167
+		) );
1168
+	}
1169
+
1170
+	public static function get_countries() {
1171
+		return apply_filters( 'frm_countries', array(
1172
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1173
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1174
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1175
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1176
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1177
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1178
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1179
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1180
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1181
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1182
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1183
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1184
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1185
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1186
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1187
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1188
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1189
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1190
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1191
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1192
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1193
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1194
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1195
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1196
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1197
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1198
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1199
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1200
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1201
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1202
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1203
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1204
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1205
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1206
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1207
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1208
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1209
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1210
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1211
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1212
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1213
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1214
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1215
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1216
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1217
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1218
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1219
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1220
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1221
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1222
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1223
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1224
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1225
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1226
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1227
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1228
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1229
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1230
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1231
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1232
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1233
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1234
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1235
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1236
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1237
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1238
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1239
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1240
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1241
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1242
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1243
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1244
+			__( 'Zimbabwe', 'formidable' ),
1245
+		) );
1246
+	}
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249 1249
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1250 1250
 
1251
-        $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1251
+		$states = FrmFieldsHelper::get_us_states();
1252
+		$state_abv = array_keys($states);
1253
+		sort($state_abv);
1254 1254
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1256
+		$states = array_values($states);
1257
+		sort($states);
1258 1258
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1259
+		unset($state_abv, $states);
1260 1260
 
1261 1261
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1262
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
-        );
1262
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265
+		);
1266 1266
 
1267 1267
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1268
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
-        );
1268
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270
+		);
1271 1271
 
1272 1272
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1273
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
-        );
1273
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275
+		);
1276 1276
 
1277 1277
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1278
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
-        );
1278
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280
+		);
1281 1281
 
1282 1282
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1283
-    }
1283
+	}
1284 1284
 
1285 1285
 	public static function field_selection() {
1286 1286
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1317,10 +1317,10 @@  discard block
 block discarded – undo
1317 1317
 		return FrmField::is_required( $field );
1318 1318
 	}
1319 1319
 
1320
-    public static function maybe_get_field( &$field ) {
1320
+	public static function maybe_get_field( &$field ) {
1321 1321
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1322 1322
 		FrmField::maybe_get_field( $field );
1323
-    }
1323
+	}
1324 1324
 
1325 1325
 	public static function dropdown_categories( $args ) {
1326 1326
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136 136
 		$key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$conf_msg = __( 'The entered values do not match', 'formidable' );
173 173
 		$defaults = array(
174
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
175
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
174
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
175
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
176 176
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
177 177
 			'conf_msg'  => array( 'full' => $conf_msg, 'part' => $conf_msg ),
178 178
 		);
179 179
 
180 180
 		$msg = FrmField::get_option( $field, $error );
181
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
181
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
182 182
 		$msg = do_shortcode( $msg );
183 183
 		return $msg;
184 184
 	}
185 185
 
186 186
     public static function get_form_fields( $form_id, $error = false ) {
187
-        $fields = FrmField::get_all_for_form($form_id);
188
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
187
+        $fields = FrmField::get_all_for_form( $form_id );
188
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
189 189
         return $fields;
190 190
     }
191 191
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 </div>
209 209
 DEFAULT_HTML;
210 210
         } else {
211
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
211
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
212 212
         }
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
214
+        return apply_filters( 'frm_custom_html', $default_html, $type );
215 215
     }
216 216
 
217 217
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
218
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
218
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
219 219
 
220 220
         $defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
             'field_plus_id' => '',
224 224
             'section_id'    => '',
225 225
         );
226
-        $args = wp_parse_args($args, $defaults);
226
+        $args = wp_parse_args( $args, $defaults );
227 227
         $field_name = $args['field_name'];
228 228
         $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
229
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
231
+        if ( FrmField::is_multiple_select( $field ) ) {
232 232
             $field_name .= '[]';
233 233
         }
234 234
 
235 235
         //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
236
+        $html = str_replace( '[id]', $field_id, $html );
237 237
 
238 238
         // Remove the for attribute for captcha
239 239
         if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
240
+            $html = str_replace( ' for="field_[key]"', '', $html );
241 241
         }
242 242
 
243 243
         // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
244
+        $html = str_replace( 'field_[key]', $html_id, $html );
245 245
 
246 246
         //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
247
+        $html = str_replace( '[key]', $field['field_key'], $html );
248 248
 
249 249
         //replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251 251
         if ( ! is_array( $errors ) ) {
252 252
             $errors = array();
253 253
         }
254
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
254
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
255 255
 
256 256
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257 257
         if ( $field['type'] == 'divider' ) {
258 258
             if ( FrmField::is_option_true( $field, 'description' ) ) {
259 259
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260 260
             } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
261
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
262 262
             }
263 263
         }
264 264
 
@@ -268,41 +268,41 @@  discard block
 block discarded – undo
268 268
 
269 269
         //replace [required_class]
270 270
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
271
-        $html = str_replace('[required_class]', $required_class, $html);
271
+        $html = str_replace( '[required_class]', $required_class, $html );
272 272
 
273 273
         //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
274
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
275 275
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
276 276
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
277 277
 
278 278
         //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
279
+        $html = str_replace( '[field_name]', $field['name'], $html );
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
         //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
288
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
289 289
         global $frm_vars;
290 290
         $frm_settings = FrmAppHelper::get_settings();
291 291
 
292 292
         foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
293
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296 296
             $replace_with = '';
297 297
 
298 298
             if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
299
+                if ( isset( $atts['opt'] ) ) {
300
+                    $atts['opt'] --;
301 301
                 }
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
303
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
304
+                if ( isset( $atts['class'] ) ) {
305
+                    unset( $atts['class'] );
306 306
                 }
307 307
 
308 308
                 $field['shortcodes'] = $atts;
@@ -311,33 +311,33 @@  discard block
 block discarded – undo
311 311
                 $replace_with = ob_get_contents();
312 312
                 ob_end_clean();
313 313
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
314
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
315 315
             }
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
317
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
318 318
         }
319 319
 
320 320
 		if ( $form ) {
321 321
             $form = (array) $form;
322 322
 
323 323
             //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
324
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
325 325
 
326 326
             //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
327
+            $html = str_replace( '[form_name]', $form['name'], $html );
328 328
         }
329 329
         $html .= "\n";
330 330
 
331 331
         //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
332
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
333 333
             return $html;
334 334
         }
335 335
 
336 336
         //If field is in repeating section
337 337
         if ( $args['section_id'] ) {
338
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
338
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
339 339
         } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
340
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
341 341
         }
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
384 384
 		// Add error class
385
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
385
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
386 386
 
387 387
 		// Add label position class
388 388
 		$classes .= ' frm_' . $field['label'] . '_container';
389 389
 
390 390
 		// Add CSS layout classes
391 391
 		if ( ! empty( $field['classes'] ) ) {
392
-			if ( ! strpos( $html, 'frm_form_field ') ) {
392
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
393 393
 				$classes .= ' frm_form_field';
394 394
 			}
395 395
 			$classes .= ' ' . $field['classes'];
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
431
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
432
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
433
+            $tag = str_replace( ']', '', $tag );
434
+            $tags = explode( ' ', $tag );
435
+            if ( is_array( $tags ) ) {
436 436
                 $tag = $tags[0];
437 437
             }
438 438
         } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
439
+            $tag = $shortcodes[$with_tags - 1][$short_key];
440 440
         }
441 441
 
442 442
         return $tag;
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 
481 481
 	public static function show_single_option( $field ) {
482 482
         $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
483
+        $html_id = self::get_html_id( $field );
484 484
         foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
485
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
486
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
487 487
 
488 488
             // If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
500
+        $tax = get_taxonomy( $tax_id );
501 501
         if ( ! $tax ) {
502 502
             return;
503 503
         }
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508 508
         );
509
-        unset($tax);
509
+        unset( $tax );
510 510
 
511 511
         return $link;
512 512
     }
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
523
+        if ( is_array( $observed_value ) ) {
524
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
525 525
         }
526 526
 
527 527
         $m = false;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         } else if ( $cond == '<' ) {
535 535
             $m = $observed_value < $hide_opt;
536 536
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
537
+            $m = stripos( $observed_value, $hide_opt );
538 538
             if ( $cond == 'not LIKE' ) {
539 539
                 $m = ( $m === false ) ? true : false;
540 540
             } else {
@@ -547,23 +547,23 @@  discard block
 block discarded – undo
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548 548
         $m = false;
549 549
         if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
550
+            if ( is_array( $hide_opt ) ) {
551
+                $m = array_intersect( $hide_opt, $observed_value );
552
+                $m = empty( $m ) ? false : true;
553 553
             } else {
554
-                $m = in_array($hide_opt, $observed_value);
554
+                $m = in_array( $hide_opt, $observed_value );
555 555
             }
556 556
         } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
557
+            $m = ! in_array( $hide_opt, $observed_value );
558 558
         } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
559
+            $min = min( $observed_value );
560 560
             $m = $min > $hide_opt;
561 561
         } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
562
+            $max = max( $observed_value );
563 563
             $m = $max < $hide_opt;
564 564
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565 565
             foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
566
+                $m = strpos( $ob, $hide_opt );
567 567
                 if ( $m !== false ) {
568 568
                     $m = true;
569 569
                     break;
@@ -584,27 +584,27 @@  discard block
 block discarded – undo
584 584
      * @return string
585 585
      */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
587
+        if ( strpos( $value, '[sitename]' ) !== false ) {
588 588
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
589
+            $value = str_replace( '[sitename]', $new_value, $value );
590 590
         }
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
593
+        $value = do_shortcode( $value );
594 594
 
595 595
         return $value;
596 596
     }
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599 599
         if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
600
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
601 601
         }
602 602
 
603 603
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+        $tagregexp = self::allowed_shortcodes( $fields );
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
608 608
 
609 609
         return $matches;
610 610
     }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             $tagregexp[] = $field->field_key;
623 623
         }
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
625
+        $tagregexp = implode( '|', $tagregexp );
626 626
         return $tagregexp;
627 627
     }
628 628
 
@@ -634,28 +634,28 @@  discard block
 block discarded – undo
634 634
         );
635 635
 
636 636
         foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
637
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
639
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
640
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
641
+                $tags = explode( ' ', $tag );
642
+                if ( is_array( $tags ) ) {
643 643
                     $tag = $tags[0];
644 644
                 }
645 645
             } else {
646
-                $tag = $shortcodes[2][ $short_key ];
646
+                $tag = $shortcodes[2][$short_key];
647 647
             }
648 648
 
649 649
             switch ( $tag ) {
650 650
                 case 'id':
651 651
                 case 'key':
652 652
                 case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
653
+                    $replace_with = $shortcode_values[$tag];
654 654
                 break;
655 655
 
656 656
                 case 'user_agent':
657 657
                 case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
658
+                    $entry->description = maybe_unserialize( $entry->description );
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660 660
                 break;
661 661
 
@@ -663,25 +663,25 @@  discard block
 block discarded – undo
663 663
                 case 'created-at':
664 664
                 case 'updated_at':
665 665
                 case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
666
+                    if ( isset( $atts['format'] ) ) {
667 667
                         $time_format = ' ';
668 668
                     } else {
669
-                        $atts['format'] = get_option('date_format');
669
+                        $atts['format'] = get_option( 'date_format' );
670 670
                         $time_format = '';
671 671
                     }
672 672
 
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
673
+                    $this_tag = str_replace( '-', '_', $tag );
674
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
675
+                    unset( $this_tag );
676 676
                 break;
677 677
 
678 678
                 case 'created_by':
679 679
                 case 'created-by':
680 680
                 case 'updated_by':
681 681
                 case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
682
+                    $this_tag = str_replace( '-', '_', $tag );
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
684
+                    unset( $this_tag );
685 685
                 break;
686 686
 
687 687
                 case 'admin_email':
@@ -698,16 +698,16 @@  discard block
 block discarded – undo
698 698
                         break;
699 699
                     }
700 700
 
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
701
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
702 702
 
703 703
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704 704
 
705 705
                     $atts['entry_id'] = $entry->id;
706 706
                     $atts['entry_key'] = $entry->item_key;
707 707
 
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
708
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
709 709
                         $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
710
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
711 711
                         $replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
@@ -722,15 +722,15 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
725
+                    unset( $field );
726 726
                 break;
727 727
             }
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
729
+            if ( isset( $replace_with ) ) {
730
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
731 731
             }
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+            unset( $atts, $conditional, $replace_with );
734 734
 		}
735 735
 
736 736
 		return $content;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
         $new_value = '';
747 747
         switch ( $tag ) {
748 748
             case 'admin_email':
749
-                $new_value = get_option('admin_email');
749
+                $new_value = get_option( 'admin_email' );
750 750
                 break;
751 751
             case 'siteurl':
752 752
                 $new_value = FrmAppHelper::site_url();
@@ -772,28 +772,28 @@  discard block
 block discarded – undo
772 772
      * @return string|array
773 773
      */
774 774
     public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
775
+        if ( ! isset( $atts['param'] ) ) {
776 776
             return '';
777 777
         }
778 778
 
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
779
+        if ( strpos( $atts['param'], '&#91;' ) ) {
780
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
781
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
782 782
         }
783 783
 
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
784
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
785 785
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786 786
 
787 787
         if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
788
+            if ( ! isset( $atts['prev_val'] ) ) {
789 789
                 $atts['prev_val'] = '';
790 790
             }
791 791
 
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
792
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
793 793
         }
794 794
 
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
795
+        if ( is_array( $new_value ) && ! $return_array ) {
796
+            $new_value = implode( ', ', $new_value );
797 797
         }
798 798
 
799 799
         return $new_value;
@@ -806,12 +806,12 @@  discard block
 block discarded – undo
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808 808
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
809
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
810
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
811
+                if ( is_array( $replace_with ) ) {
812
+                    $replace_with = implode( "\n", $replace_with );
813 813
                 }
814
-                $replace_with = wpautop($replace_with);
814
+                $replace_with = wpautop( $replace_with );
815 815
             }
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835 835
         $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
836
+        if ( in_array( $type, $single_input ) ) {
837 837
             self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
838
+        } else if ( in_array( $type, $multiple_input ) ) {
839 839
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
840
+        } else if ( in_array( $type, $other_type ) ) {
841 841
             self::field_types_for_input( $other_type, $field_selection, $field_types );
842
-		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
842
+		} else if ( isset( $field_selection[$type] ) ) {
843
+            $field_types[$type] = $field_selection[$type];
844 844
         }
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 
850 850
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851 851
         foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
852
+            $field_types[$input] = $fields[$input];
853
+            unset( $input );
854 854
         }
855 855
     }
856 856
 
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
 		// Check posted vals before checking saved values
896 896
 
897 897
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
898
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
898
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
899 899
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
900
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
900
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
901 901
 			} else {
902
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
902
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
903 903
 			}
904 904
 			return $other_val;
905 905
 
906
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
906
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
907 907
 			// For normal fields
908 908
 
909 909
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
910
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
910
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
911 911
 			} else {
912
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
912
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
913 913
 			}
914 914
 			return $other_val;
915 915
 		}
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
919 919
 			// Check if there is an "other" val in saved value and make sure the
920 920
 			// "other" val is not equal to the Other checkbox option
921
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
922
-				$other_val = $field['value'][ $opt_key ];
921
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
922
+				$other_val = $field['value'][$opt_key];
923 923
 			}
924 924
 		} else {
925 925
 			/**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 				// Multi-select dropdowns - key is not preserved
932 932
 				if ( is_array( $field['value'] ) ) {
933 933
 					$o_key = array_search( $temp_val, $field['value'] );
934
-					if ( isset( $field['value'][ $o_key ] ) ) {
935
-						unset( $field['value'][ $o_key ], $o_key );
934
+					if ( isset( $field['value'][$o_key] ) ) {
935
+						unset( $field['value'][$o_key], $o_key );
936 936
 					}
937 937
 				} else if ( $temp_val == $field['value'] ) {
938 938
 					// For radio and regular dropdowns
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 	private static function set_other_name( $args, &$other_args ) {
990 990
 		//Set up name for other field
991 991
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
992
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
992
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
993 993
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
994 994
 
995 995
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 		// Count should only be greater than 3 if inside of a repeating section
1016 1016
 		if ( count( $temp_array ) > 3 ) {
1017 1017
 			$parent = str_replace( ']', '', $temp_array[1] );
1018
-			$pointer = str_replace( ']', '', $temp_array[2]);
1018
+			$pointer = str_replace( ']', '', $temp_array[2] );
1019 1019
 		}
1020 1020
 
1021 1021
 		// Get text for "other" text field
@@ -1134,15 +1134,15 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1137
+            unset( $old, $new );
1138 1138
         }
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1141
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1142
+                unset( $k, $v );
1143 1143
             }
1144 1144
         } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1145
+            $val = str_replace( $replace, $replace_with, $val );
1146 1146
         }
1147 1147
 
1148 1148
         return $val;
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
             'DC' => 'District of Columbia',
1156 1156
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157 1157
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1158
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1159 1159
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160 1160
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161 1161
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1246,35 +1246,35 @@  discard block
 block discarded – undo
1246 1246
     }
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1249
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1250 1250
 
1251 1251
         $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1254
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1252
+        $state_abv = array_keys( $states );
1253
+        sort( $state_abv );
1254
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1258
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1256
+        $states = array_values( $states );
1257
+        sort( $states );
1258
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1259
+        unset( $state_abv, $states );
1260 1260
 
1261
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1261
+		$prepop[__( 'Age', 'formidable' )] = array(
1262 1262
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263 1263
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264 1264
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265 1265
         );
1266 1266
 
1267
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1267
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1268 1268
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269 1269
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270 1270
         );
1271 1271
 
1272
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1272
+		$prepop[__( 'Importance', 'formidable' )] = array(
1273 1273
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274 1274
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275 1275
         );
1276 1276
 
1277
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1277
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1278 1278
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279 1279
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280 1280
         );
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,58 +53,58 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' );
63 63
 } else if ( $field['type'] == 'checkbox' ) {
64
-    $checked_values = $field['value'];
65
-    $read_only = false;
64
+	$checked_values = $field['value'];
65
+	$read_only = false;
66 66
 
67 67
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
68
-        $read_only = true;
69
-        if ( $checked_values ) {
70
-            foreach ( (array) $checked_values as $checked_value ) { ?>
68
+		$read_only = true;
69
+		if ( $checked_values ) {
70
+			foreach ( (array) $checked_values as $checked_value ) { ?>
71 71
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
72 72
 <?php
73
-            }
74
-        } else { ?>
73
+			}
74
+		} else { ?>
75 75
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
76 76
 <?php
77
-        }
78
-    }
77
+		}
78
+	}
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82
-    } else if ( $field['options'] ) {
83
-        foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
-                continue;
86
-            }
87
-
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
-
92
-            // Check if other opt, and get values for other field if needed
93
-            $other_opt = false;
82
+	} else if ( $field['options'] ) {
83
+		foreach ( $field['options'] as $opt_key => $opt ) {
84
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
+				continue;
86
+			}
87
+
88
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
+
92
+			// Check if other opt, and get values for other field if needed
93
+			$other_opt = false;
94 94
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
95 95
 
96
-            ?>
96
+			?>
97 97
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
98 98
 
99
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
-            }
99
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
+			}
102 102
 
103
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
103
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
104 104
 
105
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
105
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
107
-            }
107
+			}
108 108
 
109 109
 			FrmFieldsHelper::include_other_input( array(
110 110
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 				'html_id' => $html_id, 'opt_key' => $opt_key,
114 114
 			) );
115 115
 
116
-            unset( $other_opt, $other_args, $checked );
116
+			unset( $other_opt, $other_args, $checked );
117 117
 
118
-            ?></div>
118
+			?></div>
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123
-    $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
126
-    }
123
+	$frm_settings = FrmAppHelper::get_settings();
124
+	if ( ! empty($frm_settings->pubkey) ) {
125
+		FrmFieldsHelper::display_recaptcha($field);
126
+	}
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
129 129
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
         }
78 78
     }
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82 82
     } else if ( $field['options'] ) {
83 83
         foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
84
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
85 85
                 continue;
86 86
             }
87 87
 
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
88
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
89
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
90
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
91 91
 
92 92
             // Check if other opt, and get values for other field if needed
93 93
             $other_opt = false;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101 101
             }
102 102
 
103
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
103
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
104 104
 
105 105
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     }
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123 123
     $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
124
+    if ( ! empty( $frm_settings->pubkey ) ) {
125
+        FrmFieldsHelper::display_recaptcha( $field );
126 126
     }
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/views/frm-fields/front-end/dropdown-field.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $read_only = false;
4
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
5 5
 	echo FrmProPost::get_category_dropdown( $field, array( 'location' => 'front', 'name' => $field_name, 'id' => $html_id ) );
6 6
 } else {
7 7
 	if ( FrmAppHelper::pro_is_installed() && FrmField::is_read_only( $field ) ) {
8 8
 		$read_only = true;
9 9
 
10 10
 		echo FrmProDropdownFieldsController::get_hidden_fields_with_readonly_values( $field, $field_name, $html_id ); ?>
11
-		<select <?php do_action('frm_field_input_html', $field) ?>> <?php
11
+		<select <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
12 12
 
13 13
 	} else { ?>
14
-		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
14
+		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
15 15
 	<?php   }
16 16
 
17 17
 	$other_opt = $other_checked = false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			}
27 27
 		}
28 28
 		?>
29
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option>
29
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option>
30 30
 		<?php
31 31
 	} ?>
32 32
 	</select>
Please login to merge, or discard this patch.
classes/views/frm-fields/back-end/dropdown-field.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
3
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4 4
 	echo FrmProPost::get_category_dropdown( $field, array( 'name' => $field_name, 'id' => 'placeholder_id', 'location' => 'form_builder' ) );
5 5
 } else { ?>
6 6
 	<select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php
7 7
 	echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : '';
8 8
 	echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> >
9 9
 		<?php foreach ( $field['options'] as $opt_key => $opt ) {
10
-			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
11
-			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
10
+			$field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
11
+			$opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
12 12
 			$selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?>
13 13
 			<option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option>
14 14
 		<?php } ?>
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	<?php
27 27
 
28 28
 	if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?>
29
-		<?php do_action('frm_add_multiple_opts_labels', $field); ?>
30
-		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
-			<?php FrmFieldsHelper::show_single_option($field); ?>
29
+		<?php do_action( 'frm_add_multiple_opts_labels', $field ); ?>
30
+		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
+			<?php FrmFieldsHelper::show_single_option( $field ); ?>
32 32
 		</ul>
33 33
 		<?php
34 34
 	} ?>
Please login to merge, or discard this patch.
classes/views/frm-fields/show-build.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
     <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
5 5
 		echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : '';
6
-    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
6
+	?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
7 7
 
8 8
 <?php
9 9
 
10 10
 } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
11
-    $field['default_value'] = maybe_unserialize($field['default_value']);
12
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
11
+	$field['default_value'] = maybe_unserialize($field['default_value']);
12
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
13 13
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
14
-    } else {
15
-        do_action('frm_add_multiple_opts_labels', $field); ?>
14
+	} else {
15
+		do_action('frm_add_multiple_opts_labels', $field); ?>
16 16
         <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>">
17 17
 			<?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?>
18 18
         </ul>
19 19
     <?php
20
-    }
20
+	}
21 21
 } else if ( $field['type'] == 'select' ) {
22 22
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' );
23 23
 } else if ( $field['type'] == 'captcha' ) {
24 24
 	if ( empty($frm_settings->pubkey) ) { ?>
25 25
     <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
26 26
     <?php
27
-    } ?>
27
+	} ?>
28 28
 	<img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
29 29
     <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" />
30 30
 <?php
31 31
 } else {
32
-    do_action( 'frm_display_added_fields', $field );
32
+	do_action( 'frm_display_added_fields', $field );
33 33
 	do_action( 'frm_display_added_' . $field['type'] . '_field', $field );
34 34
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
     <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
5 5
 		echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : '';
6
-    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
6
+    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea>
7 7
 
8 8
 <?php
9 9
 
10 10
 } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
11
-    $field['default_value'] = maybe_unserialize($field['default_value']);
12
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
11
+    $field['default_value'] = maybe_unserialize( $field['default_value'] );
12
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
13 13
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
14 14
     } else {
15
-        do_action('frm_add_multiple_opts_labels', $field); ?>
16
-        <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>">
15
+        do_action( 'frm_add_multiple_opts_labels', $field ); ?>
16
+        <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
17 17
 			<?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?>
18 18
         </ul>
19 19
     <?php
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 } else if ( $field['type'] == 'select' ) {
22 22
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' );
23 23
 } else if ( $field['type'] == 'captcha' ) {
24
-	if ( empty($frm_settings->pubkey) ) { ?>
25
-    <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
24
+	if ( empty( $frm_settings->pubkey ) ) { ?>
25
+    <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div>
26 26
     <?php
27 27
     } ?>
28 28
 	<img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        global $wpdb;
4
+	public static function validate( $values, $exclude = false ) {
5
+		global $wpdb;
6 6
 
7
-        FrmEntry::sanitize_entry_post( $values );
8
-        $errors = array();
7
+		FrmEntry::sanitize_entry_post( $values );
8
+		$errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
-            return $errors;
13
-        }
10
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
+			return $errors;
13
+		}
14 14
 
15 15
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
16
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
-        }
16
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
+		}
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+		if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21
-        }
21
+		}
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+		$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,42 +28,42 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+		$posted_fields = FrmField::getAll($where, 'field_order');
32 32
 
33
-        // Pass exclude value to validate_field function so it can be used for repeating sections
34
-        $args = array( 'exclude' => $exclude );
33
+		// Pass exclude value to validate_field function so it can be used for repeating sections
34
+		$args = array( 'exclude' => $exclude );
35 35
 
36
-        foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
39
-        }
36
+		foreach ( $posted_fields as $posted_field ) {
37
+			self::validate_field($posted_field, $errors, $values, $args);
38
+			unset($posted_field);
39
+		}
40 40
 
41
-        // check for spam
42
-        self::spam_check( $exclude, $values, $errors );
41
+		// check for spam
42
+		self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+		$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
45 45
 
46
-        return $errors;
47
-    }
46
+		return $errors;
47
+	}
48 48
 
49
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
-        $defaults = array(
51
-            'id'              => $posted_field->id,
52
-            'parent_field_id' => '', // the id of the repeat or embed form
53
-            'key_pointer'     => '', // the pointer in the posted array
54
-            'exclude'         => array(), // exclude these field types from validation
55
-        );
56
-        $args = wp_parse_args( $args, $defaults );
49
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
+		$defaults = array(
51
+			'id'              => $posted_field->id,
52
+			'parent_field_id' => '', // the id of the repeat or embed form
53
+			'key_pointer'     => '', // the pointer in the posted array
54
+			'exclude'         => array(), // exclude these field types from validation
55
+		);
56
+		$args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
58
+		if ( empty($args['parent_field_id']) ) {
59 59
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
60
-        } else {
61
-            // value is from a nested form
62
-            $value = $values;
63
-        }
60
+		} else {
61
+			// value is from a nested form
62
+			$value = $values;
63
+		}
64 64
 
65
-        // Check for values in "Other" fields
66
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
65
+		// Check for values in "Other" fields
66
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 			$value = reset($value);
73 73
 		}
74 74
 
75
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
75
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76 76
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78
-            $_POST['item_name'] = $value;
79
-        }
77
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78
+			$_POST['item_name'] = $value;
79
+		}
80 80
 
81 81
 		if ( $value != '' ) {
82 82
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
86 86
 		}
87 87
 
88
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
88
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
89 89
 
90
-        self::validate_recaptcha($errors, $posted_field, $args);
90
+		self::validate_recaptcha($errors, $posted_field, $args);
91 91
 
92 92
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
93 93
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
94
-    }
94
+	}
95 95
 
96 96
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
97 97
 		if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) {
@@ -101,32 +101,32 @@  discard block
 block discarded – undo
101 101
 
102 102
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
103 103
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
104
-            return;
105
-        }
104
+			return;
105
+		}
106 106
 
107
-        if ( trim($value) == 'http://' ) {
108
-            $value = '';
109
-        } else {
110
-            $value = esc_url_raw( $value );
107
+		if ( trim($value) == 'http://' ) {
108
+			$value = '';
109
+		} else {
110
+			$value = esc_url_raw( $value );
111 111
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
112
-        }
112
+		}
113 113
 
114
-        // validate the url format
114
+		// validate the url format
115 115
 		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
116 116
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
117 117
 		}
118
-    }
118
+	}
119 119
 
120 120
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
121
-        if ( $value == '' || $field->type != 'email' ) {
122
-            return;
123
-        }
121
+		if ( $value == '' || $field->type != 'email' ) {
122
+			return;
123
+		}
124 124
 
125
-        //validate the email format
126
-        if ( ! is_email($value) ) {
125
+		//validate the email format
126
+		if ( ! is_email($value) ) {
127 127
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
128
-        }
129
-    }
128
+		}
129
+	}
130 130
 
131 131
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
132 132
 		//validate the number format
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	public static function validate_recaptcha( &$errors, $field, $args ) {
223
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
224
-            return;
225
-        }
223
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
224
+			return;
225
+		}
226 226
 
227 227
 		$frm_settings = FrmAppHelper::get_settings();
228 228
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -230,57 +230,57 @@  discard block
 block discarded – undo
230 230
 			return;
231 231
 		}
232 232
 
233
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
234
-            // If captcha is missing, check if it was already verified
233
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
234
+			// If captcha is missing, check if it was already verified
235 235
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
236
-                // There was no captcha submitted
236
+				// There was no captcha submitted
237 237
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
238
-            }
239
-            return;
240
-        }
238
+			}
239
+			return;
240
+		}
241 241
 
242
-        $arg_array = array(
243
-            'body'      => array(
242
+		$arg_array = array(
243
+			'body'      => array(
244 244
 				'secret'   => $frm_settings->privkey,
245 245
 				'response' => $_POST['g-recaptcha-response'],
246 246
 				'remoteip' => FrmAppHelper::get_ip_address(),
247 247
 			),
248 248
 		);
249
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
249
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
251 251
 
252
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
253
-            // What happens when the CAPTCHA was entered incorrectly
252
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
253
+			// What happens when the CAPTCHA was entered incorrectly
254 254
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
255
-        } else if ( is_wp_error( $resp ) ) {
255
+		} else if ( is_wp_error( $resp ) ) {
256 256
 			$error_string = $resp->get_error_message();
257 257
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258 258
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
259
-        }
260
-    }
261
-
262
-    /**
263
-     * check for spam
264
-     * @param boolean $exclude
265
-     * @param array $values
266
-     * @param array $errors by reference
267
-     */
268
-    public static function spam_check( $exclude, $values, &$errors ) {
269
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
270
-            // only check spam if there are no other errors
271
-            return;
272
-        }
273
-
274
-        if ( self::is_akismet_spam( $values ) ) {
259
+		}
260
+	}
261
+
262
+	/**
263
+	 * check for spam
264
+	 * @param boolean $exclude
265
+	 * @param array $values
266
+	 * @param array $errors by reference
267
+	 */
268
+	public static function spam_check( $exclude, $values, &$errors ) {
269
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
270
+			// only check spam if there are no other errors
271
+			return;
272
+		}
273
+
274
+		if ( self::is_akismet_spam( $values ) ) {
275 275
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
276 276
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
277 277
 			}
278
-	    }
278
+		}
279 279
 
280
-    	if ( self::blacklist_check( $values ) ) {
281
-            $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
282
-    	}
283
-    }
280
+		if ( self::blacklist_check( $values ) ) {
281
+			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
282
+		}
283
+	}
284 284
 
285 285
 	private static function is_akismet_spam( $values ) {
286 286
 		global $wpcom_api_key;
@@ -292,54 +292,54 @@  discard block
 block discarded – undo
292 292
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
293 293
 	}
294 294
 
295
-    public static function blacklist_check( $values ) {
296
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
297
-            return false;
298
-        }
295
+	public static function blacklist_check( $values ) {
296
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
297
+			return false;
298
+		}
299 299
 
300
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
300
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
301 301
 
302
-    	if ( empty( $mod_keys ) ) {
303
-    		return false;
304
-    	}
302
+		if ( empty( $mod_keys ) ) {
303
+			return false;
304
+		}
305 305
 
306
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
306
+		$content = FrmEntriesHelper::entry_array_to_string($values);
307 307
 
308 308
 		if ( empty($content) ) {
309
-		    return false;
309
+			return false;
310 310
 		}
311 311
 
312
-    	$words = explode( "\n", $mod_keys );
312
+		$words = explode( "\n", $mod_keys );
313 313
 
314
-    	foreach ( (array) $words as $word ) {
315
-    		$word = trim( $word );
314
+		foreach ( (array) $words as $word ) {
315
+			$word = trim( $word );
316 316
 
317
-    		if ( empty($word) ) {
318
-    			continue;
319
-    		}
317
+			if ( empty($word) ) {
318
+				continue;
319
+			}
320 320
 
321
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
322
-    			return true;
323
-    		}
324
-    	}
321
+			if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
322
+				return true;
323
+			}
324
+		}
325 325
 
326
-    	return false;
327
-    }
326
+		return false;
327
+	}
328 328
 
329
-    /**
330
-     * Check entries for spam
331
-     *
332
-     * @return boolean true if is spam
333
-     */
334
-    public static function akismet( $values ) {
335
-	    $content = FrmEntriesHelper::entry_array_to_string( $values );
329
+	/**
330
+	 * Check entries for spam
331
+	 *
332
+	 * @return boolean true if is spam
333
+	 */
334
+	public static function akismet( $values ) {
335
+		$content = FrmEntriesHelper::entry_array_to_string( $values );
336 336
 
337 337
 		if ( empty( $content ) ) {
338
-		    return false;
338
+			return false;
339 339
 		}
340 340
 
341
-        $datas = array();
342
-        self::parse_akismet_array( $datas, $content );
341
+		$datas = array();
342
+		self::parse_akismet_array( $datas, $content );
343 343
 
344 344
 		$query_string = '';
345 345
 		foreach ( $datas as $key => $data ) {
@@ -347,35 +347,35 @@  discard block
 block discarded – undo
347 347
 			unset( $key, $data );
348 348
 		}
349 349
 
350
-        $response = Akismet::http_post($query_string, 'comment-check');
350
+		$response = Akismet::http_post($query_string, 'comment-check');
351 351
 
352 352
 		return ( is_array( $response ) && $response[1] == 'true' );
353
-    }
354
-
355
-    /**
356
-     * @since 2.0
357
-     * @param string $content
358
-     */
359
-    private  static function parse_akismet_array( &$datas, $content ) {
360
-        $datas['blog'] = FrmAppHelper::site_url();
361
-        $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
353
+	}
354
+
355
+	/**
356
+	 * @since 2.0
357
+	 * @param string $content
358
+	 */
359
+	private  static function parse_akismet_array( &$datas, $content ) {
360
+		$datas['blog'] = FrmAppHelper::site_url();
361
+		$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
362 362
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
363 363
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
364
-        $datas['comment_type'] = 'formidable';
365
-        $datas['comment_content'] = $content;
364
+		$datas['comment_type'] = 'formidable';
365
+		$datas['comment_content'] = $content;
366 366
 
367
-        if ( $permalink = get_permalink() ) {
368
-            $datas['permalink'] = $permalink;
369
-        }
367
+		if ( $permalink = get_permalink() ) {
368
+			$datas['permalink'] = $permalink;
369
+		}
370 370
 
371
-        foreach ( $_SERVER as $key => $value ) {
371
+		foreach ( $_SERVER as $key => $value ) {
372 372
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
373 373
 				$datas[ $key ] = wp_strip_all_tags( $value );
374
-            } else {
374
+			} else {
375 375
 				$datas[ $key ] = '';
376
-            }
376
+			}
377 377
 
378
-            unset($key, $value);
379
-        }
380
-    }
378
+			unset($key, $value);
379
+		}
380
+	}
381 381
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
         FrmEntry::sanitize_entry_post( $values );
8 8
         $errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
10
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
11 11
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12 12
             return $errors;
13 13
         }
14 14
 
15
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
15
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
16 16
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17 17
         }
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+        if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21 21
         }
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+        $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+        $posted_fields = FrmField::getAll( $where, 'field_order' );
32 32
 
33 33
         // Pass exclude value to validate_field function so it can be used for repeating sections
34 34
         $args = array( 'exclude' => $exclude );
35 35
 
36 36
         foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
37
+            self::validate_field( $posted_field, $errors, $values, $args );
38
+            unset( $posted_field );
39 39
         }
40 40
 
41 41
         // check for spam
42 42
         self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
45 45
 
46 46
         return $errors;
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         );
56 56
         $args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
59
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
58
+        if ( empty( $args['parent_field_id'] ) ) {
59
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
60 60
         } else {
61 61
             // value is from a nested form
62 62
             $value = $values;
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
70 70
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
71
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
72
-			$value = reset($value);
71
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
72
+			$value = reset( $value );
73 73
 		}
74 74
 
75 75
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
76
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77 77
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78 78
             $_POST['item_name'] = $value;
79 79
         }
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
86 86
 		}
87 87
 
88
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
88
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
89 89
 
90
-        self::validate_recaptcha($errors, $posted_field, $args);
90
+        self::validate_recaptcha( $errors, $posted_field, $args );
91 91
 
92 92
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
93 93
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             return;
105 105
         }
106 106
 
107
-        if ( trim($value) == 'http://' ) {
107
+        if ( trim( $value ) == 'http://' ) {
108 108
             $value = '';
109 109
         } else {
110 110
             $value = esc_url_raw( $value );
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         // validate the url format
115
-		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
116
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
115
+		if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
116
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
117 117
 		}
118 118
     }
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         //validate the email format
126
-        if ( ! is_email($value) ) {
127
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
126
+        if ( ! is_email( $value ) ) {
127
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
128 128
         }
129 129
     }
130 130
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 			return;
135 135
 		}
136 136
 
137
-		if ( ! is_numeric( $value) ) {
138
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
137
+		if ( ! is_numeric( $value ) ) {
138
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
139 139
 		}
140 140
 
141 141
 		// validate number settings
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
146 146
 				//minnum maxnum
147 147
 				if ( (float) $value < $field->field_options['minnum'] ) {
148
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
148
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
149 149
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
150
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
150
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
151 151
 				}
152 152
 			}
153 153
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			$pattern = self::phone_format( $field );
160 160
 
161 161
 			if ( ! preg_match( $pattern, $value ) ) {
162
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
162
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
163 163
 			}
164 164
 		}
165 165
 	}
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 			return;
231 231
 		}
232 232
 
233
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
233
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
234 234
             // If captcha is missing, check if it was already verified
235 235
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
236 236
                 // There was no captcha submitted
237
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
237
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
238 238
             }
239 239
             return;
240 240
         }
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 			),
248 248
 		);
249 249
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
250
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
251 251
 
252 252
         if ( isset( $response['success'] ) && ! $response['success'] ) {
253 253
             // What happens when the CAPTCHA was entered incorrectly
254
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
254
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
255 255
         } else if ( is_wp_error( $resp ) ) {
256 256
 			$error_string = $resp->get_error_message();
257
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
257
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258
+			$errors['field' . $args['id']] .= ' ' . $error_string;
259 259
         }
260 260
     }
261 261
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 	private static function is_akismet_spam( $values ) {
286 286
 		global $wpcom_api_key;
287
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
287
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
288 288
 	}
289 289
 
290 290
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
     public static function blacklist_check( $values ) {
296
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
296
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
297 297
             return false;
298 298
         }
299 299
 
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
     		return false;
304 304
     	}
305 305
 
306
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
306
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
307 307
 
308
-		if ( empty($content) ) {
308
+		if ( empty( $content ) ) {
309 309
 		    return false;
310 310
 		}
311 311
 
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
     	foreach ( (array) $words as $word ) {
315 315
     		$word = trim( $word );
316 316
 
317
-    		if ( empty($word) ) {
317
+    		if ( empty( $word ) ) {
318 318
     			continue;
319 319
     		}
320 320
 
321
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
321
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
322 322
     			return true;
323 323
     		}
324 324
     	}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			unset( $key, $data );
348 348
 		}
349 349
 
350
-        $response = Akismet::http_post($query_string, 'comment-check');
350
+        $response = Akismet::http_post( $query_string, 'comment-check' );
351 351
 
352 352
 		return ( is_array( $response ) && $response[1] == 'true' );
353 353
     }
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 
371 371
         foreach ( $_SERVER as $key => $value ) {
372 372
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
373
-				$datas[ $key ] = wp_strip_all_tags( $value );
373
+				$datas[$key] = wp_strip_all_tags( $value );
374 374
             } else {
375
-				$datas[ $key ] = '';
375
+				$datas[$key] = '';
376 376
             }
377 377
 
378
-            unset($key, $value);
378
+            unset( $key, $value );
379 379
         }
380 380
     }
381 381
 }
Please login to merge, or discard this patch.
classes/views/addons/upgrade_to_pro.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 			<tr>
17 17
 				<th></th>
18 18
 			<?php foreach ( $pro['pricing'] as $name => $price ) {
19
-				$price_id++;
19
+				$price_id ++;
20 20
 				$the_id = ( $price_id < 3 ) ? ( $price_id + 4 ) : $price_id;
21 21
 				if ( $name == 'smallbusiness' ) {
22 22
 					$name = 'Small Business';
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 			<tr>
62 62
 				<th>Included AddOns</th>
63 63
 				<td>None</td>
64
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td>
65
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td>
66
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td>
64
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td>
65
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td>
66
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td>
67 67
 			</tr>
68 68
 		</tbody>
69 69
 	</table>
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 3 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * Sanitize the value, and allow some HTML
357 357
 	 * @since 2.0
358 358
 	 * @param string $value
359
-	 * @param array $allowed
359
+	 * @param string[] $allowed
360 360
 	 * @return string
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
@@ -464,6 +464,7 @@  discard block
 block discarded – undo
464 464
 	/**
465 465
 	 * Keep track of the keys cached in each group so they can be deleted
466 466
 	 * in Redis and Memcache
467
+	 * @param string $group
467 468
 	 */
468 469
 	public static function add_key_to_group_cache( $key, $group ) {
469 470
 		$cached = self::get_group_cached_keys( $group );
@@ -787,6 +788,9 @@  discard block
 block discarded – undo
787 788
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
788 789
     }
789 790
 
791
+	/**
792
+	 * @param string $function
793
+	 */
790 794
 	public static function recursive_function_map( $value, $function ) {
791 795
 		if ( is_array( $value ) ) {
792 796
 			$original_function = $function;
@@ -1206,6 +1210,9 @@  discard block
 block discarded – undo
1206 1210
         return $sub . (($len < $original_len) ? $continue : '');
1207 1211
     }
1208 1212
 
1213
+	/**
1214
+	 * @param string[] $function_names
1215
+	 */
1209 1216
 	public static function mb_function( $function_names, $args ) {
1210 1217
 		$mb_function_name = $function_names[0];
1211 1218
 		$function_name = $function_names[1];
@@ -1239,6 +1246,9 @@  discard block
 block discarded – undo
1239 1246
         return $formatted;
1240 1247
     }
1241 1248
 
1249
+	/**
1250
+	 * @param string $time_format
1251
+	 */
1242 1252
 	private static function add_time_to_date( $time_format, $date ) {
1243 1253
 		if ( empty( $time_format ) ) {
1244 1254
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1034 added lines, -1034 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.02.06';
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();
@@ -76,83 +76,83 @@  discard block
 block discarded – undo
76 76
 		return $affiliate_id;
77 77
 	}
78 78
 
79
-    /**
80
-     * Get the Formidable settings
81
-     *
82
-     * @since 2.0
83
-     *
84
-     * @param None
85
-     * @return FrmSettings $frm_setings
86
-     */
87
-    public static function get_settings() {
88
-        global $frm_settings;
89
-        if ( empty($frm_settings) ) {
90
-            $frm_settings = new FrmSettings();
91
-        }
92
-        return $frm_settings;
93
-    }
79
+	/**
80
+	 * Get the Formidable settings
81
+	 *
82
+	 * @since 2.0
83
+	 *
84
+	 * @param None
85
+	 * @return FrmSettings $frm_setings
86
+	 */
87
+	public static function get_settings() {
88
+		global $frm_settings;
89
+		if ( empty($frm_settings) ) {
90
+			$frm_settings = new FrmSettings();
91
+		}
92
+		return $frm_settings;
93
+	}
94 94
 
95 95
 	public static function get_menu_name() {
96 96
 		$frm_settings = FrmAppHelper::get_settings();
97 97
 		return $frm_settings->menu;
98 98
 	}
99 99
 
100
-    /**
101
-     * Show a message in place of pro features
102
-     *
103
-     * @since 2.0
104
-     */
100
+	/**
101
+	 * Show a message in place of pro features
102
+	 *
103
+	 * @since 2.0
104
+	 */
105 105
 	public static function update_message() {
106 106
 		_deprecated_function( __FUNCTION__, '2.0.19' );
107
-    }
108
-
109
-    public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
111
-    }
112
-
113
-    /**
114
-     * Check for certain page in Formidable settings
115
-     *
116
-     * @since 2.0
117
-     *
118
-     * @param string $page The name of the page to check
119
-     * @return boolean
120
-     */
107
+	}
108
+
109
+	public static function pro_is_installed() {
110
+		return apply_filters('frm_pro_installed', false);
111
+	}
112
+
113
+	/**
114
+	 * Check for certain page in Formidable settings
115
+	 *
116
+	 * @since 2.0
117
+	 *
118
+	 * @param string $page The name of the page to check
119
+	 * @return boolean
120
+	 */
121 121
 	public static function is_admin_page( $page = 'formidable' ) {
122
-        global $pagenow;
122
+		global $pagenow;
123 123
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
124
-        if ( $pagenow ) {
124
+		if ( $pagenow ) {
125 125
 			return $pagenow == 'admin.php' && $get_page == $page;
126
-        }
126
+		}
127 127
 
128 128
 		return is_admin() && $get_page == $page;
129
-    }
130
-
131
-    /**
132
-     * Check for the form preview page
133
-     *
134
-     * @since 2.0
135
-     *
136
-     * @param None
137
-     * @return boolean
138
-     */
139
-    public static function is_preview_page() {
140
-        global $pagenow;
129
+	}
130
+
131
+	/**
132
+	 * Check for the form preview page
133
+	 *
134
+	 * @since 2.0
135
+	 *
136
+	 * @param None
137
+	 * @return boolean
138
+	 */
139
+	public static function is_preview_page() {
140
+		global $pagenow;
141 141
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
142 142
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
143
-    }
143
+	}
144 144
 
145
-    /**
146
-     * Check for ajax except the form preview page
147
-     *
148
-     * @since 2.0
149
-     *
150
-     * @param None
151
-     * @return boolean
152
-     */
153
-    public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
-    }
145
+	/**
146
+	 * Check for ajax except the form preview page
147
+	 *
148
+	 * @since 2.0
149
+	 *
150
+	 * @param None
151
+	 * @return boolean
152
+	 */
153
+	public static function doing_ajax() {
154
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
+	}
156 156
 
157 157
 	/**
158 158
 	 * @since 2.0.8
@@ -162,102 +162,102 @@  discard block
 block discarded – undo
162 162
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
163 163
 	}
164 164
 
165
-    /**
166
-     * Check if on an admin page
167
-     *
168
-     * @since 2.0
169
-     *
170
-     * @param None
171
-     * @return boolean
172
-     */
173
-    public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
-    }
176
-
177
-    /**
178
-     * Check if value contains blank value or empty array
179
-     *
180
-     * @since 2.0
181
-     * @param mixed $value - value to check
165
+	/**
166
+	 * Check if on an admin page
167
+	 *
168
+	 * @since 2.0
169
+	 *
170
+	 * @param None
171
+	 * @return boolean
172
+	 */
173
+	public static function is_admin() {
174
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
+	}
176
+
177
+	/**
178
+	 * Check if value contains blank value or empty array
179
+	 *
180
+	 * @since 2.0
181
+	 * @param mixed $value - value to check
182 182
 	 * @param string
183
-     * @return boolean
184
-     */
185
-    public static function is_empty_value( $value, $empty = '' ) {
186
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
-    }
188
-
189
-    public static function is_not_empty_value( $value, $empty = '' ) {
190
-        return ! self::is_empty_value( $value, $empty );
191
-    }
192
-
193
-    /**
194
-     * Get any value from the $_SERVER
195
-     *
196
-     * @since 2.0
197
-     * @param string $value
198
-     * @return string
199
-     */
183
+	 * @return boolean
184
+	 */
185
+	public static function is_empty_value( $value, $empty = '' ) {
186
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
+	}
188
+
189
+	public static function is_not_empty_value( $value, $empty = '' ) {
190
+		return ! self::is_empty_value( $value, $empty );
191
+	}
192
+
193
+	/**
194
+	 * Get any value from the $_SERVER
195
+	 *
196
+	 * @since 2.0
197
+	 * @param string $value
198
+	 * @return string
199
+	 */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
-    }
203
-
204
-    /**
205
-     * Check for the IP address in several places
206
-     * Used by [ip] shortcode
207
-     *
208
-     * @return string The IP address of the current user
209
-     */
210
-    public static function get_ip_address() {
201
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
+	}
203
+
204
+	/**
205
+	 * Check for the IP address in several places
206
+	 * Used by [ip] shortcode
207
+	 *
208
+	 * @return string The IP address of the current user
209
+	 */
210
+	public static function get_ip_address() {
211 211
 		$ip = '';
212
-        foreach ( array(
213
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
-        ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
217
-                continue;
218
-            }
219
-
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
222
-
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
-                    return $ip;
225
-                }
226
-            }
227
-        }
212
+		foreach ( array(
213
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
+		) as $key ) {
216
+			if ( ! isset( $_SERVER[ $key ] ) ) {
217
+				continue;
218
+			}
219
+
220
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
+				$ip = trim($ip); // just to be safe
222
+
223
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
+					return $ip;
225
+				}
226
+			}
227
+		}
228 228
 
229 229
 		return sanitize_text_field( $ip );
230
-    }
230
+	}
231 231
 
232
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
235
-            $param = $params[0];
236
-        }
232
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
+		if ( strpos($param, '[') ) {
234
+			$params = explode('[', $param);
235
+			$param = $params[0];
236
+		}
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
-            }
239
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
+			}
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
245
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
-        }
245
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
+		}
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249
-            foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
251
-                    continue;
252
-                }
249
+			foreach ( $params as $k => $p ) {
250
+				if ( ! $k || ! is_array($value) ) {
251
+					continue;
252
+				}
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
-            }
257
-        }
254
+				$p = trim($p, ']');
255
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
+			}
257
+		}
258 258
 
259
-        return $value;
260
-    }
259
+		return $value;
260
+	}
261 261
 
262 262
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
263 263
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
275 275
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
276
-    }
276
+	}
277 277
 
278 278
 	/**
279 279
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 
311 311
 	/**
312
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
-	*
314
-	* @since 2.0.8
315
-	* @param string $value
316
-	* @return string $value
317
-	*/
312
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
+	 *
314
+	 * @since 2.0.8
315
+	 * @param string $value
316
+	 * @return string $value
317
+	 */
318 318
 	public static function preserve_backslashes( $value ) {
319 319
 		// If backslashes have already been added, don't add them again
320 320
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 	}
338 338
 
339
-    public static function sanitize_request( $sanitize_method, &$values ) {
340
-        $temp_values = $values;
341
-        foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
339
+	public static function sanitize_request( $sanitize_method, &$values ) {
340
+		$temp_values = $values;
341
+		foreach ( $temp_values as $k => $val ) {
342
+			if ( isset( $sanitize_method[ $k ] ) ) {
343 343
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
344
-            }
345
-        }
346
-    }
344
+			}
345
+		}
346
+	}
347 347
 
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
363 363
 		$html = array(
364
-		    'a' => array(
364
+			'a' => array(
365 365
 				'href'  => array(),
366 366
 				'title' => array(),
367 367
 				'id'    => array(),
368 368
 				'class' => array(),
369
-		    ),
369
+			),
370 370
 		);
371 371
 
372 372
 		$allowed_html = array();
@@ -377,77 +377,77 @@  discard block
 block discarded – undo
377 377
 		return wp_kses( $value, $allowed_html );
378 378
 	}
379 379
 
380
-    /**
381
-     * Used when switching the action for a bulk action
382
-     * @since 2.0
383
-     */
384
-    public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
386
-            return;
387
-        }
380
+	/**
381
+	 * Used when switching the action for a bulk action
382
+	 * @since 2.0
383
+	 */
384
+	public static function remove_get_action() {
385
+		if ( ! isset($_GET) ) {
386
+			return;
387
+		}
388 388
 
389
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
-        if ( ! empty( $new_action ) ) {
389
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
+		if ( ! empty( $new_action ) ) {
391 391
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Check the WP query for a parameter
397
-     *
398
-     * @since 2.0
399
-     * @return string|array
400
-     */
401
-    public static function get_query_var( $value, $param ) {
402
-        if ( $value != '' ) {
403
-            return $value;
404
-        }
405
-
406
-        global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
409
-        }
410
-
411
-        return $value;
412
-    }
413
-
414
-    /**
415
-     * @param string $type
416
-     */
417
-    public static function trigger_hook_load( $type, $object = null ) {
418
-        // only load the form hooks once
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Check the WP query for a parameter
397
+	 *
398
+	 * @since 2.0
399
+	 * @return string|array
400
+	 */
401
+	public static function get_query_var( $value, $param ) {
402
+		if ( $value != '' ) {
403
+			return $value;
404
+		}
405
+
406
+		global $wp_query;
407
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
+			$value = $wp_query->query_vars[ $param ];
409
+		}
410
+
411
+		return $value;
412
+	}
413
+
414
+	/**
415
+	 * @param string $type
416
+	 */
417
+	public static function trigger_hook_load( $type, $object = null ) {
418
+		// only load the form hooks once
419 419
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
420
-        if ( ! $hooks_loaded ) {
420
+		if ( ! $hooks_loaded ) {
421 421
 			do_action( 'frm_load_' . $type . '_hooks' );
422
-        }
423
-    }
424
-
425
-    /**
426
-     * Check cache before fetching values and saving to cache
427
-     *
428
-     * @since 2.0
429
-     *
430
-     * @param string $cache_key The unique name for this cache
431
-     * @param string $group The name of the cache group
432
-     * @param string $query If blank, don't run a db call
433
-     * @param string $type The wpdb function to use with this query
434
-     * @return mixed $results The cache or query results
435
-     */
436
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
-            return $results;
440
-        }
441
-
442
-        if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
422
+		}
423
+	}
424
+
425
+	/**
426
+	 * Check cache before fetching values and saving to cache
427
+	 *
428
+	 * @since 2.0
429
+	 *
430
+	 * @param string $cache_key The unique name for this cache
431
+	 * @param string $group The name of the cache group
432
+	 * @param string $query If blank, don't run a db call
433
+	 * @param string $type The wpdb function to use with this query
434
+	 * @return mixed $results The cache or query results
435
+	 */
436
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
+		$results = wp_cache_get($cache_key, $group);
438
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
+			return $results;
440
+		}
441
+
442
+		if ( 'get_posts' == $type ) {
443
+			$results = get_posts($query);
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447
-        } else {
448
-            global $wpdb;
449
-            $results = $wpdb->{$type}($query);
450
-        }
447
+		} else {
448
+			global $wpdb;
449
+			$results = $wpdb->{$type}($query);
450
+		}
451 451
 
452 452
 		self::set_cache( $cache_key, $results, $group, $time );
453 453
 
@@ -479,44 +479,44 @@  discard block
 block discarded – undo
479 479
 		return (array) $cached;
480 480
 	}
481 481
 
482
-    /**
483
-     * Data that should be stored for a long time can be stored in a transient.
484
-     * First check the cache, then check the transient
485
-     * @since 2.0
486
-     * @return mixed The cached value or false
487
-     */
482
+	/**
483
+	 * Data that should be stored for a long time can be stored in a transient.
484
+	 * First check the cache, then check the transient
485
+	 * @since 2.0
486
+	 * @return mixed The cached value or false
487
+	 */
488 488
 	public static function check_cache_and_transient( $cache_key ) {
489
-        // check caching layer first
490
-        $results = self::check_cache( $cache_key );
491
-        if ( $results ) {
492
-            return $results;
493
-        }
494
-
495
-        // then check the transient
496
-        $results = get_transient($cache_key);
497
-        if ( $results ) {
498
-            wp_cache_set($cache_key, $results);
499
-        }
500
-
501
-        return $results;
502
-    }
503
-
504
-    /**
505
-     * @since 2.0
506
-     * @param string $cache_key
507
-     */
489
+		// check caching layer first
490
+		$results = self::check_cache( $cache_key );
491
+		if ( $results ) {
492
+			return $results;
493
+		}
494
+
495
+		// then check the transient
496
+		$results = get_transient($cache_key);
497
+		if ( $results ) {
498
+			wp_cache_set($cache_key, $results);
499
+		}
500
+
501
+		return $results;
502
+	}
503
+
504
+	/**
505
+	 * @since 2.0
506
+	 * @param string $cache_key
507
+	 */
508 508
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
509 509
 		delete_transient($cache_key);
510 510
 		wp_cache_delete( $cache_key, $group );
511 511
 	}
512 512
 
513
-    /**
514
-     * Delete all caching in a single group
515
-     *
516
-     * @since 2.0
517
-     *
518
-     * @param string $group The name of the cache group
519
-     */
513
+	/**
514
+	 * Delete all caching in a single group
515
+	 *
516
+	 * @since 2.0
517
+	 *
518
+	 * @param string $group The name of the cache group
519
+	 */
520 520
 	public static function cache_delete_group( $group ) {
521 521
 		$cached_keys = self::get_group_cached_keys( $group );
522 522
 
@@ -533,34 +533,34 @@  discard block
 block discarded – undo
533 533
 		}
534 534
 	}
535 535
 
536
-    /**
537
-     * Check a value from a shortcode to see if true or false.
538
-     * True when value is 1, true, 'true', 'yes'
539
-     *
540
-     * @since 1.07.10
541
-     *
542
-     * @param string $value The value to compare
543
-     * @return boolean True or False
544
-     */
536
+	/**
537
+	 * Check a value from a shortcode to see if true or false.
538
+	 * True when value is 1, true, 'true', 'yes'
539
+	 *
540
+	 * @since 1.07.10
541
+	 *
542
+	 * @param string $value The value to compare
543
+	 * @return boolean True or False
544
+	 */
545 545
 	public static function is_true( $value ) {
546
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
547
-    }
546
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
547
+	}
548 548
 
549
-    /**
550
-     * Used to filter shortcode in text widgets
551
-     */
552
-    public static function widget_text_filter_callback( $matches ) {
553
-        return do_shortcode( $matches[0] );
554
-    }
549
+	/**
550
+	 * Used to filter shortcode in text widgets
551
+	 */
552
+	public static function widget_text_filter_callback( $matches ) {
553
+		return do_shortcode( $matches[0] );
554
+	}
555 555
 
556
-    public static function get_pages() {
556
+	public static function get_pages() {
557 557
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
558
-    }
558
+	}
559 559
 
560
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
561
-        $pages = self::get_pages();
560
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
561
+		$pages = self::get_pages();
562 562
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
563
-    ?>
563
+	?>
564 564
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
565 565
             <option value=""> </option>
566 566
             <?php foreach ( $pages as $page ) { ?>
@@ -570,108 +570,108 @@  discard block
 block discarded – undo
570 570
             <?php } ?>
571 571
         </select>
572 572
     <?php
573
-    }
573
+	}
574 574
 
575 575
 	public static function post_edit_link( $post_id ) {
576
-        $post = get_post($post_id);
577
-        if ( $post ) {
576
+		$post = get_post($post_id);
577
+		if ( $post ) {
578 578
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
579 579
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
580
-        }
581
-        return '';
582
-    }
580
+		}
581
+		return '';
582
+	}
583 583
 
584 584
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
585
-    ?>
585
+	?>
586 586
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
587
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
588
-            ?> class="frm_multiselect">
587
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
588
+			?> class="frm_multiselect">
589 589
             <?php self::roles_options($capability); ?>
590 590
         </select>
591 591
     <?php
592
-    }
592
+	}
593 593
 
594 594
 	public static function roles_options( $capability ) {
595
-        global $frm_vars;
596
-        if ( isset($frm_vars['editable_roles']) ) {
597
-            $editable_roles = $frm_vars['editable_roles'];
598
-        } else {
599
-            $editable_roles = get_editable_roles();
600
-            $frm_vars['editable_roles'] = $editable_roles;
601
-        }
602
-
603
-        foreach ( $editable_roles as $role => $details ) {
604
-            $name = translate_user_role($details['name'] ); ?>
595
+		global $frm_vars;
596
+		if ( isset($frm_vars['editable_roles']) ) {
597
+			$editable_roles = $frm_vars['editable_roles'];
598
+		} else {
599
+			$editable_roles = get_editable_roles();
600
+			$frm_vars['editable_roles'] = $editable_roles;
601
+		}
602
+
603
+		foreach ( $editable_roles as $role => $details ) {
604
+			$name = translate_user_role($details['name'] ); ?>
605 605
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
606 606
 <?php
607
-            unset($role, $details);
608
-        }
609
-    }
607
+			unset($role, $details);
608
+		}
609
+	}
610 610
 
611 611
 	public static function frm_capabilities( $type = 'auto' ) {
612
-        $cap = array(
613
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
614
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
615
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
616
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
617
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
618
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
619
-        );
612
+		$cap = array(
613
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
614
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
615
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
616
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
617
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
618
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
619
+		);
620 620
 
621 621
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
622
-            return $cap;
623
-        }
622
+			return $cap;
623
+		}
624 624
 
625
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
626
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
627
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
628
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
625
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
626
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
627
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
628
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
629 629
 
630
-        return $cap;
631
-    }
630
+		return $cap;
631
+	}
632 632
 
633 633
 	public static function user_has_permission( $needed_role ) {
634
-        if ( $needed_role == '-1' ) {
635
-            return false;
634
+		if ( $needed_role == '-1' ) {
635
+			return false;
636 636
 		}
637 637
 
638
-        // $needed_role will be equal to blank if "Logged-in users" is selected
639
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
640
-            return true;
641
-        }
638
+		// $needed_role will be equal to blank if "Logged-in users" is selected
639
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
640
+			return true;
641
+		}
642 642
 
643
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
644
-        foreach ( $roles as $role ) {
643
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
644
+		foreach ( $roles as $role ) {
645 645
 			if ( current_user_can( $role ) ) {
646
-        		return true;
646
+				return true;
647 647
 			}
648
-        	if ( $role == $needed_role ) {
649
-        		break;
648
+			if ( $role == $needed_role ) {
649
+				break;
650 650
 			}
651
-        }
652
-        return false;
653
-    }
654
-
655
-    /**
656
-     * Make sure administrators can see Formidable menu
657
-     *
658
-     * @since 2.0
659
-     */
660
-    public static function maybe_add_permissions() {
651
+		}
652
+		return false;
653
+	}
654
+
655
+	/**
656
+	 * Make sure administrators can see Formidable menu
657
+	 *
658
+	 * @since 2.0
659
+	 */
660
+	public static function maybe_add_permissions() {
661 661
 		self::force_capability( 'frm_view_entries' );
662 662
 
663
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
664
-            return;
665
-        }
663
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
664
+			return;
665
+		}
666 666
 
667 667
 		$user_id = get_current_user_id();
668 668
 		$user = new WP_User( $user_id );
669
-        $frm_roles = self::frm_capabilities();
670
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
669
+		$frm_roles = self::frm_capabilities();
670
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
671 671
 			$user->add_cap( $frm_role );
672
-            unset($frm_role, $frm_role_description);
673
-        }
674
-    }
672
+			unset($frm_role, $frm_role_description);
673
+		}
674
+	}
675 675
 
676 676
 	/**
677 677
 	 * Make sure admins have permission to see the menu items
@@ -687,28 +687,28 @@  discard block
 block discarded – undo
687 687
 		}
688 688
 	}
689 689
 
690
-    /**
691
-     * Check if the user has permision for action.
692
-     * Return permission message and stop the action if no permission
693
-     * @since 2.0
694
-     * @param string $permission
695
-     */
690
+	/**
691
+	 * Check if the user has permision for action.
692
+	 * Return permission message and stop the action if no permission
693
+	 * @since 2.0
694
+	 * @param string $permission
695
+	 */
696 696
 	public static function permission_check( $permission, $show_message = 'show' ) {
697
-        $permission_error = self::permission_nonce_error($permission);
698
-        if ( $permission_error !== false ) {
699
-            if ( 'hide' == $show_message ) {
700
-                $permission_error = '';
701
-            }
702
-            wp_die($permission_error);
703
-        }
704
-    }
705
-
706
-    /**
707
-     * Check user permission and nonce
708
-     * @since 2.0
709
-     * @param string $permission
710
-     * @return false|string The permission message or false if allowed
711
-     */
697
+		$permission_error = self::permission_nonce_error($permission);
698
+		if ( $permission_error !== false ) {
699
+			if ( 'hide' == $show_message ) {
700
+				$permission_error = '';
701
+			}
702
+			wp_die($permission_error);
703
+		}
704
+	}
705
+
706
+	/**
707
+	 * Check user permission and nonce
708
+	 * @since 2.0
709
+	 * @param string $permission
710
+	 * @return false|string The permission message or false if allowed
711
+	 */
712 712
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
713 713
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
714 714
 			$frm_settings = self::get_settings();
@@ -716,23 +716,23 @@  discard block
 block discarded – undo
716 716
 		}
717 717
 
718 718
 		$error = false;
719
-        if ( empty($nonce_name) ) {
720
-            return $error;
721
-        }
719
+		if ( empty($nonce_name) ) {
720
+			return $error;
721
+		}
722 722
 
723
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
724
-            $frm_settings = self::get_settings();
725
-            $error = $frm_settings->admin_permission;
726
-        }
723
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
724
+			$frm_settings = self::get_settings();
725
+			$error = $frm_settings->admin_permission;
726
+		}
727 727
 
728
-        return $error;
729
-    }
728
+		return $error;
729
+	}
730 730
 
731
-    public static function checked( $values, $current ) {
731
+	public static function checked( $values, $current ) {
732 732
 		if ( self::check_selected( $values, $current ) ) {
733
-            echo ' checked="checked"';
733
+			echo ' checked="checked"';
734 734
 		}
735
-    }
735
+	}
736 736
 
737 737
 	public static function check_selected( $values, $current ) {
738 738
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -742,50 +742,50 @@  discard block
 block discarded – undo
742 742
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
743 743
 	}
744 744
 
745
-    /**
746
-    * Check if current field option is an "other" option
747
-    *
748
-    * @since 2.0
749
-    *
750
-    * @param string $opt_key
751
-    * @return boolean Returns true if current field option is an "Other" option
752
-    */
753
-    public static function is_other_opt( $opt_key ) {
754
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
755
-        return FrmFieldsHelper::is_other_opt( $opt_key );
756
-    }
757
-
758
-    /**
759
-    * Get value that belongs in "Other" text box
760
-    *
761
-    * @since 2.0
762
-    *
763
-    * @param string $opt_key
764
-    * @param array $field
765
-    * @return string $other_val
766
-    */
767
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
745
+	/**
746
+	 * Check if current field option is an "other" option
747
+	 *
748
+	 * @since 2.0
749
+	 *
750
+	 * @param string $opt_key
751
+	 * @return boolean Returns true if current field option is an "Other" option
752
+	 */
753
+	public static function is_other_opt( $opt_key ) {
754
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
755
+		return FrmFieldsHelper::is_other_opt( $opt_key );
756
+	}
757
+
758
+	/**
759
+	 * Get value that belongs in "Other" text box
760
+	 *
761
+	 * @since 2.0
762
+	 *
763
+	 * @param string $opt_key
764
+	 * @param array $field
765
+	 * @return string $other_val
766
+	 */
767
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
768 768
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
769 769
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
770
-    }
771
-
772
-    /**
773
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
774
-    * Intended for front-end use
775
-    *
776
-    * @since 2.0
777
-    *
778
-    * @param array $field
779
-    * @param boolean $other_opt
780
-    * @param string $checked
781
-    * @param array $args should include opt_key and field name
782
-    * @return string $other_val
783
-    */
784
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
770
+	}
771
+
772
+	/**
773
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
774
+	 * Intended for front-end use
775
+	 *
776
+	 * @since 2.0
777
+	 *
778
+	 * @param array $field
779
+	 * @param boolean $other_opt
780
+	 * @param string $checked
781
+	 * @param array $args should include opt_key and field name
782
+	 * @return string $other_val
783
+	 */
784
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
785 785
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
786 786
 		$args['field'] = $field;
787 787
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
788
-    }
788
+	}
789 789
 
790 790
 	public static function recursive_function_map( $value, $function ) {
791 791
 		if ( is_array( $value ) ) {
@@ -815,24 +815,24 @@  discard block
 block discarded – undo
815 815
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
816 816
 	}
817 817
 
818
-    /**
819
-     * Flatten a multi-dimensional array
820
-     */
818
+	/**
819
+	 * Flatten a multi-dimensional array
820
+	 */
821 821
 	public static function array_flatten( $array, $keys = 'keep' ) {
822
-        $return = array();
823
-        foreach ( $array as $key => $value ) {
824
-            if ( is_array($value) ) {
822
+		$return = array();
823
+		foreach ( $array as $key => $value ) {
824
+			if ( is_array($value) ) {
825 825
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
826
-            } else {
826
+			} else {
827 827
 				if ( $keys == 'keep' ) {
828 828
 					$return[ $key ] = $value;
829 829
 				} else {
830 830
 					$return[] = $value;
831 831
 				}
832
-            }
833
-        }
834
-        return $return;
835
-    }
832
+			}
833
+		}
834
+		return $return;
835
+	}
836 836
 
837 837
 	public static function esc_textarea( $text, $is_rich_text = false ) {
838 838
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -843,308 +843,308 @@  discard block
 block discarded – undo
843 843
 		return apply_filters( 'esc_textarea', $safe_text, $text );
844 844
 	}
845 845
 
846
-    /**
847
-     * Add auto paragraphs to text areas
848
-     * @since 2.0
849
-     */
846
+	/**
847
+	 * Add auto paragraphs to text areas
848
+	 * @since 2.0
849
+	 */
850 850
 	public static function use_wpautop( $content ) {
851
-        if ( apply_filters('frm_use_wpautop', true) ) {
852
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
853
-        }
854
-        return $content;
855
-    }
851
+		if ( apply_filters('frm_use_wpautop', true) ) {
852
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
853
+		}
854
+		return $content;
855
+	}
856 856
 
857 857
 	public static function replace_quotes( $val ) {
858
-        //Replace double quotes
858
+		//Replace double quotes
859 859
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
860
-        //Replace single quotes
861
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
862
-        return $val;
863
-    }
864
-
865
-    /**
866
-     * @since 2.0
867
-     * @return string The base Google APIS url for the current version of jQuery UI
868
-     */
869
-    public static function jquery_ui_base_url() {
860
+		//Replace single quotes
861
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
862
+		return $val;
863
+	}
864
+
865
+	/**
866
+	 * @since 2.0
867
+	 * @return string The base Google APIS url for the current version of jQuery UI
868
+	 */
869
+	public static function jquery_ui_base_url() {
870 870
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
871
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
872
-        return $url;
873
-    }
871
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
872
+		return $url;
873
+	}
874 874
 
875
-    /**
876
-     * @param string $handle
877
-     */
875
+	/**
876
+	 * @param string $handle
877
+	 */
878 878
 	public static function script_version( $handle ) {
879
-        global $wp_scripts;
880
-    	if ( ! $wp_scripts ) {
881
-    	    return false;
882
-    	}
879
+		global $wp_scripts;
880
+		if ( ! $wp_scripts ) {
881
+			return false;
882
+		}
883 883
 
884
-        $ver = 0;
884
+		$ver = 0;
885 885
 
886
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
887
-            return $ver;
888
-        }
886
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
887
+			return $ver;
888
+		}
889 889
 
890
-        $query = $wp_scripts->registered[ $handle ];
891
-    	if ( is_object( $query ) ) {
892
-    	    $ver = $query->ver;
893
-    	}
890
+		$query = $wp_scripts->registered[ $handle ];
891
+		if ( is_object( $query ) ) {
892
+			$ver = $query->ver;
893
+		}
894 894
 
895
-    	return $ver;
896
-    }
895
+		return $ver;
896
+	}
897 897
 
898 898
 	public static function js_redirect( $url ) {
899 899
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
900
-    }
900
+	}
901 901
 
902 902
 	public static function get_user_id_param( $user_id ) {
903
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
-            return $user_id;
905
-        }
903
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
+			return $user_id;
905
+		}
906 906
 
907 907
 		if ( $user_id == 'current' ) {
908 908
 			$user_id = get_current_user_id();
909 909
 		} else {
910
-            if ( is_email($user_id) ) {
911
-                $user = get_user_by('email', $user_id);
912
-            } else {
913
-                $user = get_user_by('login', $user_id);
914
-            }
910
+			if ( is_email($user_id) ) {
911
+				$user = get_user_by('email', $user_id);
912
+			} else {
913
+				$user = get_user_by('login', $user_id);
914
+			}
915 915
 
916
-            if ( $user ) {
917
-                $user_id = $user->ID;
918
-            }
919
-            unset($user);
920
-        }
916
+			if ( $user ) {
917
+				$user_id = $user->ID;
918
+			}
919
+			unset($user);
920
+		}
921 921
 
922
-        return $user_id;
923
-    }
922
+		return $user_id;
923
+	}
924 924
 
925 925
 	public static function get_file_contents( $filename, $atts = array() ) {
926
-        if ( ! is_file($filename) ) {
927
-            return false;
928
-        }
929
-
930
-        extract($atts);
931
-        ob_start();
932
-        include($filename);
933
-        $contents = ob_get_contents();
934
-        ob_end_clean();
935
-        return $contents;
936
-    }
937
-
938
-    /**
939
-     * @param string $table_name
940
-     * @param string $column
926
+		if ( ! is_file($filename) ) {
927
+			return false;
928
+		}
929
+
930
+		extract($atts);
931
+		ob_start();
932
+		include($filename);
933
+		$contents = ob_get_contents();
934
+		ob_end_clean();
935
+		return $contents;
936
+	}
937
+
938
+	/**
939
+	 * @param string $table_name
940
+	 * @param string $column
941 941
 	 * @param int $id
942 942
 	 * @param int $num_chars
943
-     */
944
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
-        $key = '';
943
+	 */
944
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
+		$key = '';
946 946
 
947
-        if ( ! empty( $name ) ) {
948
-            $key = sanitize_key($name);
949
-        }
947
+		if ( ! empty( $name ) ) {
948
+			$key = sanitize_key($name);
949
+		}
950 950
 
951 951
 		if ( empty( $key ) ) {
952
-            $max_slug_value = pow(36, $num_chars);
953
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
954
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
-        }
952
+			$max_slug_value = pow(36, $num_chars);
953
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
954
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
+		}
956 956
 
957 957
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
958 958
 			$key = $key . 'a';
959
-        }
959
+		}
960 960
 
961 961
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
962 962
 
963
-        if ( $key_check || is_numeric($key_check) ) {
964
-            $suffix = 2;
963
+		if ( $key_check || is_numeric($key_check) ) {
964
+			$suffix = 2;
965 965
 			do {
966 966
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
967 967
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
968 968
 				$suffix++;
969 969
 			} while ($key_check || is_numeric($key_check));
970 970
 			$key = $alt_post_name;
971
-        }
972
-        return $key;
973
-    }
974
-
975
-    /**
976
-     * Editing a Form or Entry
977
-     * @param string $table
978
-     * @return bool|array
979
-     */
980
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
-        if ( ! $record ) {
982
-            return false;
983
-        }
984
-
985
-        if ( empty($post_values) ) {
986
-            $post_values = stripslashes_deep($_POST);
987
-        }
971
+		}
972
+		return $key;
973
+	}
974
+
975
+	/**
976
+	 * Editing a Form or Entry
977
+	 * @param string $table
978
+	 * @return bool|array
979
+	 */
980
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
+		if ( ! $record ) {
982
+			return false;
983
+		}
984
+
985
+		if ( empty($post_values) ) {
986
+			$post_values = stripslashes_deep($_POST);
987
+		}
988 988
 
989 989
 		$values = array( 'id' => $record->id, 'fields' => array() );
990 990
 
991 991
 		foreach ( array( 'name', 'description' ) as $var ) {
992
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
992
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
993 993
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
994
-            unset($var, $default_val);
995
-        }
996
-
997
-        $values['description'] = self::use_wpautop($values['description']);
998
-        $frm_settings = self::get_settings();
999
-        $is_form_builder = self::is_admin_page('formidable' );
1000
-
1001
-        foreach ( (array) $fields as $field ) {
1002
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
1003
-            if ( ! $is_form_builder ) {
1004
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
-            }
994
+			unset($var, $default_val);
995
+		}
996
+
997
+		$values['description'] = self::use_wpautop($values['description']);
998
+		$frm_settings = self::get_settings();
999
+		$is_form_builder = self::is_admin_page('formidable' );
1000
+
1001
+		foreach ( (array) $fields as $field ) {
1002
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
1003
+			if ( ! $is_form_builder ) {
1004
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
+			}
1006 1006
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1007 1007
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1008
-        }
1008
+		}
1009 1009
 
1010
-        self::fill_form_opts($record, $table, $post_values, $values);
1010
+		self::fill_form_opts($record, $table, $post_values, $values);
1011 1011
 
1012
-        if ( $table == 'entries' ) {
1013
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
-        } else if ( $table == 'forms' ) {
1015
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
-        }
1012
+		if ( $table == 'entries' ) {
1013
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
+		} else if ( $table == 'forms' ) {
1015
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
+		}
1017 1017
 
1018
-        return $values;
1019
-    }
1018
+		return $values;
1019
+	}
1020 1020
 
1021 1021
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1022
-        $post_values = $args['post_values'];
1023
-
1024
-        if ( $args['default'] ) {
1025
-            $meta_value = $field->default_value;
1026
-        } else {
1027
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
-                if ( ! isset($field->field_options['custom_field']) ) {
1029
-                    $field->field_options['custom_field'] = '';
1030
-                }
1022
+		$post_values = $args['post_values'];
1023
+
1024
+		if ( $args['default'] ) {
1025
+			$meta_value = $field->default_value;
1026
+		} else {
1027
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
+				if ( ! isset($field->field_options['custom_field']) ) {
1029
+					$field->field_options['custom_field'] = '';
1030
+				}
1031 1031
 				$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 ) );
1032
-            } else {
1032
+			} else {
1033 1033
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1034
-            }
1035
-        }
1034
+			}
1035
+		}
1036 1036
 
1037 1037
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1038
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
-
1040
-        $field_array = array(
1041
-            'id'            => $field->id,
1042
-            'value'         => $new_value,
1043
-            'default_value' => $field->default_value,
1044
-            'name'          => $field->name,
1045
-            'description'   => $field->description,
1046
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
-            'options'       => $field->options,
1048
-            'required'      => $field->required,
1049
-            'field_key'     => $field->field_key,
1050
-            'field_order'   => $field->field_order,
1051
-            'form_id'       => $field->form_id,
1038
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
+
1040
+		$field_array = array(
1041
+			'id'            => $field->id,
1042
+			'value'         => $new_value,
1043
+			'default_value' => $field->default_value,
1044
+			'name'          => $field->name,
1045
+			'description'   => $field->description,
1046
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
+			'options'       => $field->options,
1048
+			'required'      => $field->required,
1049
+			'field_key'     => $field->field_key,
1050
+			'field_order'   => $field->field_order,
1051
+			'form_id'       => $field->form_id,
1052 1052
 			'parent_form_id' => $args['parent_form_id'],
1053
-        );
1053
+		);
1054 1054
 
1055
-        $args['field_type'] = $field_type;
1056
-        self::fill_field_opts($field, $field_array, $args);
1055
+		$args['field_type'] = $field_type;
1056
+		self::fill_field_opts($field, $field_array, $args);
1057 1057
 		// Track the original field's type
1058 1058
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1059 1059
 
1060
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1060
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1061 1061
 
1062
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
-            $field_array['unique_msg'] = '';
1064
-        }
1062
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
+			$field_array['unique_msg'] = '';
1064
+		}
1065 1065
 
1066
-        $field_array = array_merge( $field->field_options, $field_array );
1066
+		$field_array = array_merge( $field->field_options, $field_array );
1067 1067
 
1068
-        $values['fields'][ $field->id ] = $field_array;
1069
-    }
1068
+		$values['fields'][ $field->id ] = $field_array;
1069
+	}
1070 1070
 
1071 1071
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1072
-        $post_values = $args['post_values'];
1073
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1072
+		$post_values = $args['post_values'];
1073
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1074 1074
 
1075
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1075
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1076 1076
 			$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 );
1077
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
-                if ( $args['field_type'] == 'captcha' ) {
1081
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
-                } else {
1083
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
-                }
1085
-            }
1086
-        }
1087
-
1088
-        if ( $field_array['custom_html'] == '' ) {
1089
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
-        }
1091
-    }
1092
-
1093
-    /**
1094
-     * @param string $table
1095
-     */
1077
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
+				if ( $args['field_type'] == 'captcha' ) {
1081
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
+				} else {
1083
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
+				}
1085
+			}
1086
+		}
1087
+
1088
+		if ( $field_array['custom_html'] == '' ) {
1089
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
+		}
1091
+	}
1092
+
1093
+	/**
1094
+	 * @param string $table
1095
+	 */
1096 1096
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1097
-        if ( $table == 'entries' ) {
1098
-            $form = $record->form_id;
1097
+		if ( $table == 'entries' ) {
1098
+			$form = $record->form_id;
1099 1099
 			FrmForm::maybe_get_form( $form );
1100
-        } else {
1101
-            $form = $record;
1102
-        }
1100
+		} else {
1101
+			$form = $record;
1102
+		}
1103 1103
 
1104
-        if ( ! $form ) {
1105
-            return;
1106
-        }
1104
+		if ( ! $form ) {
1105
+			return;
1106
+		}
1107 1107
 
1108
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1108
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1109 1109
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1110 1110
 
1111
-        if ( ! is_array($form->options) ) {
1112
-            return;
1113
-        }
1111
+		if ( ! is_array($form->options) ) {
1112
+			return;
1113
+		}
1114 1114
 
1115
-        foreach ( $form->options as $opt => $value ) {
1116
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
-        }
1115
+		foreach ( $form->options as $opt => $value ) {
1116
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
+		}
1118 1118
 
1119
-        self::fill_form_defaults($post_values, $values);
1120
-    }
1119
+		self::fill_form_defaults($post_values, $values);
1120
+	}
1121 1121
 
1122
-    /**
1123
-     * Set to POST value or default
1124
-     */
1122
+	/**
1123
+	 * Set to POST value or default
1124
+	 */
1125 1125
 	private static function fill_form_defaults( $post_values, array &$values ) {
1126
-        $form_defaults = FrmFormsHelper::get_default_opts();
1126
+		$form_defaults = FrmFormsHelper::get_default_opts();
1127 1127
 
1128
-        foreach ( $form_defaults as $opt => $default ) {
1129
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1128
+		foreach ( $form_defaults as $opt => $default ) {
1129
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1130 1130
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1131
-            }
1131
+			}
1132 1132
 
1133
-            unset($opt, $defaut);
1134
-        }
1133
+			unset($opt, $defaut);
1134
+		}
1135 1135
 
1136
-        if ( ! isset($values['custom_style']) ) {
1137
-            $frm_settings = self::get_settings();
1136
+		if ( ! isset($values['custom_style']) ) {
1137
+			$frm_settings = self::get_settings();
1138 1138
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1139
-        }
1139
+		}
1140 1140
 
1141 1141
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1142 1142
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1143 1143
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1144
-            }
1145
-            unset($h);
1146
-        }
1147
-    }
1144
+			}
1145
+			unset($h);
1146
+		}
1147
+	}
1148 1148
 
1149 1149
 	public static function get_meta_value( $field_id, $entry ) {
1150 1150
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1152,59 +1152,59 @@  discard block
 block discarded – undo
1152 1152
 	}
1153 1153
 
1154 1154
 	public static function insert_opt_html( $args ) {
1155
-        $class = '';
1156
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1157
-            $class .= 'show_frm_not_email_to';
1158
-        }
1159
-    ?>
1155
+		$class = '';
1156
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1157
+			$class .= 'show_frm_not_email_to';
1158
+		}
1159
+	?>
1160 1160
 <li>
1161 1161
     <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>
1162 1162
     <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>
1163 1163
     <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>
1164 1164
 </li>
1165 1165
     <?php
1166
-    }
1166
+	}
1167 1167
 
1168 1168
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1169
-        if ( is_array( $str ) ) {
1170
-            return '';
1169
+		if ( is_array( $str ) ) {
1170
+			return '';
1171 1171
 		}
1172 1172
 
1173
-        $length = (int) $length;
1173
+		$length = (int) $length;
1174 1174
 		$str = wp_strip_all_tags( $str );
1175 1175
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1176 1176
 
1177 1177
 		if ( $length == 0 ) {
1178
-            return '';
1179
-        } else if ( $length <= 10 ) {
1178
+			return '';
1179
+		} else if ( $length <= 10 ) {
1180 1180
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1181
-            return $sub . (($length < $original_len) ? $continue : '');
1182
-        }
1181
+			return $sub . (($length < $original_len) ? $continue : '');
1182
+		}
1183 1183
 
1184
-        $sub = '';
1185
-        $len = 0;
1184
+		$sub = '';
1185
+		$len = 0;
1186 1186
 
1187 1187
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1188 1188
 
1189 1189
 		foreach ( $words as $word ) {
1190
-            $part = (($sub != '') ? ' ' : '') . $word;
1190
+			$part = (($sub != '') ? ' ' : '') . $word;
1191 1191
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1192
-            if ( $total_len > $length && str_word_count($sub) ) {
1193
-                break;
1194
-            }
1192
+			if ( $total_len > $length && str_word_count($sub) ) {
1193
+				break;
1194
+			}
1195 1195
 
1196
-            $sub .= $part;
1196
+			$sub .= $part;
1197 1197
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1198 1198
 
1199
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1200
-                break;
1201
-            }
1199
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1200
+				break;
1201
+			}
1202 1202
 
1203
-            unset($total_len, $word);
1204
-        }
1203
+			unset($total_len, $word);
1204
+		}
1205 1205
 
1206
-        return $sub . (($len < $original_len) ? $continue : '');
1207
-    }
1206
+		return $sub . (($len < $original_len) ? $continue : '');
1207
+	}
1208 1208
 
1209 1209
 	public static function mb_function( $function_names, $args ) {
1210 1210
 		$mb_function_name = $function_names[0];
@@ -1216,18 +1216,18 @@  discard block
 block discarded – undo
1216 1216
 	}
1217 1217
 
1218 1218
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1219
-        if ( empty($date) ) {
1220
-            return $date;
1221
-        }
1219
+		if ( empty($date) ) {
1220
+			return $date;
1221
+		}
1222 1222
 
1223
-        if ( empty($date_format) ) {
1224
-            $date_format = get_option('date_format');
1225
-        }
1223
+		if ( empty($date_format) ) {
1224
+			$date_format = get_option('date_format');
1225
+		}
1226 1226
 
1227
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1228
-            $frmpro_settings = new FrmProSettings();
1229
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1230
-        }
1227
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1228
+			$frmpro_settings = new FrmProSettings();
1229
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1230
+		}
1231 1231
 
1232 1232
 		$formatted = self::get_localized_date( $date_format, $date );
1233 1233
 
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
 			$formatted .= self::add_time_to_date( $time_format, $date );
1237 1237
 		}
1238 1238
 
1239
-        return $formatted;
1240
-    }
1239
+		return $formatted;
1240
+	}
1241 1241
 
1242 1242
 	private static function add_time_to_date( $time_format, $date ) {
1243 1243
 		if ( empty( $time_format ) ) {
@@ -1318,61 +1318,61 @@  discard block
 block discarded – undo
1318 1318
 		);
1319 1319
 	}
1320 1320
 
1321
-    /**
1322
-     * Added for < WP 4.0 compatability
1323
-     *
1324
-     * @since 1.07.10
1325
-     *
1326
-     * @param string $term The value to escape
1327
-     * @return string The escaped value
1328
-     */
1321
+	/**
1322
+	 * Added for < WP 4.0 compatability
1323
+	 *
1324
+	 * @since 1.07.10
1325
+	 *
1326
+	 * @param string $term The value to escape
1327
+	 * @return string The escaped value
1328
+	 */
1329 1329
 	public static function esc_like( $term ) {
1330
-        global $wpdb;
1331
-        if ( method_exists($wpdb, 'esc_like') ) {
1330
+		global $wpdb;
1331
+		if ( method_exists($wpdb, 'esc_like') ) {
1332 1332
 			// WP 4.0
1333
-            $term = $wpdb->esc_like( $term );
1334
-        } else {
1335
-            $term = like_escape( $term );
1336
-        }
1333
+			$term = $wpdb->esc_like( $term );
1334
+		} else {
1335
+			$term = like_escape( $term );
1336
+		}
1337 1337
 
1338
-        return $term;
1339
-    }
1338
+		return $term;
1339
+	}
1340 1340
 
1341
-    /**
1342
-     * @param string $order_query
1343
-     */
1341
+	/**
1342
+	 * @param string $order_query
1343
+	 */
1344 1344
 	public static function esc_order( $order_query ) {
1345
-        if ( empty($order_query) ) {
1346
-            return '';
1347
-        }
1348
-
1349
-        // remove ORDER BY before santizing
1350
-        $order_query = strtolower($order_query);
1351
-        if ( strpos($order_query, 'order by') !== false ) {
1352
-            $order_query = str_replace('order by', '', $order_query);
1353
-        }
1354
-
1355
-        $order_query = explode(' ', trim($order_query));
1356
-
1357
-        $order_fields = array(
1358
-            'id', 'form_key', 'name', 'description',
1359
-            'parent_form_id', 'logged_in', 'is_template',
1360
-            'default_template', 'status', 'created_at',
1361
-        );
1362
-
1363
-        $order = trim(trim(reset($order_query), ','));
1364
-        if ( ! in_array($order, $order_fields) ) {
1365
-            return '';
1366
-        }
1367
-
1368
-        $order_by = '';
1369
-        if ( count($order_query) > 1 ) {
1345
+		if ( empty($order_query) ) {
1346
+			return '';
1347
+		}
1348
+
1349
+		// remove ORDER BY before santizing
1350
+		$order_query = strtolower($order_query);
1351
+		if ( strpos($order_query, 'order by') !== false ) {
1352
+			$order_query = str_replace('order by', '', $order_query);
1353
+		}
1354
+
1355
+		$order_query = explode(' ', trim($order_query));
1356
+
1357
+		$order_fields = array(
1358
+			'id', 'form_key', 'name', 'description',
1359
+			'parent_form_id', 'logged_in', 'is_template',
1360
+			'default_template', 'status', 'created_at',
1361
+		);
1362
+
1363
+		$order = trim(trim(reset($order_query), ','));
1364
+		if ( ! in_array($order, $order_fields) ) {
1365
+			return '';
1366
+		}
1367
+
1368
+		$order_by = '';
1369
+		if ( count($order_query) > 1 ) {
1370 1370
 			$order_by = end( $order_query );
1371 1371
 			self::esc_order_by( $order_by );
1372
-        }
1372
+		}
1373 1373
 
1374 1374
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1375
-    }
1375
+	}
1376 1376
 
1377 1377
 	/**
1378 1378
 	 * Make sure this is ordering by either ASC or DESC
@@ -1384,169 +1384,169 @@  discard block
 block discarded – undo
1384 1384
 		}
1385 1385
 	}
1386 1386
 
1387
-    /**
1388
-     * @param string $limit
1389
-     */
1387
+	/**
1388
+	 * @param string $limit
1389
+	 */
1390 1390
 	public static function esc_limit( $limit ) {
1391
-        if ( empty($limit) ) {
1392
-            return '';
1393
-        }
1391
+		if ( empty($limit) ) {
1392
+			return '';
1393
+		}
1394 1394
 
1395
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1396
-        if ( is_numeric($limit) ) {
1395
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1396
+		if ( is_numeric($limit) ) {
1397 1397
 			return ' LIMIT ' . $limit;
1398
-        }
1398
+		}
1399 1399
 
1400
-        $limit = explode(',', trim($limit));
1401
-        foreach ( $limit as $k => $l ) {
1402
-            if ( is_numeric( $l ) ) {
1403
-                $limit[ $k ] = $l;
1404
-            }
1405
-        }
1400
+		$limit = explode(',', trim($limit));
1401
+		foreach ( $limit as $k => $l ) {
1402
+			if ( is_numeric( $l ) ) {
1403
+				$limit[ $k ] = $l;
1404
+			}
1405
+		}
1406 1406
 
1407
-        $limit = implode(',', $limit);
1407
+		$limit = implode(',', $limit);
1408 1408
 		return ' LIMIT ' . $limit;
1409
-    }
1410
-
1411
-    /**
1412
-     * Get an array of values ready to go through $wpdb->prepare
1413
-     * @since 2.0
1414
-     */
1415
-    public static function prepare_array_values( $array, $type = '%s' ) {
1416
-        $placeholders = array_fill(0, count($array), $type);
1417
-        return implode(', ', $placeholders);
1418
-    }
1419
-
1420
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1421
-        if ( empty($where) ) {
1422
-            return '';
1423
-        }
1409
+	}
1410
+
1411
+	/**
1412
+	 * Get an array of values ready to go through $wpdb->prepare
1413
+	 * @since 2.0
1414
+	 */
1415
+	public static function prepare_array_values( $array, $type = '%s' ) {
1416
+		$placeholders = array_fill(0, count($array), $type);
1417
+		return implode(', ', $placeholders);
1418
+	}
1419
+
1420
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1421
+		if ( empty($where) ) {
1422
+			return '';
1423
+		}
1424 1424
 
1425 1425
 		if ( is_array( $where ) ) {
1426
-            global $wpdb;
1427
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1426
+			global $wpdb;
1427
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1428 1428
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1429 1429
 		} else {
1430
-            $where = $starts_with . $where;
1431
-        }
1430
+			$where = $starts_with . $where;
1431
+		}
1432 1432
 
1433
-        return $where;
1434
-    }
1433
+		return $where;
1434
+	}
1435 1435
 
1436
-    // Pagination Methods
1436
+	// Pagination Methods
1437 1437
 
1438
-    /**
1439
-     * @param integer $current_p
1440
-     */
1438
+	/**
1439
+	 * @param integer $current_p
1440
+	 */
1441 1441
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1442 1442
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1443 1443
 	}
1444 1444
 
1445
-    /**
1446
-     * @param integer $current_p
1447
-     */
1448
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1449
-        if ( $current_p == 1 ) {
1450
-            return 1;
1451
-        } else {
1452
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1453
-        }
1454
-    }
1445
+	/**
1446
+	 * @param integer $current_p
1447
+	 */
1448
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1449
+		if ( $current_p == 1 ) {
1450
+			return 1;
1451
+		} else {
1452
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1453
+		}
1454
+	}
1455 1455
 
1456 1456
 	/**
1457 1457
 	 * @return array
1458 1458
 	 */
1459 1459
 	public static function json_to_array( $json_vars ) {
1460
-        $vars = array();
1461
-        foreach ( $json_vars as $jv ) {
1462
-            $jv_name = explode('[', $jv['name']);
1463
-            $last = count($jv_name) - 1;
1464
-            foreach ( $jv_name as $p => $n ) {
1465
-                $name = trim($n, ']');
1466
-                if ( ! isset($l1) ) {
1467
-                    $l1 = $name;
1468
-                }
1469
-
1470
-                if ( ! isset($l2) ) {
1471
-                    $l2 = $name;
1472
-                }
1473
-
1474
-                if ( ! isset($l3) ) {
1475
-                    $l3 = $name;
1476
-                }
1477
-
1478
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1479
-
1480
-                switch ( $p ) {
1481
-                    case 0:
1482
-                        $l1 = $name;
1483
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1484
-                    break;
1485
-
1486
-                    case 1:
1487
-                        $l2 = $name;
1488
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1489
-                    break;
1490
-
1491
-                    case 2:
1492
-                        $l3 = $name;
1493
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1494
-                    break;
1495
-
1496
-                    case 3:
1497
-                        $l4 = $name;
1498
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1499
-                    break;
1500
-                }
1501
-
1502
-                unset($this_val, $n);
1503
-            }
1504
-
1505
-            unset($last, $jv);
1506
-        }
1507
-
1508
-        return $vars;
1509
-    }
1510
-
1511
-    /**
1512
-     * @param string $name
1513
-     * @param string $l1
1514
-     */
1515
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1516
-        if ( $name == '' ) {
1517
-            $vars[] = $val;
1518
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1519
-            $vars[ $l1 ] = $val;
1520
-        }
1521
-    }
1460
+		$vars = array();
1461
+		foreach ( $json_vars as $jv ) {
1462
+			$jv_name = explode('[', $jv['name']);
1463
+			$last = count($jv_name) - 1;
1464
+			foreach ( $jv_name as $p => $n ) {
1465
+				$name = trim($n, ']');
1466
+				if ( ! isset($l1) ) {
1467
+					$l1 = $name;
1468
+				}
1469
+
1470
+				if ( ! isset($l2) ) {
1471
+					$l2 = $name;
1472
+				}
1473
+
1474
+				if ( ! isset($l3) ) {
1475
+					$l3 = $name;
1476
+				}
1477
+
1478
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1479
+
1480
+				switch ( $p ) {
1481
+					case 0:
1482
+						$l1 = $name;
1483
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1484
+					break;
1485
+
1486
+					case 1:
1487
+						$l2 = $name;
1488
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1489
+					break;
1490
+
1491
+					case 2:
1492
+						$l3 = $name;
1493
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1494
+					break;
1495
+
1496
+					case 3:
1497
+						$l4 = $name;
1498
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1499
+					break;
1500
+				}
1501
+
1502
+				unset($this_val, $n);
1503
+			}
1504
+
1505
+			unset($last, $jv);
1506
+		}
1507
+
1508
+		return $vars;
1509
+	}
1510
+
1511
+	/**
1512
+	 * @param string $name
1513
+	 * @param string $l1
1514
+	 */
1515
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1516
+		if ( $name == '' ) {
1517
+			$vars[] = $val;
1518
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1519
+			$vars[ $l1 ] = $val;
1520
+		}
1521
+	}
1522 1522
 
1523 1523
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1524
-        $tooltips = array(
1525
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1526
-            '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' ),
1527
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1528
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1529
-            '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' ),
1530
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1531
-            '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() ) ),
1532
-        );
1533
-
1534
-        if ( ! isset( $tooltips[ $name ] ) ) {
1535
-            return;
1536
-        }
1537
-
1538
-        if ( 'open' == $class ) {
1539
-            echo ' frm_help"';
1540
-        } else {
1541
-            echo ' class="frm_help"';
1542
-        }
1524
+		$tooltips = array(
1525
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1526
+			'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' ),
1527
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1528
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1529
+			'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' ),
1530
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1531
+			'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() ) ),
1532
+		);
1533
+
1534
+		if ( ! isset( $tooltips[ $name ] ) ) {
1535
+			return;
1536
+		}
1537
+
1538
+		if ( 'open' == $class ) {
1539
+			echo ' frm_help"';
1540
+		} else {
1541
+			echo ' class="frm_help"';
1542
+		}
1543 1543
 
1544 1544
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1545 1545
 
1546
-        if ( 'open' != $class ) {
1547
-            echo '"';
1548
-        }
1549
-    }
1546
+		if ( 'open' != $class ) {
1547
+			echo '"';
1548
+		}
1549
+	}
1550 1550
 
1551 1551
 	/**
1552 1552
 	 * Add the current_page class to that page in the form nav
@@ -1562,35 +1562,35 @@  discard block
 block discarded – undo
1562 1562
 		}
1563 1563
 	}
1564 1564
 
1565
-    /**
1566
-     * Prepare and json_encode post content
1567
-     *
1568
-     * @since 2.0
1569
-     *
1570
-     * @param array $post_content
1571
-     * @return string $post_content ( json encoded array )
1572
-     */
1573
-    public static function prepare_and_encode( $post_content ) {
1574
-        //Loop through array to strip slashes and add only the needed ones
1565
+	/**
1566
+	 * Prepare and json_encode post content
1567
+	 *
1568
+	 * @since 2.0
1569
+	 *
1570
+	 * @param array $post_content
1571
+	 * @return string $post_content ( json encoded array )
1572
+	 */
1573
+	public static function prepare_and_encode( $post_content ) {
1574
+		//Loop through array to strip slashes and add only the needed ones
1575 1575
 		foreach ( $post_content as $key => $val ) {
1576 1576
 			// Replace problematic characters (like &quot;)
1577 1577
 			$val = str_replace( '&quot;', '"', $val );
1578 1578
 
1579 1579
 			self::prepare_action_slashes( $val, $key, $post_content );
1580
-            unset( $key, $val );
1581
-        }
1580
+			unset( $key, $val );
1581
+		}
1582 1582
 
1583
-        // json_encode the array
1584
-        $post_content = json_encode( $post_content );
1583
+		// json_encode the array
1584
+		$post_content = json_encode( $post_content );
1585 1585
 
1586
-	    // add extra slashes for \r\n since WP strips them
1586
+		// add extra slashes for \r\n since WP strips them
1587 1587
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1588 1588
 
1589
-        // allow for &quot
1590
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1589
+		// allow for &quot
1590
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1591 1591
 
1592
-        return $post_content;
1593
-    }
1592
+		return $post_content;
1593
+	}
1594 1594
 
1595 1595
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1596 1596
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1658,64 +1658,64 @@  discard block
 block discarded – undo
1658 1658
 	}
1659 1659
 
1660 1660
 	public static function maybe_json_decode( $string ) {
1661
-        if ( is_array($string) ) {
1662
-            return $string;
1663
-        }
1661
+		if ( is_array($string) ) {
1662
+			return $string;
1663
+		}
1664 1664
 
1665
-        $new_string = json_decode($string, true);
1666
-        if ( function_exists('json_last_error') ) {
1665
+		$new_string = json_decode($string, true);
1666
+		if ( function_exists('json_last_error') ) {
1667 1667
 			// php 5.3+
1668
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1669
-                $string = $new_string;
1670
-            }
1671
-        } else if ( isset($new_string) ) {
1668
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1669
+				$string = $new_string;
1670
+			}
1671
+		} else if ( isset($new_string) ) {
1672 1672
 			// php < 5.3 fallback
1673
-            $string = $new_string;
1674
-        }
1675
-        return $string;
1676
-    }
1677
-
1678
-    /**
1679
-     * @since 1.07.10
1680
-     *
1681
-     * @param string $post_type The name of the post type that may need to be highlighted
1682
-     * echo The javascript to open and highlight the Formidable menu
1683
-     */
1673
+			$string = $new_string;
1674
+		}
1675
+		return $string;
1676
+	}
1677
+
1678
+	/**
1679
+	 * @since 1.07.10
1680
+	 *
1681
+	 * @param string $post_type The name of the post type that may need to be highlighted
1682
+	 * echo The javascript to open and highlight the Formidable menu
1683
+	 */
1684 1684
 	public static function maybe_highlight_menu( $post_type ) {
1685
-        global $post;
1685
+		global $post;
1686 1686
 
1687
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1688
-            return;
1689
-        }
1687
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1688
+			return;
1689
+		}
1690 1690
 
1691
-        if ( is_object($post) && $post->post_type != $post_type ) {
1692
-            return;
1693
-        }
1691
+		if ( is_object($post) && $post->post_type != $post_type ) {
1692
+			return;
1693
+		}
1694 1694
 
1695
-        self::load_admin_wide_js();
1696
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1697
-    }
1695
+		self::load_admin_wide_js();
1696
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1697
+	}
1698 1698
 
1699
-    /**
1700
-     * Load the JS file on non-Formidable pages in the admin area
1701
-     * @since 2.0
1702
-     */
1699
+	/**
1700
+	 * Load the JS file on non-Formidable pages in the admin area
1701
+	 * @since 2.0
1702
+	 */
1703 1703
 	public static function load_admin_wide_js( $load = true ) {
1704
-        $version = FrmAppHelper::plugin_version();
1704
+		$version = FrmAppHelper::plugin_version();
1705 1705
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1706 1706
 
1707
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1707
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1708 1708
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1709
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1709
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1710 1710
 			'url'          => FrmAppHelper::plugin_url(),
1711 1711
 			'loading'      => __( 'Loading&hellip;' ),
1712 1712
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1713
-        ) );
1713
+		) );
1714 1714
 
1715 1715
 		if ( $load ) {
1716 1716
 			wp_enqueue_script( 'formidable_admin_global' );
1717 1717
 		}
1718
-    }
1718
+	}
1719 1719
 
1720 1720
 	/**
1721 1721
 	 * @since 2.0.9
@@ -1724,9 +1724,9 @@  discard block
 block discarded – undo
1724 1724
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1725 1725
 	}
1726 1726
 
1727
-    /**
1728
-     * @param string $location
1729
-     */
1727
+	/**
1728
+	 * @param string $location
1729
+	 */
1730 1730
 	public static function localize_script( $location ) {
1731 1731
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1732 1732
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1779,81 +1779,81 @@  discard block
 block discarded – undo
1779 1779
 		}
1780 1780
 	}
1781 1781
 
1782
-    /**
1782
+	/**
1783 1783
 	 * echo the message on the plugins listing page
1784
-     * @since 1.07.10
1785
-     *
1786
-     * @param float $min_version The version the add-on requires
1787
-     */
1784
+	 * @since 1.07.10
1785
+	 *
1786
+	 * @param float $min_version The version the add-on requires
1787
+	 */
1788 1788
 	public static function min_version_notice( $min_version ) {
1789
-        $frm_version = self::plugin_version();
1789
+		$frm_version = self::plugin_version();
1790 1790
 
1791
-        // check if Formidable meets minimum requirements
1792
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1793
-            return;
1794
-        }
1791
+		// check if Formidable meets minimum requirements
1792
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1793
+			return;
1794
+		}
1795 1795
 
1796
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1796
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1797 1797
 		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">' .
1798
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1799
-        '</div></td></tr>';
1800
-    }
1801
-
1802
-    public static function locales( $type = 'date' ) {
1803
-        $locales = array(
1804
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1805
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1806
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1807
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1808
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1809
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1810
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1811
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1812
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1813
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1814
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1815
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1816
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1817
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1818
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1819
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1820
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1821
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1822
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1823
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1824
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1825
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1826
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1827
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1828
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1829
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1830
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1831
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1832
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1833
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1834
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1835
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1836
-        );
1837
-
1838
-        if ( $type == 'captcha' ) {
1839
-            // remove the languages unavailable for the captcha
1840
-            $unset = array(
1841
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1842
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1843
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1844
-            );
1845
-        } else {
1846
-            // remove the languages unavailable for the datepicker
1847
-            $unset = array(
1848
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1849
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1850
-                'es-419', 'tr',
1851
-            );
1852
-        }
1853
-
1854
-        $locales = array_diff_key($locales, array_flip($unset));
1855
-        $locales = apply_filters('frm_locales', $locales);
1856
-
1857
-        return $locales;
1858
-    }
1798
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1799
+		'</div></td></tr>';
1800
+	}
1801
+
1802
+	public static function locales( $type = 'date' ) {
1803
+		$locales = array(
1804
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1805
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1806
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1807
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1808
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1809
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1810
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1811
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1812
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1813
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1814
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1815
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1816
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1817
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1818
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1819
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1820
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1821
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1822
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1823
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1824
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1825
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1826
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1827
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1828
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1829
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1830
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1831
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1832
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1833
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1834
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1835
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1836
+		);
1837
+
1838
+		if ( $type == 'captcha' ) {
1839
+			// remove the languages unavailable for the captcha
1840
+			$unset = array(
1841
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1842
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1843
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1844
+			);
1845
+		} else {
1846
+			// remove the languages unavailable for the datepicker
1847
+			$unset = array(
1848
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1849
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1850
+				'es-419', 'tr',
1851
+			);
1852
+		}
1853
+
1854
+		$locales = array_diff_key($locales, array_flip($unset));
1855
+		$locales = apply_filters('frm_locales', $locales);
1856
+
1857
+		return $locales;
1858
+	}
1859 1859
 }
Please login to merge, or discard this patch.
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 	public static function get_affiliate() {
69 69
 		return '';
70
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
70
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
71 71
 		$affiliate_id = strtolower( $affiliate_id );
72 72
 		$allowed_affiliates = array();
73 73
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function get_settings() {
88 88
         global $frm_settings;
89
-        if ( empty($frm_settings) ) {
89
+        if ( empty( $frm_settings ) ) {
90 90
             $frm_settings = new FrmSettings();
91 91
         }
92 92
         return $frm_settings;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
     public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
110
+        return apply_filters( 'frm_pro_installed', false );
111 111
     }
112 112
 
113 113
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @return boolean
152 152
      */
153 153
     public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
155 155
     }
156 156
 
157 157
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return boolean
172 172
      */
173 173
     public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
175 175
     }
176 176
 
177 177
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return string
199 199
      */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
202 202
     }
203 203
 
204 204
     /**
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214 214
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215 215
         ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
+            if ( ! isset( $_SERVER[$key] ) ) {
217 217
                 continue;
218 218
             }
219 219
 
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
220
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
221
+                $ip = trim( $ip ); // just to be safe
222 222
 
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
224 224
                     return $ip;
225 225
                 }
226 226
             }
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
     }
231 231
 
232 232
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
233
+        if ( strpos( $param, '[' ) ) {
234
+            $params = explode( '[', $param );
235 235
             $param = $params[0];
236 236
         }
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
239
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
240
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
241
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
242 242
             }
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249 249
             foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
250
+                if ( ! $k || ! is_array( $value ) ) {
251 251
                     continue;
252 252
                 }
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
+                $p = trim( $p, ']' );
255
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
256 256
             }
257 257
         }
258 258
 
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$value = $args['default'];
293 293
 		if ( $args['type'] == 'get' ) {
294
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
295
-				$value = $_GET[ $args['param'] ];
294
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
295
+				$value = $_GET[$args['param']];
296 296
 			}
297 297
 		} else if ( $args['type'] == 'post' ) {
298
-			if ( isset( $_POST[ $args['param'] ] ) ) {
299
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
298
+			if ( isset( $_POST[$args['param']] ) ) {
299
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
300 300
 			}
301 301
 		} else {
302
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
303
-				$value = $_REQUEST[ $args['param'] ];
302
+			if ( isset( $_REQUEST[$args['param']] ) ) {
303
+				$value = $_REQUEST[$args['param']];
304 304
 			}
305 305
 		}
306 306
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			if ( is_array( $value ) ) {
329 329
 				$temp_values = $value;
330 330
 				foreach ( $temp_values as $k => $v ) {
331
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
331
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
332 332
 				}
333 333
 			} else {
334 334
 				$value = call_user_func( $sanitize, $value );
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     public static function sanitize_request( $sanitize_method, &$values ) {
340 340
         $temp_values = $values;
341 341
         foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
343
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
342
+            if ( isset( $sanitize_method[$k] ) ) {
343
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
344 344
             }
345 345
         }
346 346
     }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
350 350
 		foreach ( $temp_values as $k => $val ) {
351
-			$values[ $k ] = wp_kses_post( $val );
351
+			$values[$k] = wp_kses_post( $val );
352 352
 		}
353 353
 	}
354 354
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 		$allowed_html = array();
373 373
 		foreach ( $allowed as $a ) {
374
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
374
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
375 375
 		}
376 376
 
377 377
 		return wp_kses( $value, $allowed_html );
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      * @since 2.0
383 383
      */
384 384
     public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
385
+        if ( ! isset( $_GET ) ) {
386 386
             return;
387 387
         }
388 388
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
         }
405 405
 
406 406
         global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
407
+        if ( isset( $wp_query->query_vars[$param] ) ) {
408
+            $value = $wp_query->query_vars[$param];
409 409
         }
410 410
 
411 411
         return $value;
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
      * @return mixed $results The cache or query results
435 435
      */
436 436
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
+        $results = wp_cache_get( $cache_key, $group );
438
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
439 439
             return $results;
440 440
         }
441 441
 
442 442
         if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
443
+            $results = get_posts( $query );
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447 447
         } else {
448 448
             global $wpdb;
449
-            $results = $wpdb->{$type}($query);
449
+            $results = $wpdb->{$type}( $query );
450 450
         }
451 451
 
452 452
 		self::set_cache( $cache_key, $results, $group, $time );
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public static function add_key_to_group_cache( $key, $group ) {
469 469
 		$cached = self::get_group_cached_keys( $group );
470
-		$cached[ $key ] = $key;
470
+		$cached[$key] = $key;
471 471
 		wp_cache_set( 'cached_keys', $cached, $group, 300 );
472 472
 	}
473 473
 
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
         }
494 494
 
495 495
         // then check the transient
496
-        $results = get_transient($cache_key);
496
+        $results = get_transient( $cache_key );
497 497
         if ( $results ) {
498
-            wp_cache_set($cache_key, $results);
498
+            wp_cache_set( $cache_key, $results );
499 499
         }
500 500
 
501 501
         return $results;
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param string $cache_key
507 507
      */
508 508
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
509
-		delete_transient($cache_key);
509
+		delete_transient( $cache_key );
510 510
 		wp_cache_delete( $cache_key, $group );
511 511
 	}
512 512
 
@@ -548,17 +548,17 @@  discard block
 block discarded – undo
548 548
     }
549 549
 
550 550
     public static function get_pages() {
551
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
551
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
552 552
     }
553 553
 
554 554
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
555 555
         $pages = self::get_pages();
556 556
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
557 557
     ?>
558
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
558
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
559 559
             <option value=""> </option>
560 560
             <?php foreach ( $pages as $page ) { ?>
561
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
561
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
562 562
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
563 563
 				</option>
564 564
             <?php } ?>
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     }
568 568
 
569 569
 	public static function post_edit_link( $post_id ) {
570
-        $post = get_post($post_id);
570
+        $post = get_post( $post_id );
571 571
         if ( $post ) {
572 572
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
573 573
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -577,17 +577,17 @@  discard block
 block discarded – undo
577 577
 
578 578
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
579 579
     ?>
580
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
580
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
581 581
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
582 582
             ?> class="frm_multiselect">
583
-            <?php self::roles_options($capability); ?>
583
+            <?php self::roles_options( $capability ); ?>
584 584
         </select>
585 585
     <?php
586 586
     }
587 587
 
588 588
 	public static function roles_options( $capability ) {
589 589
         global $frm_vars;
590
-        if ( isset($frm_vars['editable_roles']) ) {
590
+        if ( isset( $frm_vars['editable_roles'] ) ) {
591 591
             $editable_roles = $frm_vars['editable_roles'];
592 592
         } else {
593 593
             $editable_roles = get_editable_roles();
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
         }
596 596
 
597 597
         foreach ( $editable_roles as $role => $details ) {
598
-            $name = translate_user_role($details['name'] ); ?>
599
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
598
+            $name = translate_user_role( $details['name'] ); ?>
599
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
600 600
 <?php
601
-            unset($role, $details);
601
+            unset( $role, $details );
602 602
         }
603 603
     }
604 604
 
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     public static function maybe_add_permissions() {
655 655
 		self::force_capability( 'frm_view_entries' );
656 656
 
657
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
657
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
658 658
             return;
659 659
         }
660 660
 
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
         $frm_roles = self::frm_capabilities();
664 664
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
665 665
 			$user->add_cap( $frm_role );
666
-            unset($frm_role, $frm_role_description);
666
+            unset( $frm_role, $frm_role_description );
667 667
         }
668 668
     }
669 669
 
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
      * @param string $permission
689 689
      */
690 690
 	public static function permission_check( $permission, $show_message = 'show' ) {
691
-        $permission_error = self::permission_nonce_error($permission);
691
+        $permission_error = self::permission_nonce_error( $permission );
692 692
         if ( $permission_error !== false ) {
693 693
             if ( 'hide' == $show_message ) {
694 694
                 $permission_error = '';
695 695
             }
696
-            wp_die($permission_error);
696
+            wp_die( $permission_error );
697 697
         }
698 698
     }
699 699
 
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 		}
711 711
 
712 712
 		$error = false;
713
-        if ( empty($nonce_name) ) {
713
+        if ( empty( $nonce_name ) ) {
714 714
             return $error;
715 715
         }
716 716
 
717
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
717
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
718 718
             $frm_settings = self::get_settings();
719 719
             $error = $frm_settings->admin_permission;
720 720
         }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 			} else {
795 795
 				foreach ( $value as $k => $v ) {
796 796
 					if ( ! is_array( $v ) ) {
797
-						$value[ $k ] = call_user_func( $original_function, $v );
797
+						$value[$k] = call_user_func( $original_function, $v );
798 798
 					}
799 799
 				}
800 800
 			}
@@ -815,11 +815,11 @@  discard block
 block discarded – undo
815 815
 	public static function array_flatten( $array, $keys = 'keep' ) {
816 816
         $return = array();
817 817
         foreach ( $array as $key => $value ) {
818
-            if ( is_array($value) ) {
818
+            if ( is_array( $value ) ) {
819 819
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
820 820
             } else {
821 821
 				if ( $keys == 'keep' ) {
822
-					$return[ $key ] = $value;
822
+					$return[$key] = $value;
823 823
 				} else {
824 824
 					$return[] = $value;
825 825
 				}
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
      * @since 2.0
843 843
      */
844 844
 	public static function use_wpautop( $content ) {
845
-        if ( apply_filters('frm_use_wpautop', true) ) {
846
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
845
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
846
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
847 847
         }
848 848
         return $content;
849 849
     }
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
      * @return string The base Google APIS url for the current version of jQuery UI
862 862
      */
863 863
     public static function jquery_ui_base_url() {
864
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
865
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
864
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
865
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
866 866
         return $url;
867 867
     }
868 868
 
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
 
878 878
         $ver = 0;
879 879
 
880
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
880
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
881 881
             return $ver;
882 882
         }
883 883
 
884
-        $query = $wp_scripts->registered[ $handle ];
884
+        $query = $wp_scripts->registered[$handle];
885 885
     	if ( is_object( $query ) ) {
886 886
     	    $ver = $query->ver;
887 887
     	}
@@ -894,36 +894,36 @@  discard block
 block discarded – undo
894 894
     }
895 895
 
896 896
 	public static function get_user_id_param( $user_id ) {
897
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
897
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
898 898
             return $user_id;
899 899
         }
900 900
 
901 901
 		if ( $user_id == 'current' ) {
902 902
 			$user_id = get_current_user_id();
903 903
 		} else {
904
-            if ( is_email($user_id) ) {
905
-                $user = get_user_by('email', $user_id);
904
+            if ( is_email( $user_id ) ) {
905
+                $user = get_user_by( 'email', $user_id );
906 906
             } else {
907
-                $user = get_user_by('login', $user_id);
907
+                $user = get_user_by( 'login', $user_id );
908 908
             }
909 909
 
910 910
             if ( $user ) {
911 911
                 $user_id = $user->ID;
912 912
             }
913
-            unset($user);
913
+            unset( $user );
914 914
         }
915 915
 
916 916
         return $user_id;
917 917
     }
918 918
 
919 919
 	public static function get_file_contents( $filename, $atts = array() ) {
920
-        if ( ! is_file($filename) ) {
920
+        if ( ! is_file( $filename ) ) {
921 921
             return false;
922 922
         }
923 923
 
924
-        extract($atts);
924
+        extract( $atts );
925 925
         ob_start();
926
-        include($filename);
926
+        include( $filename );
927 927
         $contents = ob_get_contents();
928 928
         ob_end_clean();
929 929
         return $contents;
@@ -939,28 +939,28 @@  discard block
 block discarded – undo
939 939
         $key = '';
940 940
 
941 941
         if ( ! empty( $name ) ) {
942
-            $key = sanitize_key($name);
942
+            $key = sanitize_key( $name );
943 943
         }
944 944
 
945 945
 		if ( empty( $key ) ) {
946
-            $max_slug_value = pow(36, $num_chars);
946
+            $max_slug_value = pow( 36, $num_chars );
947 947
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
948
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
948
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
949 949
         }
950 950
 
951
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
951
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
952 952
 			$key = $key . 'a';
953 953
         }
954 954
 
955 955
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
956 956
 
957
-        if ( $key_check || is_numeric($key_check) ) {
957
+        if ( $key_check || is_numeric( $key_check ) ) {
958 958
             $suffix = 2;
959 959
 			do {
960 960
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
961 961
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
962
-				$suffix++;
963
-			} while ($key_check || is_numeric($key_check));
962
+				$suffix ++;
963
+			} while ( $key_check || is_numeric( $key_check ) );
964 964
 			$key = $alt_post_name;
965 965
         }
966 966
         return $key;
@@ -976,32 +976,32 @@  discard block
 block discarded – undo
976 976
             return false;
977 977
         }
978 978
 
979
-        if ( empty($post_values) ) {
980
-            $post_values = stripslashes_deep($_POST);
979
+        if ( empty( $post_values ) ) {
980
+            $post_values = stripslashes_deep( $_POST );
981 981
         }
982 982
 
983 983
 		$values = array( 'id' => $record->id, 'fields' => array() );
984 984
 
985 985
 		foreach ( array( 'name', 'description' ) as $var ) {
986
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
987
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
988
-            unset($var, $default_val);
986
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
987
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
988
+            unset( $var, $default_val );
989 989
         }
990 990
 
991
-        $values['description'] = self::use_wpautop($values['description']);
991
+        $values['description'] = self::use_wpautop( $values['description'] );
992 992
         $frm_settings = self::get_settings();
993
-        $is_form_builder = self::is_admin_page('formidable' );
993
+        $is_form_builder = self::is_admin_page( 'formidable' );
994 994
 
995 995
         foreach ( (array) $fields as $field ) {
996 996
             // Make sure to filter default values (for placeholder text), but not on the form builder page
997 997
             if ( ! $is_form_builder ) {
998
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
998
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
999 999
             }
1000 1000
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1001
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1001
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1002 1002
         }
1003 1003
 
1004
-        self::fill_form_opts($record, $table, $post_values, $values);
1004
+        self::fill_form_opts( $record, $table, $post_values, $values );
1005 1005
 
1006 1006
         if ( $table == 'entries' ) {
1007 1007
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1018,8 +1018,8 @@  discard block
 block discarded – undo
1018 1018
         if ( $args['default'] ) {
1019 1019
             $meta_value = $field->default_value;
1020 1020
         } else {
1021
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1022
-                if ( ! isset($field->field_options['custom_field']) ) {
1021
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1022
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1023 1023
                     $field->field_options['custom_field'] = '';
1024 1024
                 }
1025 1025
 				$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 ) );
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
             }
1029 1029
         }
1030 1030
 
1031
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1032
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1032
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1033 1033
 
1034 1034
         $field_array = array(
1035 1035
             'id'            => $field->id,
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
             'default_value' => $field->default_value,
1038 1038
             'name'          => $field->name,
1039 1039
             'description'   => $field->description,
1040
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1040
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1041 1041
             'options'       => $field->options,
1042 1042
             'required'      => $field->required,
1043 1043
             'field_key'     => $field->field_key,
@@ -1047,40 +1047,40 @@  discard block
 block discarded – undo
1047 1047
         );
1048 1048
 
1049 1049
         $args['field_type'] = $field_type;
1050
-        self::fill_field_opts($field, $field_array, $args);
1050
+        self::fill_field_opts( $field, $field_array, $args );
1051 1051
 		// Track the original field's type
1052 1052
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1053 1053
 
1054 1054
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1055 1055
 
1056
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1056
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1057 1057
             $field_array['unique_msg'] = '';
1058 1058
         }
1059 1059
 
1060 1060
         $field_array = array_merge( $field->field_options, $field_array );
1061 1061
 
1062
-        $values['fields'][ $field->id ] = $field_array;
1062
+        $values['fields'][$field->id] = $field_array;
1063 1063
     }
1064 1064
 
1065 1065
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1066 1066
         $post_values = $args['post_values'];
1067
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1067
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1068 1068
 
1069 1069
         foreach ( $opt_defaults as $opt => $default_opt ) {
1070
-			$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 );
1071
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1072
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1073
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1070
+			$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 );
1071
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1072
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1073
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1074 1074
                 if ( $args['field_type'] == 'captcha' ) {
1075
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1075
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1076 1076
                 } else {
1077
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1077
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1078 1078
                 }
1079 1079
             }
1080 1080
         }
1081 1081
 
1082 1082
         if ( $field_array['custom_html'] == '' ) {
1083
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1083
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1084 1084
         }
1085 1085
     }
1086 1086
 
@@ -1099,18 +1099,18 @@  discard block
 block discarded – undo
1099 1099
             return;
1100 1100
         }
1101 1101
 
1102
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1102
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1103 1103
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1104 1104
 
1105
-        if ( ! is_array($form->options) ) {
1105
+        if ( ! is_array( $form->options ) ) {
1106 1106
             return;
1107 1107
         }
1108 1108
 
1109 1109
         foreach ( $form->options as $opt => $value ) {
1110
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1110
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1111 1111
         }
1112 1112
 
1113
-        self::fill_form_defaults($post_values, $values);
1113
+        self::fill_form_defaults( $post_values, $values );
1114 1114
     }
1115 1115
 
1116 1116
     /**
@@ -1120,23 +1120,23 @@  discard block
 block discarded – undo
1120 1120
         $form_defaults = FrmFormsHelper::get_default_opts();
1121 1121
 
1122 1122
         foreach ( $form_defaults as $opt => $default ) {
1123
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1124
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1123
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1124
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1125 1125
             }
1126 1126
 
1127
-            unset($opt, $defaut);
1127
+            unset( $opt, $defaut );
1128 1128
         }
1129 1129
 
1130
-        if ( ! isset($values['custom_style']) ) {
1130
+        if ( ! isset( $values['custom_style'] ) ) {
1131 1131
             $frm_settings = self::get_settings();
1132 1132
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1133 1133
         }
1134 1134
 
1135 1135
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1136
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1137
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1136
+			if ( ! isset( $values[$h . '_html'] ) ) {
1137
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1138 1138
             }
1139
-            unset($h);
1139
+            unset( $h );
1140 1140
         }
1141 1141
     }
1142 1142
 
@@ -1152,9 +1152,9 @@  discard block
 block discarded – undo
1152 1152
         }
1153 1153
     ?>
1154 1154
 <li>
1155
-    <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>
1156
-    <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>
1157
-    <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>
1155
+    <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>
1156
+    <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>
1157
+    <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>
1158 1158
 </li>
1159 1159
     <?php
1160 1160
     }
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
             return '';
1173 1173
         } else if ( $length <= 10 ) {
1174 1174
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1175
-            return $sub . (($length < $original_len) ? $continue : '');
1175
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1176 1176
         }
1177 1177
 
1178 1178
         $sub = '';
@@ -1181,23 +1181,23 @@  discard block
 block discarded – undo
1181 1181
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1182 1182
 
1183 1183
 		foreach ( $words as $word ) {
1184
-            $part = (($sub != '') ? ' ' : '') . $word;
1184
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1185 1185
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1186
-            if ( $total_len > $length && str_word_count($sub) ) {
1186
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1187 1187
                 break;
1188 1188
             }
1189 1189
 
1190 1190
             $sub .= $part;
1191 1191
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1192 1192
 
1193
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1193
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1194 1194
                 break;
1195 1195
             }
1196 1196
 
1197
-            unset($total_len, $word);
1197
+            unset( $total_len, $word );
1198 1198
         }
1199 1199
 
1200
-        return $sub . (($len < $original_len) ? $continue : '');
1200
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1201 1201
     }
1202 1202
 
1203 1203
 	public static function mb_function( $function_names, $args ) {
@@ -1210,17 +1210,17 @@  discard block
 block discarded – undo
1210 1210
 	}
1211 1211
 
1212 1212
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1213
-        if ( empty($date) ) {
1213
+        if ( empty( $date ) ) {
1214 1214
             return $date;
1215 1215
         }
1216 1216
 
1217
-        if ( empty($date_format) ) {
1218
-            $date_format = get_option('date_format');
1217
+        if ( empty( $date_format ) ) {
1218
+            $date_format = get_option( 'date_format' );
1219 1219
         }
1220 1220
 
1221
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1221
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1222 1222
             $frmpro_settings = new FrmProSettings();
1223
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1223
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1224 1224
         }
1225 1225
 
1226 1226
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 
1236 1236
 	private static function add_time_to_date( $time_format, $date ) {
1237 1237
 		if ( empty( $time_format ) ) {
1238
-			$time_format = get_option('time_format');
1238
+			$time_format = get_option( 'time_format' );
1239 1239
 		}
1240 1240
 
1241 1241
 		$trimmed_format = trim( $time_format );
@@ -1281,10 +1281,10 @@  discard block
 block discarded – undo
1281 1281
 		$time_strings = self::get_time_strings();
1282 1282
 
1283 1283
 		foreach ( $time_strings as $k => $v ) {
1284
-			if ( $diff[ $k ] ) {
1285
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1284
+			if ( $diff[$k] ) {
1285
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1286 1286
 			} else {
1287
-				unset( $time_strings[ $k ] );
1287
+				unset( $time_strings[$k] );
1288 1288
 			}
1289 1289
 		}
1290 1290
 
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
      */
1323 1323
 	public static function esc_like( $term ) {
1324 1324
         global $wpdb;
1325
-        if ( method_exists($wpdb, 'esc_like') ) {
1325
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1326 1326
 			// WP 4.0
1327 1327
             $term = $wpdb->esc_like( $term );
1328 1328
         } else {
@@ -1336,17 +1336,17 @@  discard block
 block discarded – undo
1336 1336
      * @param string $order_query
1337 1337
      */
1338 1338
 	public static function esc_order( $order_query ) {
1339
-        if ( empty($order_query) ) {
1339
+        if ( empty( $order_query ) ) {
1340 1340
             return '';
1341 1341
         }
1342 1342
 
1343 1343
         // remove ORDER BY before santizing
1344
-        $order_query = strtolower($order_query);
1345
-        if ( strpos($order_query, 'order by') !== false ) {
1346
-            $order_query = str_replace('order by', '', $order_query);
1344
+        $order_query = strtolower( $order_query );
1345
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1346
+            $order_query = str_replace( 'order by', '', $order_query );
1347 1347
         }
1348 1348
 
1349
-        $order_query = explode(' ', trim($order_query));
1349
+        $order_query = explode( ' ', trim( $order_query ) );
1350 1350
 
1351 1351
         $order_fields = array(
1352 1352
             'id', 'form_key', 'name', 'description',
@@ -1354,13 +1354,13 @@  discard block
 block discarded – undo
1354 1354
             'default_template', 'status', 'created_at',
1355 1355
         );
1356 1356
 
1357
-        $order = trim(trim(reset($order_query), ','));
1358
-        if ( ! in_array($order, $order_fields) ) {
1357
+        $order = trim( trim( reset( $order_query ), ',' ) );
1358
+        if ( ! in_array( $order, $order_fields ) ) {
1359 1359
             return '';
1360 1360
         }
1361 1361
 
1362 1362
         $order_by = '';
1363
-        if ( count($order_query) > 1 ) {
1363
+        if ( count( $order_query ) > 1 ) {
1364 1364
 			$order_by = end( $order_query );
1365 1365
 			self::esc_order_by( $order_by );
1366 1366
         }
@@ -1382,23 +1382,23 @@  discard block
 block discarded – undo
1382 1382
      * @param string $limit
1383 1383
      */
1384 1384
 	public static function esc_limit( $limit ) {
1385
-        if ( empty($limit) ) {
1385
+        if ( empty( $limit ) ) {
1386 1386
             return '';
1387 1387
         }
1388 1388
 
1389
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1390
-        if ( is_numeric($limit) ) {
1389
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1390
+        if ( is_numeric( $limit ) ) {
1391 1391
 			return ' LIMIT ' . $limit;
1392 1392
         }
1393 1393
 
1394
-        $limit = explode(',', trim($limit));
1394
+        $limit = explode( ',', trim( $limit ) );
1395 1395
         foreach ( $limit as $k => $l ) {
1396 1396
             if ( is_numeric( $l ) ) {
1397
-                $limit[ $k ] = $l;
1397
+                $limit[$k] = $l;
1398 1398
             }
1399 1399
         }
1400 1400
 
1401
-        $limit = implode(',', $limit);
1401
+        $limit = implode( ',', $limit );
1402 1402
 		return ' LIMIT ' . $limit;
1403 1403
     }
1404 1404
 
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
      * @since 2.0
1408 1408
      */
1409 1409
     public static function prepare_array_values( $array, $type = '%s' ) {
1410
-        $placeholders = array_fill(0, count($array), $type);
1411
-        return implode(', ', $placeholders);
1410
+        $placeholders = array_fill( 0, count( $array ), $type );
1411
+        return implode( ', ', $placeholders );
1412 1412
     }
1413 1413
 
1414 1414
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1415
-        if ( empty($where) ) {
1415
+        if ( empty( $where ) ) {
1416 1416
             return '';
1417 1417
         }
1418 1418
 
@@ -1453,19 +1453,19 @@  discard block
 block discarded – undo
1453 1453
 	public static function json_to_array( $json_vars ) {
1454 1454
         $vars = array();
1455 1455
         foreach ( $json_vars as $jv ) {
1456
-            $jv_name = explode('[', $jv['name']);
1457
-            $last = count($jv_name) - 1;
1456
+            $jv_name = explode( '[', $jv['name'] );
1457
+            $last = count( $jv_name ) - 1;
1458 1458
             foreach ( $jv_name as $p => $n ) {
1459
-                $name = trim($n, ']');
1460
-                if ( ! isset($l1) ) {
1459
+                $name = trim( $n, ']' );
1460
+                if ( ! isset( $l1 ) ) {
1461 1461
                     $l1 = $name;
1462 1462
                 }
1463 1463
 
1464
-                if ( ! isset($l2) ) {
1464
+                if ( ! isset( $l2 ) ) {
1465 1465
                     $l2 = $name;
1466 1466
                 }
1467 1467
 
1468
-                if ( ! isset($l3) ) {
1468
+                if ( ! isset( $l3 ) ) {
1469 1469
                     $l3 = $name;
1470 1470
                 }
1471 1471
 
@@ -1479,24 +1479,24 @@  discard block
 block discarded – undo
1479 1479
 
1480 1480
                     case 1:
1481 1481
                         $l2 = $name;
1482
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1482
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1483 1483
                     break;
1484 1484
 
1485 1485
                     case 2:
1486 1486
                         $l3 = $name;
1487
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1487
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1488 1488
                     break;
1489 1489
 
1490 1490
                     case 3:
1491 1491
                         $l4 = $name;
1492
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1492
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1493 1493
                     break;
1494 1494
                 }
1495 1495
 
1496
-                unset($this_val, $n);
1496
+                unset( $this_val, $n );
1497 1497
             }
1498 1498
 
1499
-            unset($last, $jv);
1499
+            unset( $last, $jv );
1500 1500
         }
1501 1501
 
1502 1502
         return $vars;
@@ -1509,8 +1509,8 @@  discard block
 block discarded – undo
1509 1509
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1510 1510
         if ( $name == '' ) {
1511 1511
             $vars[] = $val;
1512
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1513
-            $vars[ $l1 ] = $val;
1512
+        } else if ( ! isset( $vars[$l1] ) ) {
1513
+            $vars[$l1] = $val;
1514 1514
         }
1515 1515
     }
1516 1516
 
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
             '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() ) ),
1526 1526
         );
1527 1527
 
1528
-        if ( ! isset( $tooltips[ $name ] ) ) {
1528
+        if ( ! isset( $tooltips[$name] ) ) {
1529 1529
             return;
1530 1530
         }
1531 1531
 
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
             echo ' class="frm_help"';
1536 1536
         }
1537 1537
 
1538
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1538
+		echo ' title="' . esc_attr( $tooltips[$name] );
1539 1539
 
1540 1540
         if ( 'open' != $class ) {
1541 1541
             echo '"';
@@ -1587,13 +1587,13 @@  discard block
 block discarded – undo
1587 1587
     }
1588 1588
 
1589 1589
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1590
-		if ( ! isset( $post_content[ $key ] ) ) {
1590
+		if ( ! isset( $post_content[$key] ) ) {
1591 1591
 			return;
1592 1592
 		}
1593 1593
 
1594 1594
 		if ( is_array( $val ) ) {
1595 1595
 			foreach ( $val as $k1 => $v1 ) {
1596
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1596
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1597 1597
 				unset( $k1, $v1 );
1598 1598
 			}
1599 1599
 		} else {
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 			$val = stripslashes( $val );
1602 1602
 
1603 1603
 			// Add backslashes before double quotes and forward slashes only
1604
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1604
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1605 1605
 		}
1606 1606
 	}
1607 1607
 
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1619 1619
 
1620 1620
 		if ( empty( $settings['ID'] ) ) {
1621
-			unset( $settings['ID']);
1621
+			unset( $settings['ID'] );
1622 1622
 		}
1623 1623
 
1624 1624
 		// delete all caches for this group
@@ -1652,17 +1652,17 @@  discard block
 block discarded – undo
1652 1652
 	}
1653 1653
 
1654 1654
 	public static function maybe_json_decode( $string ) {
1655
-        if ( is_array($string) ) {
1655
+        if ( is_array( $string ) ) {
1656 1656
             return $string;
1657 1657
         }
1658 1658
 
1659
-        $new_string = json_decode($string, true);
1660
-        if ( function_exists('json_last_error') ) {
1659
+        $new_string = json_decode( $string, true );
1660
+        if ( function_exists( 'json_last_error' ) ) {
1661 1661
 			// php 5.3+
1662 1662
             if ( json_last_error() == JSON_ERROR_NONE ) {
1663 1663
                 $string = $new_string;
1664 1664
             }
1665
-        } else if ( isset($new_string) ) {
1665
+        } else if ( isset( $new_string ) ) {
1666 1666
 			// php < 5.3 fallback
1667 1667
             $string = $new_string;
1668 1668
         }
@@ -1678,11 +1678,11 @@  discard block
 block discarded – undo
1678 1678
 	public static function maybe_highlight_menu( $post_type ) {
1679 1679
         global $post;
1680 1680
 
1681
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1681
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1682 1682
             return;
1683 1683
         }
1684 1684
 
1685
-        if ( is_object($post) && $post->post_type != $post_type ) {
1685
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1686 1686
             return;
1687 1687
         }
1688 1688
 
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
         $frm_version = self::plugin_version();
1784 1784
 
1785 1785
         // check if Formidable meets minimum requirements
1786
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1786
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1787 1787
             return;
1788 1788
         }
1789 1789
 
1790
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1790
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1791 1791
 		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">' .
1792 1792
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1793 1793
         '</div></td></tr>';
@@ -1795,38 +1795,38 @@  discard block
 block discarded – undo
1795 1795
 
1796 1796
     public static function locales( $type = 'date' ) {
1797 1797
         $locales = array(
1798
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1799
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1800
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1799
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1800
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1801 1801
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1802
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1803
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1802
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1803
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1804 1804
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1805
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1806
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1805
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1806
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1807 1807
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1808
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1808
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1809 1809
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1810
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1810
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1811 1811
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1812
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1812
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1813 1813
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1814
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1815
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1816
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1817
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1818
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1814
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1815
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1816
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1817
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1818
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1819 1819
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1820
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1820
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1821 1821
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1822 1822
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1823
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1823
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1824 1824
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1825
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1825
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1826 1826
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1827
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1828
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1829
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1828
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1829
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1830 1830
         );
1831 1831
 
1832 1832
         if ( $type == 'captcha' ) {
@@ -1845,8 +1845,8 @@  discard block
 block discarded – undo
1845 1845
             );
1846 1846
         }
1847 1847
 
1848
-        $locales = array_diff_key($locales, array_flip($unset));
1849
-        $locales = apply_filters('frm_locales', $locales);
1848
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1849
+        $locales = apply_filters( 'frm_locales', $locales );
1850 1850
 
1851 1851
         return $locales;
1852 1852
     }
Please login to merge, or discard this patch.