Completed
Push — master ( fc5171...0327ab )
by Stephanie
03:59
created
classes/controllers/FrmXMLController.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmXMLController {
4 4
 
5 5
     public static function menu() {
6
-        add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route');
6
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7 7
     }
8 8
 
9 9
     public static function add_default_templates() {
@@ -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))
@@ -64,48 +64,48 @@  discard block
 block discarded – undo
64 64
 			'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ),
65 65
         ) );
66 66
 
67
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php');
67
+        include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
68 68
     }
69 69
 
70 70
     public static function import_xml() {
71 71
         $errors = array();
72 72
         $message = '';
73 73
 
74
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
75 75
         if ( $permission_error !== false ) {
76 76
             $errors[] = $permission_error;
77
-            self::form($errors);
77
+            self::form( $errors );
78 78
             return;
79 79
         }
80 80
 
81
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
82 82
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
83
-            self::form($errors);
83
+            self::form( $errors );
84 84
             return;
85 85
         }
86 86
 
87 87
         $file = $_FILES['frm_import_file']['tmp_name'];
88 88
 
89 89
         if ( ! is_uploaded_file( $file ) ) {
90
-            unset($file);
90
+            unset( $file );
91 91
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
92
-            self::form($errors);
92
+            self::form( $errors );
93 93
             return;
94 94
         }
95 95
 
96 96
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
97 97
 
98
-        $export_format = apply_filters('frm_export_formats', array(
98
+        $export_format = apply_filters( 'frm_export_formats', array(
99 99
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
100 100
 		) );
101 101
 
102
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
103
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
102
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
103
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
104 104
             // allow other file types to be imported
105
-            do_action('frm_before_import_'. $file_type );
105
+            do_action( 'frm_before_import_' . $file_type );
106 106
             return;
107 107
         }
108
-        unset($file_type);
108
+        unset( $file_type );
109 109
 
110 110
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
111 111
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 		libxml_use_internal_errors( $set_err );
125 125
 		libxml_disable_entity_loader( $loader );
126 126
 
127
-        self::form($errors, $message);
127
+        self::form( $errors, $message );
128 128
     }
129 129
 
130 130
     public static function export_xml() {
131 131
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
132
-        if ( ! empty($error) ) {
132
+        if ( ! empty( $error ) ) {
133 133
             wp_die( $error );
134 134
         }
135 135
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         if ( $format == 'xml' ) {
146
-            self::generate_xml($type, compact('ids'));
146
+            self::generate_xml( $type, compact( 'ids' ) );
147 147
 		} if ( $format == 'csv' ) {
148
-			self::generate_csv( compact('ids') );
148
+			self::generate_csv( compact( 'ids' ) );
149 149
         } else {
150
-            do_action('frm_export_format_'. $format, compact('ids'));
150
+            do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
151 151
         }
152 152
 
153 153
         wp_die();
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
     	global $wpdb;
158 158
 
159 159
 	    $type = (array) $type;
160
-        if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
160
+        if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) {
161 161
             // make sure the form is included if there are entries
162 162
             $type[] = 'forms';
163 163
         }
164 164
 
165
-	    if ( in_array( 'forms', $type) ) {
165
+	    if ( in_array( 'forms', $type ) ) {
166 166
             // include actions with forms
167 167
 	        $type[] = 'actions';
168 168
 	    }
169 169
 
170 170
 	    $tables = array(
171
-	        'items'     => $wpdb->prefix .'frm_items',
172
-	        'forms'     => $wpdb->prefix .'frm_forms',
171
+	        'items'     => $wpdb->prefix . 'frm_items',
172
+	        'forms'     => $wpdb->prefix . 'frm_forms',
173 173
 	        'posts'     => $wpdb->posts,
174 174
 	        'styles'    => $wpdb->posts,
175 175
 	        'actions'   => $wpdb->posts,
@@ -199,31 +199,31 @@  discard block
 block discarded – undo
199 199
 		foreach ( $type as $tb_type ) {
200 200
             $where = array();
201 201
 			$join = '';
202
-            $table = $tables[ $tb_type ];
202
+            $table = $tables[$tb_type];
203 203
 
204
-            $select = $table .'.id';
204
+            $select = $table . '.id';
205 205
             $query_vars = array();
206 206
 
207 207
             switch ( $tb_type ) {
208 208
                 case 'forms':
209 209
                     //add forms
210 210
                     if ( $args['ids'] ) {
211
-						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table .'.parent_form_id' => $args['ids'] );
211
+						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
212 212
                 	} else {
213
-						$where[ $table . '.status !' ] = 'draft';
213
+						$where[$table . '.status !'] = 'draft';
214 214
                 	}
215 215
                 break;
216 216
                 case 'actions':
217
-                    $select = $table .'.ID';
217
+                    $select = $table . '.ID';
218 218
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
219
-                    if ( ! empty($args['ids']) ) {
219
+                    if ( ! empty( $args['ids'] ) ) {
220 220
 						$where['menu_order'] = $args['ids'];
221 221
                     }
222 222
                 break;
223 223
                 case 'items':
224 224
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
225 225
                     if ( $args['ids'] ) {
226
-						$where[ $table . '.form_id' ] = $args['ids'];
226
+						$where[$table . '.form_id'] = $args['ids'];
227 227
                     }
228 228
                 break;
229 229
                 case 'styles':
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                         }
239 239
                         unset( $form_id, $form_data );
240 240
                     }
241
-                    $select = $table .'.ID';
241
+                    $select = $table . '.ID';
242 242
                     $where['post_type'] = 'frm_styles';
243 243
 
244 244
                     // Only export selected styles
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
                     }
248 248
                 break;
249 249
                 default:
250
-                    $select = $table .'.ID';
250
+                    $select = $table . '.ID';
251 251
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
252 252
                     $where['pm.meta_key'] = 'frm_form_id';
253 253
 
254
-                    if ( empty($args['ids']) ) {
254
+                    if ( empty( $args['ids'] ) ) {
255 255
                         $where['pm.meta_value >'] = 1;
256 256
                     } else {
257 257
                         $where['pm.meta_value'] = $args['ids'];
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
                 break;
260 260
             }
261 261
 
262
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
263
-            unset($tb_type);
262
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
263
+            unset( $tb_type );
264 264
         }
265 265
 
266
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
267
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
266
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
267
+        include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
268 268
     }
269 269
 
270 270
 
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
290 290
 		}
291 291
 
292
-		if ( ! ini_get('safe_mode') ) {
293
-			set_time_limit(0); //Remove time limit to execute this function
294
-			$mem_limit = str_replace('M', '', ini_get('memory_limit'));
292
+		if ( ! ini_get( 'safe_mode' ) ) {
293
+			set_time_limit( 0 ); //Remove time limit to execute this function
294
+			$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
295 295
 			if ( (int) $mem_limit < 256 ) {
296
-				ini_set('memory_limit', '256M');
296
+				ini_set( 'memory_limit', '256M' );
297 297
 			}
298 298
 		}
299 299
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		 */
324 324
 		$query = apply_filters( 'frm_csv_where', $query, compact( 'form_id', 'search', 'fid', 'item_id' ) );
325 325
 
326
-		$entry_ids = FrmDb::get_col( $wpdb->prefix .'frm_items it', $query );
326
+		$entry_ids = FrmDb::get_col( $wpdb->prefix . 'frm_items it', $query );
327 327
 		unset( $query );
328 328
 
329 329
 		if ( empty( $entry_ids ) ) {
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 			$no_export_fields = FrmField::no_save_fields();
365 365
 			foreach ( $csv_fields as $k => $f ) {
366 366
 				if ( in_array( $f->type, $no_export_fields ) ) {
367
-					unset( $csv_fields[ $k ] );
367
+					unset( $csv_fields[$k] );
368 368
 				}
369 369
 			}
370 370
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +1128 added lines, -1128 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.0.21.1';
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
35
-        return plugins_url( '', self::plugin_path() .'/formidable.php' );
36
-    }
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
+		return plugins_url( '', self::plugin_path() .'/formidable.php' );
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();
@@ -75,78 +75,78 @@  discard block
 block discarded – undo
75 75
 		return $affiliate_id;
76 76
 	}
77 77
 
78
-    /**
79
-     * Get the Formidable settings
80
-     *
81
-     * @since 2.0
82
-     *
83
-     * @param None
84
-     * @return FrmSettings $frm_setings
85
-     */
86
-    public static function get_settings() {
87
-        global $frm_settings;
88
-        if ( empty($frm_settings) ) {
89
-            $frm_settings = new FrmSettings();
90
-        }
91
-        return $frm_settings;
92
-    }
93
-
94
-    /**
95
-     * Show a message in place of pro features
96
-     *
97
-     * @since 2.0
98
-     */
78
+	/**
79
+	 * Get the Formidable settings
80
+	 *
81
+	 * @since 2.0
82
+	 *
83
+	 * @param None
84
+	 * @return FrmSettings $frm_setings
85
+	 */
86
+	public static function get_settings() {
87
+		global $frm_settings;
88
+		if ( empty($frm_settings) ) {
89
+			$frm_settings = new FrmSettings();
90
+		}
91
+		return $frm_settings;
92
+	}
93
+
94
+	/**
95
+	 * Show a message in place of pro features
96
+	 *
97
+	 * @since 2.0
98
+	 */
99 99
 	public static function update_message( $features, $class = '' ) {
100 100
 		_deprecated_function( __FUNCTION__, '2.0.19' );
101
-    }
102
-
103
-    public static function pro_is_installed() {
104
-        return apply_filters('frm_pro_installed', false);
105
-    }
106
-
107
-    /**
108
-     * Check for certain page in Formidable settings
109
-     *
110
-     * @since 2.0
111
-     *
112
-     * @param string $page The name of the page to check
113
-     * @return boolean
114
-     */
101
+	}
102
+
103
+	public static function pro_is_installed() {
104
+		return apply_filters('frm_pro_installed', false);
105
+	}
106
+
107
+	/**
108
+	 * Check for certain page in Formidable settings
109
+	 *
110
+	 * @since 2.0
111
+	 *
112
+	 * @param string $page The name of the page to check
113
+	 * @return boolean
114
+	 */
115 115
 	public static function is_admin_page( $page = 'formidable' ) {
116
-        global $pagenow;
116
+		global $pagenow;
117 117
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
118
-        if ( $pagenow ) {
118
+		if ( $pagenow ) {
119 119
 			return $pagenow == 'admin.php' && $get_page == $page;
120
-        }
120
+		}
121 121
 
122 122
 		return is_admin() && $get_page == $page;
123
-    }
124
-
125
-    /**
126
-     * Check for the form preview page
127
-     *
128
-     * @since 2.0
129
-     *
130
-     * @param None
131
-     * @return boolean
132
-     */
133
-    public static function is_preview_page() {
134
-        global $pagenow;
123
+	}
124
+
125
+	/**
126
+	 * Check for the form preview page
127
+	 *
128
+	 * @since 2.0
129
+	 *
130
+	 * @param None
131
+	 * @return boolean
132
+	 */
133
+	public static function is_preview_page() {
134
+		global $pagenow;
135 135
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
136 136
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
137
-    }
137
+	}
138 138
 
139
-    /**
140
-     * Check for ajax except the form preview page
141
-     *
142
-     * @since 2.0
143
-     *
144
-     * @param None
145
-     * @return boolean
146
-     */
147
-    public static function doing_ajax() {
148
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
149
-    }
139
+	/**
140
+	 * Check for ajax except the form preview page
141
+	 *
142
+	 * @since 2.0
143
+	 *
144
+	 * @param None
145
+	 * @return boolean
146
+	 */
147
+	public static function doing_ajax() {
148
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
149
+	}
150 150
 
151 151
 	/**
152 152
 	 * @since 2.0.8
@@ -156,101 +156,101 @@  discard block
 block discarded – undo
156 156
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
157 157
 	}
158 158
 
159
-    /**
160
-     * Check if on an admin page
161
-     *
162
-     * @since 2.0
163
-     *
164
-     * @param None
165
-     * @return boolean
166
-     */
167
-    public static function is_admin() {
168
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
169
-    }
170
-
171
-    /**
172
-     * Check if value contains blank value or empty array
173
-     *
174
-     * @since 2.0
175
-     * @param $value - value to check
176
-     * @return boolean
177
-     */
178
-    public static function is_empty_value( $value, $empty = '' ) {
179
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
-    }
181
-
182
-    public static function is_not_empty_value( $value, $empty = '' ) {
183
-        return ! self::is_empty_value( $value, $empty );
184
-    }
185
-
186
-    /**
187
-     * Get any value from the $_SERVER
188
-     *
189
-     * @since 2.0
190
-     * @param string $value
191
-     * @return string
192
-     */
159
+	/**
160
+	 * Check if on an admin page
161
+	 *
162
+	 * @since 2.0
163
+	 *
164
+	 * @param None
165
+	 * @return boolean
166
+	 */
167
+	public static function is_admin() {
168
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
169
+	}
170
+
171
+	/**
172
+	 * Check if value contains blank value or empty array
173
+	 *
174
+	 * @since 2.0
175
+	 * @param $value - value to check
176
+	 * @return boolean
177
+	 */
178
+	public static function is_empty_value( $value, $empty = '' ) {
179
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
180
+	}
181
+
182
+	public static function is_not_empty_value( $value, $empty = '' ) {
183
+		return ! self::is_empty_value( $value, $empty );
184
+	}
185
+
186
+	/**
187
+	 * Get any value from the $_SERVER
188
+	 *
189
+	 * @since 2.0
190
+	 * @param string $value
191
+	 * @return string
192
+	 */
193 193
 	public static function get_server_value( $value ) {
194
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
-    }
196
-
197
-    /**
198
-     * Check for the IP address in several places
199
-     * Used by [ip] shortcode
200
-     *
201
-     * @return string The IP address of the current user
202
-     */
203
-    public static function get_ip_address() {
194
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
195
+	}
196
+
197
+	/**
198
+	 * Check for the IP address in several places
199
+	 * Used by [ip] shortcode
200
+	 *
201
+	 * @return string The IP address of the current user
202
+	 */
203
+	public static function get_ip_address() {
204 204
 		$ip = '';
205
-        foreach ( array(
206
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
-        ) as $key ) {
209
-            if ( ! isset( $_SERVER[ $key ] ) ) {
210
-                continue;
211
-            }
212
-
213
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
-                $ip = trim($ip); // just to be safe
215
-
216
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
-                    return $ip;
218
-                }
219
-            }
220
-        }
205
+		foreach ( array(
206
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
207
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
208
+		) as $key ) {
209
+			if ( ! isset( $_SERVER[ $key ] ) ) {
210
+				continue;
211
+			}
212
+
213
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
214
+				$ip = trim($ip); // just to be safe
215
+
216
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
217
+					return $ip;
218
+				}
219
+			}
220
+		}
221 221
 
222 222
 		return sanitize_text_field( $ip );
223
-    }
223
+	}
224 224
 
225
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
-        if ( strpos($param, '[') ) {
227
-            $params = explode('[', $param);
228
-            $param = $params[0];
229
-        }
225
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
226
+		if ( strpos($param, '[') ) {
227
+			$params = explode('[', $param);
228
+			$param = $params[0];
229
+		}
230 230
 
231 231
 		if ( $src == 'get' ) {
232
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
235
-            }
232
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
233
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
234
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
235
+			}
236 236
 			self::sanitize_value( $sanitize, $value );
237 237
 		} else {
238
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
-        }
238
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
239
+		}
240 240
 
241 241
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
242
-            foreach ( $params as $k => $p ) {
243
-                if ( ! $k || ! is_array($value) ) {
244
-                    continue;
245
-                }
242
+			foreach ( $params as $k => $p ) {
243
+				if ( ! $k || ! is_array($value) ) {
244
+					continue;
245
+				}
246 246
 
247
-                $p = trim($p, ']');
248
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
-            }
250
-        }
247
+				$p = trim($p, ']');
248
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
249
+			}
250
+		}
251 251
 
252
-        return $value;
253
-    }
252
+		return $value;
253
+	}
254 254
 
255 255
 	/**
256 256
 	 *
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
273 273
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
274
-    }
274
+	}
275 275
 
276 276
 	/**
277 277
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
309
-	*
310
-	* @since 2.0.8
311
-	* @param string $value
312
-	* @return string $value
313
-	*/
308
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
309
+	 *
310
+	 * @since 2.0.8
311
+	 * @param string $value
312
+	 * @return string $value
313
+	 */
314 314
 	public static function preserve_backslashes( $value ) {
315 315
 		// If backslashes have already been added, don't add them again
316 316
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 	}
331 331
 
332
-    public static function sanitize_request( $sanitize_method, &$values ) {
333
-        $temp_values = $values;
334
-        foreach ( $temp_values as $k => $val ) {
335
-            if ( isset( $sanitize_method[ $k ] ) ) {
332
+	public static function sanitize_request( $sanitize_method, &$values ) {
333
+		$temp_values = $values;
334
+		foreach ( $temp_values as $k => $val ) {
335
+			if ( isset( $sanitize_method[ $k ] ) ) {
336 336
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
337
-            }
338
-        }
339
-    }
337
+			}
338
+		}
339
+	}
340 340
 
341 341
 	public static function sanitize_array( &$values ) {
342 342
 		$temp_values = $values;
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public static function kses( $value, $allowed = array() ) {
353 353
 		$html = array(
354
-		    'a' => array(
354
+			'a' => array(
355 355
 				'href'  => array(),
356 356
 				'title' => array(),
357 357
 				'id'    => array(),
358 358
 				'class' => array(),
359
-		    ),
359
+			),
360 360
 		);
361 361
 
362 362
 		$allowed_html = array();
@@ -367,176 +367,176 @@  discard block
 block discarded – undo
367 367
 		return wp_kses( $value, $allowed_html );
368 368
 	}
369 369
 
370
-    /**
371
-     * Used when switching the action for a bulk action
372
-     * @since 2.0
373
-     */
374
-    public static function remove_get_action() {
375
-        if ( ! isset($_GET) ) {
376
-            return;
377
-        }
370
+	/**
371
+	 * Used when switching the action for a bulk action
372
+	 * @since 2.0
373
+	 */
374
+	public static function remove_get_action() {
375
+		if ( ! isset($_GET) ) {
376
+			return;
377
+		}
378 378
 
379
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
380
-        if ( ! empty( $new_action ) ) {
379
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
380
+		if ( ! empty( $new_action ) ) {
381 381
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
382
-        }
383
-    }
384
-
385
-    /**
386
-     * Check the WP query for a parameter
387
-     *
388
-     * @since 2.0
389
-     * @return string|array
390
-     */
391
-    public static function get_query_var( $value, $param ) {
392
-        if ( $value != '' ) {
393
-            return $value;
394
-        }
395
-
396
-        global $wp_query;
397
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
398
-            $value = $wp_query->query_vars[ $param ];
399
-        }
400
-
401
-        return $value;
402
-    }
403
-
404
-    /**
405
-     * @param string $type
406
-     */
407
-    public static function trigger_hook_load( $type, $object = null ) {
408
-        // only load the form hooks once
409
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
410
-        if ( ! $hooks_loaded ) {
411
-            do_action('frm_load_'. $type .'_hooks');
412
-        }
413
-    }
414
-
415
-    /**
416
-     * Check cache before fetching values and saving to cache
417
-     *
418
-     * @since 2.0
419
-     *
420
-     * @param string $cache_key The unique name for this cache
421
-     * @param string $group The name of the cache group
422
-     * @param string $query If blank, don't run a db call
423
-     * @param string $type The wpdb function to use with this query
424
-     * @return mixed $results The cache or query results
425
-     */
426
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
427
-        $results = wp_cache_get($cache_key, $group);
428
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
429
-            return $results;
430
-        }
431
-
432
-        if ( 'get_posts' == $type ) {
433
-            $results = get_posts($query);
434
-        } else {
435
-            global $wpdb;
436
-            $results = $wpdb->{$type}($query);
437
-        }
382
+		}
383
+	}
384
+
385
+	/**
386
+	 * Check the WP query for a parameter
387
+	 *
388
+	 * @since 2.0
389
+	 * @return string|array
390
+	 */
391
+	public static function get_query_var( $value, $param ) {
392
+		if ( $value != '' ) {
393
+			return $value;
394
+		}
395
+
396
+		global $wp_query;
397
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
398
+			$value = $wp_query->query_vars[ $param ];
399
+		}
400
+
401
+		return $value;
402
+	}
403
+
404
+	/**
405
+	 * @param string $type
406
+	 */
407
+	public static function trigger_hook_load( $type, $object = null ) {
408
+		// only load the form hooks once
409
+		$hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
410
+		if ( ! $hooks_loaded ) {
411
+			do_action('frm_load_'. $type .'_hooks');
412
+		}
413
+	}
414
+
415
+	/**
416
+	 * Check cache before fetching values and saving to cache
417
+	 *
418
+	 * @since 2.0
419
+	 *
420
+	 * @param string $cache_key The unique name for this cache
421
+	 * @param string $group The name of the cache group
422
+	 * @param string $query If blank, don't run a db call
423
+	 * @param string $type The wpdb function to use with this query
424
+	 * @return mixed $results The cache or query results
425
+	 */
426
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
427
+		$results = wp_cache_get($cache_key, $group);
428
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
429
+			return $results;
430
+		}
431
+
432
+		if ( 'get_posts' == $type ) {
433
+			$results = get_posts($query);
434
+		} else {
435
+			global $wpdb;
436
+			$results = $wpdb->{$type}($query);
437
+		}
438 438
 
439 439
 		if ( ! self::prevent_caching() ) {
440 440
 			wp_cache_set( $cache_key, $results, $group, $time );
441 441
 		}
442 442
 
443
-        return $results;
444
-    }
443
+		return $results;
444
+	}
445 445
 
446
-    /**
447
-     * Data that should be stored for a long time can be stored in a transient.
448
-     * First check the cache, then check the transient
449
-     * @since 2.0
450
-     * @return mixed The cached value or false
451
-     */
446
+	/**
447
+	 * Data that should be stored for a long time can be stored in a transient.
448
+	 * First check the cache, then check the transient
449
+	 * @since 2.0
450
+	 * @return mixed The cached value or false
451
+	 */
452 452
 	public static function check_cache_and_transient( $cache_key ) {
453
-        // check caching layer first
454
-        $results = self::check_cache( $cache_key );
455
-        if ( $results ) {
456
-            return $results;
457
-        }
458
-
459
-        // then check the transient
460
-        $results = get_transient($cache_key);
461
-        if ( $results ) {
462
-            wp_cache_set($cache_key, $results);
463
-        }
464
-
465
-        return $results;
466
-    }
467
-
468
-    /**
469
-     * @since 2.0
470
-     * @param string $cache_key
471
-     */
453
+		// check caching layer first
454
+		$results = self::check_cache( $cache_key );
455
+		if ( $results ) {
456
+			return $results;
457
+		}
458
+
459
+		// then check the transient
460
+		$results = get_transient($cache_key);
461
+		if ( $results ) {
462
+			wp_cache_set($cache_key, $results);
463
+		}
464
+
465
+		return $results;
466
+	}
467
+
468
+	/**
469
+	 * @since 2.0
470
+	 * @param string $cache_key
471
+	 */
472 472
 	public static function delete_cache_and_transient( $cache_key ) {
473
-        delete_transient($cache_key);
474
-        wp_cache_delete($cache_key);
475
-    }
476
-
477
-    /**
478
-     * Delete all caching in a single group
479
-     *
480
-     * @since 2.0
481
-     *
482
-     * @param string $group The name of the cache group
483
-     * @return boolean True or False
484
-     */
473
+		delete_transient($cache_key);
474
+		wp_cache_delete($cache_key);
475
+	}
476
+
477
+	/**
478
+	 * Delete all caching in a single group
479
+	 *
480
+	 * @since 2.0
481
+	 *
482
+	 * @param string $group The name of the cache group
483
+	 * @return boolean True or False
484
+	 */
485 485
 	public static function cache_delete_group( $group ) {
486
-    	global $wp_object_cache;
487
-
488
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
490
-                wp_cache_delete($k, $group);
491
-            }
492
-            return true;
493
-        }
494
-
495
-    	return false;
496
-    }
497
-
498
-    /**
499
-     * Check a value from a shortcode to see if true or false.
500
-     * True when value is 1, true, 'true', 'yes'
501
-     *
502
-     * @since 1.07.10
503
-     *
504
-     * @param string $value The value to compare
505
-     * @return boolean True or False
506
-     */
486
+		global $wp_object_cache;
487
+
488
+		if ( isset( $wp_object_cache->cache[ $group ] ) ) {
489
+			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
490
+				wp_cache_delete($k, $group);
491
+			}
492
+			return true;
493
+		}
494
+
495
+		return false;
496
+	}
497
+
498
+	/**
499
+	 * Check a value from a shortcode to see if true or false.
500
+	 * True when value is 1, true, 'true', 'yes'
501
+	 *
502
+	 * @since 1.07.10
503
+	 *
504
+	 * @param string $value The value to compare
505
+	 * @return boolean True or False
506
+	 */
507 507
 	public static function is_true( $value ) {
508
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
509
-    }
508
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
509
+	}
510 510
 
511
-    /**
512
-     * Used to filter shortcode in text widgets
513
-     */
514
-    public static function widget_text_filter_callback( $matches ) {
515
-        return do_shortcode( $matches[0] );
516
-    }
511
+	/**
512
+	 * Used to filter shortcode in text widgets
513
+	 */
514
+	public static function widget_text_filter_callback( $matches ) {
515
+		return do_shortcode( $matches[0] );
516
+	}
517 517
 
518 518
 	public static function load_scripts( $scripts ) {
519
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
520
-        foreach ( (array) $scripts as $s ) {
521
-            wp_enqueue_script($s);
522
-        }
523
-    }
519
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
520
+		foreach ( (array) $scripts as $s ) {
521
+			wp_enqueue_script($s);
522
+		}
523
+	}
524 524
 
525 525
 	public static function load_styles( $styles ) {
526
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
527
-        foreach ( (array) $styles as $s ) {
528
-            wp_enqueue_style($s);
529
-        }
530
-    }
526
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
527
+		foreach ( (array) $styles as $s ) {
528
+			wp_enqueue_style($s);
529
+		}
530
+	}
531 531
 
532
-    public static function get_pages() {
532
+	public static function get_pages() {
533 533
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
534
-    }
534
+	}
535 535
 
536
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
537
-        $pages = self::get_pages();
536
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
537
+		$pages = self::get_pages();
538 538
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
539
-    ?>
539
+	?>
540 540
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
541 541
             <option value=""> </option>
542 542
             <?php foreach ( $pages as $page ) { ?>
@@ -546,107 +546,107 @@  discard block
 block discarded – undo
546 546
             <?php } ?>
547 547
         </select>
548 548
     <?php
549
-    }
549
+	}
550 550
 
551 551
 	public static function post_edit_link( $post_id ) {
552
-        $post = get_post($post_id);
553
-        if ( $post ) {
554
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
555
-        }
556
-        return '';
557
-    }
552
+		$post = get_post($post_id);
553
+		if ( $post ) {
554
+			return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
555
+		}
556
+		return '';
557
+	}
558 558
 
559 559
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
560
-    ?>
560
+	?>
561 561
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
562
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
563
-            ?> class="frm_multiselect">
562
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
563
+			?> class="frm_multiselect">
564 564
             <?php self::roles_options($capability); ?>
565 565
         </select>
566 566
     <?php
567
-    }
567
+	}
568 568
 
569 569
 	public static function roles_options( $capability ) {
570
-        global $frm_vars;
571
-        if ( isset($frm_vars['editable_roles']) ) {
572
-            $editable_roles = $frm_vars['editable_roles'];
573
-        } else {
574
-            $editable_roles = get_editable_roles();
575
-            $frm_vars['editable_roles'] = $editable_roles;
576
-        }
577
-
578
-        foreach ( $editable_roles as $role => $details ) {
579
-            $name = translate_user_role($details['name'] ); ?>
570
+		global $frm_vars;
571
+		if ( isset($frm_vars['editable_roles']) ) {
572
+			$editable_roles = $frm_vars['editable_roles'];
573
+		} else {
574
+			$editable_roles = get_editable_roles();
575
+			$frm_vars['editable_roles'] = $editable_roles;
576
+		}
577
+
578
+		foreach ( $editable_roles as $role => $details ) {
579
+			$name = translate_user_role($details['name'] ); ?>
580 580
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
581 581
 <?php
582
-            unset($role, $details);
583
-        }
584
-    }
582
+			unset($role, $details);
583
+		}
584
+	}
585 585
 
586 586
 	public static function frm_capabilities( $type = 'auto' ) {
587
-        $cap = array(
588
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
589
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
590
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
591
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
592
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
593
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
594
-        );
587
+		$cap = array(
588
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
589
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
590
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
591
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
592
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
593
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
594
+		);
595 595
 
596 596
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
597
-            return $cap;
598
-        }
597
+			return $cap;
598
+		}
599 599
 
600
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
601
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
602
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
603
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
600
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
601
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
602
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
603
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
604 604
 
605
-        return $cap;
606
-    }
605
+		return $cap;
606
+	}
607 607
 
608 608
 	public static function user_has_permission( $needed_role ) {
609
-        if ( $needed_role == '-1' ) {
610
-            return false;
609
+		if ( $needed_role == '-1' ) {
610
+			return false;
611 611
 		}
612 612
 
613
-        // $needed_role will be equal to blank if "Logged-in users" is selected
614
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
615
-            return true;
616
-        }
613
+		// $needed_role will be equal to blank if "Logged-in users" is selected
614
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
615
+			return true;
616
+		}
617 617
 
618
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
619
-        foreach ( $roles as $role ) {
618
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
619
+		foreach ( $roles as $role ) {
620 620
 			if ( current_user_can( $role ) ) {
621
-        		return true;
621
+				return true;
622 622
 			}
623
-        	if ( $role == $needed_role ) {
624
-        		break;
623
+			if ( $role == $needed_role ) {
624
+				break;
625 625
 			}
626
-        }
627
-        return false;
628
-    }
629
-
630
-    /**
631
-     * Make sure administrators can see Formidable menu
632
-     *
633
-     * @since 2.0
634
-     */
635
-    public static function maybe_add_permissions() {
626
+		}
627
+		return false;
628
+	}
629
+
630
+	/**
631
+	 * Make sure administrators can see Formidable menu
632
+	 *
633
+	 * @since 2.0
634
+	 */
635
+	public static function maybe_add_permissions() {
636 636
 		self::force_capability( 'frm_view_entries' );
637 637
 
638
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
639
-            return;
640
-        }
638
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
639
+			return;
640
+		}
641 641
 
642 642
 		$user_id = get_current_user_id();
643 643
 		$user = new WP_User( $user_id );
644
-        $frm_roles = self::frm_capabilities();
645
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
644
+		$frm_roles = self::frm_capabilities();
645
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
646 646
 			$user->add_cap( $frm_role );
647
-            unset($frm_role, $frm_role_description);
648
-        }
649
-    }
647
+			unset($frm_role, $frm_role_description);
648
+		}
649
+	}
650 650
 
651 651
 	/**
652 652
 	 * Make sure admins have permission to see the menu items
@@ -662,28 +662,28 @@  discard block
 block discarded – undo
662 662
 		}
663 663
 	}
664 664
 
665
-    /**
666
-     * Check if the user has permision for action.
667
-     * Return permission message and stop the action if no permission
668
-     * @since 2.0
669
-     * @param string $permission
670
-     */
665
+	/**
666
+	 * Check if the user has permision for action.
667
+	 * Return permission message and stop the action if no permission
668
+	 * @since 2.0
669
+	 * @param string $permission
670
+	 */
671 671
 	public static function permission_check( $permission, $show_message = 'show' ) {
672
-        $permission_error = self::permission_nonce_error($permission);
673
-        if ( $permission_error !== false ) {
674
-            if ( 'hide' == $show_message ) {
675
-                $permission_error = '';
676
-            }
677
-            wp_die($permission_error);
678
-        }
679
-    }
680
-
681
-    /**
682
-     * Check user permission and nonce
683
-     * @since 2.0
684
-     * @param string $permission
685
-     * @return false|string The permission message or false if allowed
686
-     */
672
+		$permission_error = self::permission_nonce_error($permission);
673
+		if ( $permission_error !== false ) {
674
+			if ( 'hide' == $show_message ) {
675
+				$permission_error = '';
676
+			}
677
+			wp_die($permission_error);
678
+		}
679
+	}
680
+
681
+	/**
682
+	 * Check user permission and nonce
683
+	 * @since 2.0
684
+	 * @param string $permission
685
+	 * @return false|string The permission message or false if allowed
686
+	 */
687 687
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
688 688
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
689 689
 			$frm_settings = self::get_settings();
@@ -691,75 +691,75 @@  discard block
 block discarded – undo
691 691
 		}
692 692
 
693 693
 		$error = false;
694
-        if ( empty($nonce_name) ) {
695
-            return $error;
696
-        }
694
+		if ( empty($nonce_name) ) {
695
+			return $error;
696
+		}
697 697
 
698
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
699
-            $frm_settings = self::get_settings();
700
-            $error = $frm_settings->admin_permission;
701
-        }
698
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
699
+			$frm_settings = self::get_settings();
700
+			$error = $frm_settings->admin_permission;
701
+		}
702 702
 
703
-        return $error;
704
-    }
703
+		return $error;
704
+	}
705 705
 
706
-    public static function checked( $values, $current ) {
706
+	public static function checked( $values, $current ) {
707 707
 		if ( self::check_selected( $values, $current ) ) {
708
-            echo ' checked="checked"';
708
+			echo ' checked="checked"';
709 709
 		}
710
-    }
710
+	}
711 711
 
712 712
 	public static function check_selected( $values, $current ) {
713
-        $values = self::recursive_function_map( $values, 'trim' );
714
-        $current = trim($current);
715
-
716
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
717
-    }
718
-
719
-    /**
720
-    * Check if current field option is an "other" option
721
-    *
722
-    * @since 2.0
723
-    *
724
-    * @param string $opt_key
725
-    * @return boolean Returns true if current field option is an "Other" option
726
-    */
727
-    public static function is_other_opt( $opt_key ) {
728
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
729
-        return FrmFieldsHelper::is_other_opt( $opt_key );
730
-    }
731
-
732
-    /**
733
-    * Get value that belongs in "Other" text box
734
-    *
735
-    * @since 2.0
736
-    *
737
-    * @param string $opt_key
738
-    * @param array $field
739
-    * @return string $other_val
740
-    */
741
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
713
+		$values = self::recursive_function_map( $values, 'trim' );
714
+		$current = trim($current);
715
+
716
+		return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
717
+	}
718
+
719
+	/**
720
+	 * Check if current field option is an "other" option
721
+	 *
722
+	 * @since 2.0
723
+	 *
724
+	 * @param string $opt_key
725
+	 * @return boolean Returns true if current field option is an "Other" option
726
+	 */
727
+	public static function is_other_opt( $opt_key ) {
728
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
729
+		return FrmFieldsHelper::is_other_opt( $opt_key );
730
+	}
731
+
732
+	/**
733
+	 * Get value that belongs in "Other" text box
734
+	 *
735
+	 * @since 2.0
736
+	 *
737
+	 * @param string $opt_key
738
+	 * @param array $field
739
+	 * @return string $other_val
740
+	 */
741
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
742 742
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
743 743
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
744
-    }
745
-
746
-    /**
747
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
748
-    * Intended for front-end use
749
-    *
750
-    * @since 2.0
751
-    *
752
-    * @param array $field
753
-    * @param boolean $other_opt
754
-    * @param string $checked
755
-    * @param array $args should include opt_key and field name
756
-    * @return string $other_val
757
-    */
758
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
744
+	}
745
+
746
+	/**
747
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
748
+	 * Intended for front-end use
749
+	 *
750
+	 * @since 2.0
751
+	 *
752
+	 * @param array $field
753
+	 * @param boolean $other_opt
754
+	 * @param string $checked
755
+	 * @param array $args should include opt_key and field name
756
+	 * @return string $other_val
757
+	 */
758
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
759 759
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
760 760
 		$args['field'] = $field;
761 761
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
762
-    }
762
+	}
763 763
 
764 764
 	public static function recursive_function_map( $value, $function ) {
765 765
 		if ( is_array( $value ) ) {
@@ -789,333 +789,333 @@  discard block
 block discarded – undo
789 789
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
790 790
 	}
791 791
 
792
-    /**
793
-     * Flatten a multi-dimensional array
794
-     */
792
+	/**
793
+	 * Flatten a multi-dimensional array
794
+	 */
795 795
 	public static function array_flatten( $array, $keys = 'keep' ) {
796
-        $return = array();
797
-        foreach ( $array as $key => $value ) {
798
-            if ( is_array($value) ) {
796
+		$return = array();
797
+		foreach ( $array as $key => $value ) {
798
+			if ( is_array($value) ) {
799 799
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
800
-            } else {
800
+			} else {
801 801
 				if ( $keys == 'keep' ) {
802 802
 					$return[ $key ] = $value;
803 803
 				} else {
804 804
 					$return[] = $value;
805 805
 				}
806
-            }
807
-        }
808
-        return $return;
809
-    }
810
-
811
-    public static function esc_textarea( $text ) {
812
-        $safe_text = str_replace('&quot;', '"', $text);
813
-        $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
814
-    	return apply_filters( 'esc_textarea', $safe_text, $text );
815
-    }
816
-
817
-    /**
818
-     * Add auto paragraphs to text areas
819
-     * @since 2.0
820
-     */
806
+			}
807
+		}
808
+		return $return;
809
+	}
810
+
811
+	public static function esc_textarea( $text ) {
812
+		$safe_text = str_replace('&quot;', '"', $text);
813
+		$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
814
+		return apply_filters( 'esc_textarea', $safe_text, $text );
815
+	}
816
+
817
+	/**
818
+	 * Add auto paragraphs to text areas
819
+	 * @since 2.0
820
+	 */
821 821
 	public static function use_wpautop( $content ) {
822
-        if ( apply_filters('frm_use_wpautop', true) ) {
823
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
824
-        }
825
-        return $content;
826
-    }
822
+		if ( apply_filters('frm_use_wpautop', true) ) {
823
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
824
+		}
825
+		return $content;
826
+	}
827 827
 
828 828
 	public static function replace_quotes( $val ) {
829
-        //Replace double quotes
829
+		//Replace double quotes
830 830
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
831
-        //Replace single quotes
832
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
833
-        return $val;
834
-    }
835
-
836
-    /**
837
-     * @since 2.0
838
-     * @return string The base Google APIS url for the current version of jQuery UI
839
-     */
840
-    public static function jquery_ui_base_url() {
841
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
842
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
843
-        return $url;
844
-    }
845
-
846
-    /**
847
-     * @param string $handle
848
-     */
831
+		//Replace single quotes
832
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
833
+		return $val;
834
+	}
835
+
836
+	/**
837
+	 * @since 2.0
838
+	 * @return string The base Google APIS url for the current version of jQuery UI
839
+	 */
840
+	public static function jquery_ui_base_url() {
841
+		$url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
842
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
843
+		return $url;
844
+	}
845
+
846
+	/**
847
+	 * @param string $handle
848
+	 */
849 849
 	public static function script_version( $handle ) {
850
-        global $wp_scripts;
851
-    	if ( ! $wp_scripts ) {
852
-    	    return false;
853
-    	}
850
+		global $wp_scripts;
851
+		if ( ! $wp_scripts ) {
852
+			return false;
853
+		}
854 854
 
855
-        $ver = 0;
855
+		$ver = 0;
856 856
 
857
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
858
-            return $ver;
859
-        }
857
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
858
+			return $ver;
859
+		}
860 860
 
861
-        $query = $wp_scripts->registered[ $handle ];
862
-    	if ( is_object( $query ) ) {
863
-    	    $ver = $query->ver;
864
-    	}
861
+		$query = $wp_scripts->registered[ $handle ];
862
+		if ( is_object( $query ) ) {
863
+			$ver = $query->ver;
864
+		}
865 865
 
866
-    	return $ver;
867
-    }
866
+		return $ver;
867
+	}
868 868
 
869 869
 	public static function js_redirect( $url ) {
870 870
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
871
-    }
871
+	}
872 872
 
873 873
 	public static function get_user_id_param( $user_id ) {
874
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
875
-            return $user_id;
876
-        }
874
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
875
+			return $user_id;
876
+		}
877 877
 
878 878
 		if ( $user_id == 'current' ) {
879 879
 			$user_id = get_current_user_id();
880 880
 		} else {
881
-            if ( is_email($user_id) ) {
882
-                $user = get_user_by('email', $user_id);
883
-            } else {
884
-                $user = get_user_by('login', $user_id);
885
-            }
881
+			if ( is_email($user_id) ) {
882
+				$user = get_user_by('email', $user_id);
883
+			} else {
884
+				$user = get_user_by('login', $user_id);
885
+			}
886 886
 
887
-            if ( $user ) {
888
-                $user_id = $user->ID;
889
-            }
890
-            unset($user);
891
-        }
887
+			if ( $user ) {
888
+				$user_id = $user->ID;
889
+			}
890
+			unset($user);
891
+		}
892 892
 
893
-        return $user_id;
894
-    }
893
+		return $user_id;
894
+	}
895 895
 
896 896
 	public static function get_file_contents( $filename, $atts = array() ) {
897
-        if ( ! is_file($filename) ) {
898
-            return false;
899
-        }
900
-
901
-        extract($atts);
902
-        ob_start();
903
-        include($filename);
904
-        $contents = ob_get_contents();
905
-        ob_end_clean();
906
-        return $contents;
907
-    }
908
-
909
-    /**
910
-     * @param string $table_name
911
-     * @param string $column
912
-     */
913
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
914
-        global $wpdb;
915
-
916
-        $key = '';
917
-
918
-        if ( ! empty( $name ) ) {
919
-            $key = sanitize_key($name);
920
-        }
897
+		if ( ! is_file($filename) ) {
898
+			return false;
899
+		}
900
+
901
+		extract($atts);
902
+		ob_start();
903
+		include($filename);
904
+		$contents = ob_get_contents();
905
+		ob_end_clean();
906
+		return $contents;
907
+	}
908
+
909
+	/**
910
+	 * @param string $table_name
911
+	 * @param string $column
912
+	 */
913
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
914
+		global $wpdb;
915
+
916
+		$key = '';
917
+
918
+		if ( ! empty( $name ) ) {
919
+			$key = sanitize_key($name);
920
+		}
921 921
 
922 922
 		if ( empty( $key ) ) {
923
-            $max_slug_value = pow(36, $num_chars);
924
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
925
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
926
-        }
923
+			$max_slug_value = pow(36, $num_chars);
924
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
925
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
926
+		}
927 927
 
928 928
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
929
-            $key = $key .'a';
930
-        }
929
+			$key = $key .'a';
930
+		}
931 931
 
932 932
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
933 933
 
934
-        if ( $key_check || is_numeric($key_check) ) {
935
-            $suffix = 2;
934
+		if ( $key_check || is_numeric($key_check) ) {
935
+			$suffix = 2;
936 936
 			do {
937 937
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
938 938
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
939 939
 				$suffix++;
940 940
 			} while ($key_check || is_numeric($key_check));
941 941
 			$key = $alt_post_name;
942
-        }
943
-        return $key;
944
-    }
945
-
946
-    /**
947
-     * Editing a Form or Entry
948
-     * @param string $table
949
-     * @return bool|array
950
-     */
951
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
952
-        if ( ! $record ) {
953
-            return false;
954
-        }
955
-
956
-        global $frm_vars;
957
-
958
-        if ( empty($post_values) ) {
959
-            $post_values = stripslashes_deep($_POST);
960
-        }
942
+		}
943
+		return $key;
944
+	}
945
+
946
+	/**
947
+	 * Editing a Form or Entry
948
+	 * @param string $table
949
+	 * @return bool|array
950
+	 */
951
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
952
+		if ( ! $record ) {
953
+			return false;
954
+		}
955
+
956
+		global $frm_vars;
957
+
958
+		if ( empty($post_values) ) {
959
+			$post_values = stripslashes_deep($_POST);
960
+		}
961 961
 
962 962
 		$values = array( 'id' => $record->id, 'fields' => array() );
963 963
 
964 964
 		foreach ( array( 'name', 'description' ) as $var ) {
965
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
966
-            $values[ $var ] = self::get_param( $var, $default_val );
967
-            unset($var, $default_val);
968
-        }
969
-
970
-        $values['description'] = self::use_wpautop($values['description']);
971
-        $frm_settings = self::get_settings();
972
-        $is_form_builder = self::is_admin_page('formidable' );
973
-
974
-        foreach ( (array) $fields as $field ) {
975
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
976
-            if ( ! $is_form_builder ) {
977
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
978
-            }
965
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
966
+			$values[ $var ] = self::get_param( $var, $default_val );
967
+			unset($var, $default_val);
968
+		}
969
+
970
+		$values['description'] = self::use_wpautop($values['description']);
971
+		$frm_settings = self::get_settings();
972
+		$is_form_builder = self::is_admin_page('formidable' );
973
+
974
+		foreach ( (array) $fields as $field ) {
975
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
976
+			if ( ! $is_form_builder ) {
977
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
978
+			}
979 979
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
980 980
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
981
-        }
981
+		}
982 982
 
983
-        self::fill_form_opts($record, $table, $post_values, $values);
983
+		self::fill_form_opts($record, $table, $post_values, $values);
984 984
 
985
-        if ( $table == 'entries' ) {
986
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
987
-        } else if ( $table == 'forms' ) {
988
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
989
-        }
985
+		if ( $table == 'entries' ) {
986
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
987
+		} else if ( $table == 'forms' ) {
988
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
989
+		}
990 990
 
991
-        return $values;
992
-    }
991
+		return $values;
992
+	}
993 993
 
994 994
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
995
-        $post_values = $args['post_values'];
996
-
997
-        if ( $args['default'] ) {
998
-            $meta_value = $field->default_value;
999
-        } else {
1000
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1001
-                if ( ! isset($field->field_options['custom_field']) ) {
1002
-                    $field->field_options['custom_field'] = '';
1003
-                }
995
+		$post_values = $args['post_values'];
996
+
997
+		if ( $args['default'] ) {
998
+			$meta_value = $field->default_value;
999
+		} else {
1000
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1001
+				if ( ! isset($field->field_options['custom_field']) ) {
1002
+					$field->field_options['custom_field'] = '';
1003
+				}
1004 1004
 				$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 ) );
1005
-            } else {
1005
+			} else {
1006 1006
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1007
-            }
1008
-        }
1009
-
1010
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1011
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1012
-
1013
-        $field_array = array(
1014
-            'id'            => $field->id,
1015
-            'value'         => $new_value,
1016
-            'default_value' => $field->default_value,
1017
-            'name'          => $field->name,
1018
-            'description'   => $field->description,
1019
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1020
-            'options'       => $field->options,
1021
-            'required'      => $field->required,
1022
-            'field_key'     => $field->field_key,
1023
-            'field_order'   => $field->field_order,
1024
-            'form_id'       => $field->form_id,
1007
+			}
1008
+		}
1009
+
1010
+		$field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
1011
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1012
+
1013
+		$field_array = array(
1014
+			'id'            => $field->id,
1015
+			'value'         => $new_value,
1016
+			'default_value' => $field->default_value,
1017
+			'name'          => $field->name,
1018
+			'description'   => $field->description,
1019
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1020
+			'options'       => $field->options,
1021
+			'required'      => $field->required,
1022
+			'field_key'     => $field->field_key,
1023
+			'field_order'   => $field->field_order,
1024
+			'form_id'       => $field->form_id,
1025 1025
 			'parent_form_id' => $args['parent_form_id'],
1026
-        );
1026
+		);
1027 1027
 
1028
-        $args['field_type'] = $field_type;
1029
-        self::fill_field_opts($field, $field_array, $args);
1028
+		$args['field_type'] = $field_type;
1029
+		self::fill_field_opts($field, $field_array, $args);
1030 1030
 
1031
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1031
+		$field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1032 1032
 
1033
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1034
-            $field_array['unique_msg'] = '';
1035
-        }
1033
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1034
+			$field_array['unique_msg'] = '';
1035
+		}
1036 1036
 
1037
-        $field_array = array_merge( $field->field_options, $field_array );
1037
+		$field_array = array_merge( $field->field_options, $field_array );
1038 1038
 
1039
-        $values['fields'][ $field->id ] = $field_array;
1040
-    }
1039
+		$values['fields'][ $field->id ] = $field_array;
1040
+	}
1041 1041
 
1042 1042
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1043
-        $post_values = $args['post_values'];
1044
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1045
-
1046
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1047
-            $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 );
1048
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1049
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1050
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1051
-                if ( $args['field_type'] == 'captcha' ) {
1052
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1053
-                } else {
1054
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1055
-                }
1056
-            }
1057
-        }
1058
-
1059
-        if ( $field_array['custom_html'] == '' ) {
1060
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1061
-        }
1062
-    }
1063
-
1064
-    /**
1065
-     * @param string $table
1066
-     */
1043
+		$post_values = $args['post_values'];
1044
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1045
+
1046
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1047
+			$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 );
1048
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1049
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1050
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1051
+				if ( $args['field_type'] == 'captcha' ) {
1052
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1053
+				} else {
1054
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1055
+				}
1056
+			}
1057
+		}
1058
+
1059
+		if ( $field_array['custom_html'] == '' ) {
1060
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1061
+		}
1062
+	}
1063
+
1064
+	/**
1065
+	 * @param string $table
1066
+	 */
1067 1067
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1068
-        if ( $table == 'entries' ) {
1069
-            $form = $record->form_id;
1068
+		if ( $table == 'entries' ) {
1069
+			$form = $record->form_id;
1070 1070
 			FrmForm::maybe_get_form( $form );
1071
-        } else {
1072
-            $form = $record;
1073
-        }
1071
+		} else {
1072
+			$form = $record;
1073
+		}
1074 1074
 
1075
-        if ( ! $form ) {
1076
-            return;
1077
-        }
1075
+		if ( ! $form ) {
1076
+			return;
1077
+		}
1078 1078
 
1079
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1079
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1080 1080
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1081 1081
 
1082
-        if ( ! is_array($form->options) ) {
1083
-            return;
1084
-        }
1082
+		if ( ! is_array($form->options) ) {
1083
+			return;
1084
+		}
1085 1085
 
1086
-        foreach ( $form->options as $opt => $value ) {
1087
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1088
-        }
1086
+		foreach ( $form->options as $opt => $value ) {
1087
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1088
+		}
1089 1089
 
1090
-        self::fill_form_defaults($post_values, $values);
1091
-    }
1090
+		self::fill_form_defaults($post_values, $values);
1091
+	}
1092 1092
 
1093
-    /**
1094
-     * Set to POST value or default
1095
-     */
1093
+	/**
1094
+	 * Set to POST value or default
1095
+	 */
1096 1096
 	private static function fill_form_defaults( $post_values, array &$values ) {
1097
-        $form_defaults = FrmFormsHelper::get_default_opts();
1097
+		$form_defaults = FrmFormsHelper::get_default_opts();
1098 1098
 
1099
-        foreach ( $form_defaults as $opt => $default ) {
1100
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1099
+		foreach ( $form_defaults as $opt => $default ) {
1100
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1101 1101
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1102
-            }
1102
+			}
1103 1103
 
1104
-            unset($opt, $defaut);
1105
-        }
1104
+			unset($opt, $defaut);
1105
+		}
1106 1106
 
1107
-        if ( ! isset($values['custom_style']) ) {
1108
-            $frm_settings = self::get_settings();
1107
+		if ( ! isset($values['custom_style']) ) {
1108
+			$frm_settings = self::get_settings();
1109 1109
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1110
-        }
1110
+		}
1111 1111
 
1112 1112
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1113
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1114
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1115
-            }
1116
-            unset($h);
1117
-        }
1118
-    }
1113
+			if ( ! isset( $values[ $h .'_html' ] ) ) {
1114
+				$values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1115
+			}
1116
+			unset($h);
1117
+		}
1118
+	}
1119 1119
 
1120 1120
 	public static function get_meta_value( $field_id, $entry ) {
1121 1121
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1123,69 +1123,69 @@  discard block
 block discarded – undo
1123 1123
 	}
1124 1124
 
1125 1125
 	public static function insert_opt_html( $args ) {
1126
-        $class = '';
1127
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1128
-            $class .= 'show_frm_not_email_to';
1129
-        }
1130
-    ?>
1126
+		$class = '';
1127
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1128
+			$class .= 'show_frm_not_email_to';
1129
+		}
1130
+	?>
1131 1131
 <li>
1132 1132
     <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>
1133 1133
     <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>
1134 1134
     <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>
1135 1135
 </li>
1136 1136
     <?php
1137
-    }
1137
+	}
1138 1138
 
1139
-    public static function get_us_states() {
1140
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1141
-        return FrmFieldsHelper::get_us_states();
1142
-    }
1139
+	public static function get_us_states() {
1140
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1141
+		return FrmFieldsHelper::get_us_states();
1142
+	}
1143 1143
 
1144
-    public static function get_countries() {
1145
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1146
-        return FrmFieldsHelper::get_countries();
1147
-    }
1144
+	public static function get_countries() {
1145
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1146
+		return FrmFieldsHelper::get_countries();
1147
+	}
1148 1148
 
1149 1149
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1150
-        if ( is_array( $str ) ) {
1151
-            return;
1150
+		if ( is_array( $str ) ) {
1151
+			return;
1152 1152
 		}
1153 1153
 
1154
-        $length = (int) $length;
1154
+		$length = (int) $length;
1155 1155
 		$str = wp_strip_all_tags( $str );
1156 1156
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1157 1157
 
1158 1158
 		if ( $length == 0 ) {
1159
-            return '';
1160
-        } else if ( $length <= 10 ) {
1159
+			return '';
1160
+		} else if ( $length <= 10 ) {
1161 1161
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1162
-            return $sub . (($length < $original_len) ? $continue : '');
1163
-        }
1162
+			return $sub . (($length < $original_len) ? $continue : '');
1163
+		}
1164 1164
 
1165
-        $sub = '';
1166
-        $len = 0;
1165
+		$sub = '';
1166
+		$len = 0;
1167 1167
 
1168 1168
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1169 1169
 
1170 1170
 		foreach ( $words as $word ) {
1171
-            $part = (($sub != '') ? ' ' : '') . $word;
1171
+			$part = (($sub != '') ? ' ' : '') . $word;
1172 1172
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1173
-            if ( $total_len > $length && str_word_count($sub) ) {
1174
-                break;
1175
-            }
1173
+			if ( $total_len > $length && str_word_count($sub) ) {
1174
+				break;
1175
+			}
1176 1176
 
1177
-            $sub .= $part;
1177
+			$sub .= $part;
1178 1178
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1179 1179
 
1180
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1181
-                break;
1182
-            }
1180
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1181
+				break;
1182
+			}
1183 1183
 
1184
-            unset($total_len, $word);
1185
-        }
1184
+			unset($total_len, $word);
1185
+		}
1186 1186
 
1187
-        return $sub . (($len < $original_len) ? $continue : '');
1188
-    }
1187
+		return $sub . (($len < $original_len) ? $continue : '');
1188
+	}
1189 1189
 
1190 1190
 	public static function mb_function( $function_names, $args ) {
1191 1191
 		$mb_function_name = $function_names[0];
@@ -1197,18 +1197,18 @@  discard block
 block discarded – undo
1197 1197
 	}
1198 1198
 
1199 1199
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1200
-        if ( empty($date) ) {
1201
-            return $date;
1202
-        }
1200
+		if ( empty($date) ) {
1201
+			return $date;
1202
+		}
1203 1203
 
1204
-        if ( empty($date_format) ) {
1205
-            $date_format = get_option('date_format');
1206
-        }
1204
+		if ( empty($date_format) ) {
1205
+			$date_format = get_option('date_format');
1206
+		}
1207 1207
 
1208
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1209
-            $frmpro_settings = new FrmProSettings();
1210
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1211
-        }
1208
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1209
+			$frmpro_settings = new FrmProSettings();
1210
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1211
+		}
1212 1212
 
1213 1213
 		$formatted = self::get_localized_date( $date_format, $date );
1214 1214
 
@@ -1217,8 +1217,8 @@  discard block
 block discarded – undo
1217 1217
 			$formatted .= self::add_time_to_date( $time_format, $date );
1218 1218
 		}
1219 1219
 
1220
-        return $formatted;
1221
-    }
1220
+		return $formatted;
1221
+	}
1222 1222
 
1223 1223
 	private static function add_time_to_date( $time_format, $date ) {
1224 1224
 		if ( empty( $time_format ) ) {
@@ -1299,61 +1299,61 @@  discard block
 block discarded – undo
1299 1299
 		);
1300 1300
 	}
1301 1301
 
1302
-    /**
1303
-     * Added for < WP 4.0 compatability
1304
-     *
1305
-     * @since 1.07.10
1306
-     *
1307
-     * @param string $term The value to escape
1308
-     * @return string The escaped value
1309
-     */
1302
+	/**
1303
+	 * Added for < WP 4.0 compatability
1304
+	 *
1305
+	 * @since 1.07.10
1306
+	 *
1307
+	 * @param string $term The value to escape
1308
+	 * @return string The escaped value
1309
+	 */
1310 1310
 	public static function esc_like( $term ) {
1311
-        global $wpdb;
1312
-        if ( method_exists($wpdb, 'esc_like') ) {
1311
+		global $wpdb;
1312
+		if ( method_exists($wpdb, 'esc_like') ) {
1313 1313
 			// WP 4.0
1314
-            $term = $wpdb->esc_like( $term );
1315
-        } else {
1316
-            $term = like_escape( $term );
1317
-        }
1314
+			$term = $wpdb->esc_like( $term );
1315
+		} else {
1316
+			$term = like_escape( $term );
1317
+		}
1318 1318
 
1319
-        return $term;
1320
-    }
1319
+		return $term;
1320
+	}
1321 1321
 
1322
-    /**
1323
-     * @param string $order_query
1324
-     */
1322
+	/**
1323
+	 * @param string $order_query
1324
+	 */
1325 1325
 	public static function esc_order( $order_query ) {
1326
-        if ( empty($order_query) ) {
1327
-            return '';
1328
-        }
1329
-
1330
-        // remove ORDER BY before santizing
1331
-        $order_query = strtolower($order_query);
1332
-        if ( strpos($order_query, 'order by') !== false ) {
1333
-            $order_query = str_replace('order by', '', $order_query);
1334
-        }
1335
-
1336
-        $order_query = explode(' ', trim($order_query));
1337
-
1338
-        $order_fields = array(
1339
-            'id', 'form_key', 'name', 'description',
1340
-            'parent_form_id', 'logged_in', 'is_template',
1341
-            'default_template', 'status', 'created_at',
1342
-        );
1343
-
1344
-        $order = trim(trim(reset($order_query), ','));
1345
-        if ( ! in_array($order, $order_fields) ) {
1346
-            return '';
1347
-        }
1348
-
1349
-        $order_by = '';
1350
-        if ( count($order_query) > 1 ) {
1326
+		if ( empty($order_query) ) {
1327
+			return '';
1328
+		}
1329
+
1330
+		// remove ORDER BY before santizing
1331
+		$order_query = strtolower($order_query);
1332
+		if ( strpos($order_query, 'order by') !== false ) {
1333
+			$order_query = str_replace('order by', '', $order_query);
1334
+		}
1335
+
1336
+		$order_query = explode(' ', trim($order_query));
1337
+
1338
+		$order_fields = array(
1339
+			'id', 'form_key', 'name', 'description',
1340
+			'parent_form_id', 'logged_in', 'is_template',
1341
+			'default_template', 'status', 'created_at',
1342
+		);
1343
+
1344
+		$order = trim(trim(reset($order_query), ','));
1345
+		if ( ! in_array($order, $order_fields) ) {
1346
+			return '';
1347
+		}
1348
+
1349
+		$order_by = '';
1350
+		if ( count($order_query) > 1 ) {
1351 1351
 			$order_by = end( $order_query );
1352 1352
 			self::esc_order_by( $order_by );
1353
-        }
1353
+		}
1354 1354
 
1355
-        return ' ORDER BY '. $order . ' '. $order_by;
1356
-    }
1355
+		return ' ORDER BY '. $order . ' '. $order_by;
1356
+	}
1357 1357
 
1358 1358
 	/**
1359 1359
 	 * Make sure this is ordering by either ASC or DESC
@@ -1365,183 +1365,183 @@  discard block
 block discarded – undo
1365 1365
 		}
1366 1366
 	}
1367 1367
 
1368
-    /**
1369
-     * @param string $limit
1370
-     */
1368
+	/**
1369
+	 * @param string $limit
1370
+	 */
1371 1371
 	public static function esc_limit( $limit ) {
1372
-        if ( empty($limit) ) {
1373
-            return '';
1374
-        }
1375
-
1376
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1377
-        if ( is_numeric($limit) ) {
1378
-            return ' LIMIT '. $limit;
1379
-        }
1380
-
1381
-        $limit = explode(',', trim($limit));
1382
-        foreach ( $limit as $k => $l ) {
1383
-            if ( is_numeric( $l ) ) {
1384
-                $limit[ $k ] = $l;
1385
-            }
1386
-        }
1387
-
1388
-        $limit = implode(',', $limit);
1389
-        return ' LIMIT '. $limit;
1390
-    }
1391
-
1392
-    /**
1393
-     * Get an array of values ready to go through $wpdb->prepare
1394
-     * @since 2.0
1395
-     */
1396
-    public static function prepare_array_values( $array, $type = '%s' ) {
1397
-        $placeholders = array_fill(0, count($array), $type);
1398
-        return implode(', ', $placeholders);
1399
-    }
1400
-
1401
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1402
-        if ( empty($where) ) {
1403
-            return '';
1404
-        }
1372
+		if ( empty($limit) ) {
1373
+			return '';
1374
+		}
1375
+
1376
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1377
+		if ( is_numeric($limit) ) {
1378
+			return ' LIMIT '. $limit;
1379
+		}
1380
+
1381
+		$limit = explode(',', trim($limit));
1382
+		foreach ( $limit as $k => $l ) {
1383
+			if ( is_numeric( $l ) ) {
1384
+				$limit[ $k ] = $l;
1385
+			}
1386
+		}
1387
+
1388
+		$limit = implode(',', $limit);
1389
+		return ' LIMIT '. $limit;
1390
+	}
1391
+
1392
+	/**
1393
+	 * Get an array of values ready to go through $wpdb->prepare
1394
+	 * @since 2.0
1395
+	 */
1396
+	public static function prepare_array_values( $array, $type = '%s' ) {
1397
+		$placeholders = array_fill(0, count($array), $type);
1398
+		return implode(', ', $placeholders);
1399
+	}
1400
+
1401
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1402
+		if ( empty($where) ) {
1403
+			return '';
1404
+		}
1405 1405
 
1406 1406
 		if ( is_array( $where ) ) {
1407
-            global $wpdb;
1408
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1407
+			global $wpdb;
1408
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1409 1409
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1410 1410
 		} else {
1411
-            $where = $starts_with . $where;
1412
-        }
1411
+			$where = $starts_with . $where;
1412
+		}
1413 1413
 
1414
-        return $where;
1415
-    }
1414
+		return $where;
1415
+	}
1416 1416
 
1417
-    // Pagination Methods
1417
+	// Pagination Methods
1418 1418
 
1419
-    /**
1420
-     * @param integer $current_p
1421
-     */
1419
+	/**
1420
+	 * @param integer $current_p
1421
+	 */
1422 1422
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1423 1423
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1424 1424
 	}
1425 1425
 
1426
-    /**
1427
-     * @param integer $current_p
1428
-     */
1429
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1430
-        if ( $current_p == 1 ) {
1431
-            return 1;
1432
-        } else {
1433
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1434
-        }
1435
-    }
1436
-
1437
-    /**
1438
-     * @param string $table_name
1439
-     */
1440
-    public static function &getRecordCount( $where = '', $table_name ) {
1441
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1442
-        $count = FrmDb::get_count( $table_name, $where );
1443
-        return $count;
1444
-    }
1445
-
1446
-    public static function get_referer_info() {
1447
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1448
-        return self::get_server_value('HTTP_REFERER');
1449
-    }
1426
+	/**
1427
+	 * @param integer $current_p
1428
+	 */
1429
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1430
+		if ( $current_p == 1 ) {
1431
+			return 1;
1432
+		} else {
1433
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1434
+		}
1435
+	}
1436
+
1437
+	/**
1438
+	 * @param string $table_name
1439
+	 */
1440
+	public static function &getRecordCount( $where = '', $table_name ) {
1441
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1442
+		$count = FrmDb::get_count( $table_name, $where );
1443
+		return $count;
1444
+	}
1445
+
1446
+	public static function get_referer_info() {
1447
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1448
+		return self::get_server_value('HTTP_REFERER');
1449
+	}
1450 1450
 
1451 1451
 	/**
1452 1452
 	 * @return array
1453 1453
 	 */
1454 1454
 	public static function json_to_array( $json_vars ) {
1455
-        $vars = array();
1456
-        foreach ( $json_vars as $jv ) {
1457
-            $jv_name = explode('[', $jv['name']);
1458
-            $last = count($jv_name) - 1;
1459
-            foreach ( $jv_name as $p => $n ) {
1460
-                $name = trim($n, ']');
1461
-                if ( ! isset($l1) ) {
1462
-                    $l1 = $name;
1463
-                }
1464
-
1465
-                if ( ! isset($l2) ) {
1466
-                    $l2 = $name;
1467
-                }
1468
-
1469
-                if ( ! isset($l3) ) {
1470
-                    $l3 = $name;
1471
-                }
1472
-
1473
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1474
-
1475
-                switch ( $p ) {
1476
-                    case 0:
1477
-                        $l1 = $name;
1478
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1479
-                    break;
1480
-
1481
-                    case 1:
1482
-                        $l2 = $name;
1483
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1484
-                    break;
1485
-
1486
-                    case 2:
1487
-                        $l3 = $name;
1488
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1489
-                    break;
1490
-
1491
-                    case 3:
1492
-                        $l4 = $name;
1493
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1494
-                    break;
1495
-                }
1496
-
1497
-                unset($this_val, $n);
1498
-            }
1499
-
1500
-            unset($last, $jv);
1501
-        }
1502
-
1503
-        return $vars;
1504
-    }
1505
-
1506
-    /**
1507
-     * @param string $name
1508
-     * @param string $l1
1509
-     */
1510
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1511
-        if ( $name == '' ) {
1512
-            $vars[] = $val;
1513
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1514
-            $vars[ $l1 ] = $val;
1515
-        }
1516
-    }
1455
+		$vars = array();
1456
+		foreach ( $json_vars as $jv ) {
1457
+			$jv_name = explode('[', $jv['name']);
1458
+			$last = count($jv_name) - 1;
1459
+			foreach ( $jv_name as $p => $n ) {
1460
+				$name = trim($n, ']');
1461
+				if ( ! isset($l1) ) {
1462
+					$l1 = $name;
1463
+				}
1464
+
1465
+				if ( ! isset($l2) ) {
1466
+					$l2 = $name;
1467
+				}
1468
+
1469
+				if ( ! isset($l3) ) {
1470
+					$l3 = $name;
1471
+				}
1472
+
1473
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1474
+
1475
+				switch ( $p ) {
1476
+					case 0:
1477
+						$l1 = $name;
1478
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1479
+					break;
1480
+
1481
+					case 1:
1482
+						$l2 = $name;
1483
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1484
+					break;
1485
+
1486
+					case 2:
1487
+						$l3 = $name;
1488
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1489
+					break;
1490
+
1491
+					case 3:
1492
+						$l4 = $name;
1493
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1494
+					break;
1495
+				}
1496
+
1497
+				unset($this_val, $n);
1498
+			}
1499
+
1500
+			unset($last, $jv);
1501
+		}
1502
+
1503
+		return $vars;
1504
+	}
1505
+
1506
+	/**
1507
+	 * @param string $name
1508
+	 * @param string $l1
1509
+	 */
1510
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1511
+		if ( $name == '' ) {
1512
+			$vars[] = $val;
1513
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1514
+			$vars[ $l1 ] = $val;
1515
+		}
1516
+	}
1517 1517
 
1518 1518
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1519
-        $tooltips = array(
1520
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1521
-            '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' ),
1522
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1523
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1524
-            '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' ),
1525
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1526
-            '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() ) ),
1527
-        );
1528
-
1529
-        if ( ! isset( $tooltips[ $name ] ) ) {
1530
-            return;
1531
-        }
1532
-
1533
-        if ( 'open' == $class ) {
1534
-            echo ' frm_help"';
1535
-        } else {
1536
-            echo ' class="frm_help"';
1537
-        }
1538
-
1539
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1540
-
1541
-        if ( 'open' != $class ) {
1542
-            echo '"';
1543
-        }
1544
-    }
1519
+		$tooltips = array(
1520
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1521
+			'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' ),
1522
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1523
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1524
+			'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' ),
1525
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1526
+			'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() ) ),
1527
+		);
1528
+
1529
+		if ( ! isset( $tooltips[ $name ] ) ) {
1530
+			return;
1531
+		}
1532
+
1533
+		if ( 'open' == $class ) {
1534
+			echo ' frm_help"';
1535
+		} else {
1536
+			echo ' class="frm_help"';
1537
+		}
1538
+
1539
+		echo ' title="'. esc_attr( $tooltips[ $name ] );
1540
+
1541
+		if ( 'open' != $class ) {
1542
+			echo '"';
1543
+		}
1544
+	}
1545 1545
 
1546 1546
 	/**
1547 1547
 	 * Add the current_page class to that page in the form nav
@@ -1557,35 +1557,35 @@  discard block
 block discarded – undo
1557 1557
 		}
1558 1558
 	}
1559 1559
 
1560
-    /**
1561
-     * Prepare and json_encode post content
1562
-     *
1563
-     * @since 2.0
1564
-     *
1565
-     * @param array $post_content
1566
-     * @return string $post_content ( json encoded array )
1567
-     */
1568
-    public static function prepare_and_encode( $post_content ) {
1569
-        //Loop through array to strip slashes and add only the needed ones
1560
+	/**
1561
+	 * Prepare and json_encode post content
1562
+	 *
1563
+	 * @since 2.0
1564
+	 *
1565
+	 * @param array $post_content
1566
+	 * @return string $post_content ( json encoded array )
1567
+	 */
1568
+	public static function prepare_and_encode( $post_content ) {
1569
+		//Loop through array to strip slashes and add only the needed ones
1570 1570
 		foreach ( $post_content as $key => $val ) {
1571 1571
 			// Replace problematic characters (like &quot;)
1572 1572
 			$val = str_replace( '&quot;', '"', $val );
1573 1573
 
1574 1574
 			self::prepare_action_slashes( $val, $key, $post_content );
1575
-            unset( $key, $val );
1576
-        }
1575
+			unset( $key, $val );
1576
+		}
1577 1577
 
1578
-        // json_encode the array
1579
-        $post_content = json_encode( $post_content );
1578
+		// json_encode the array
1579
+		$post_content = json_encode( $post_content );
1580 1580
 
1581
-	    // add extra slashes for \r\n since WP strips them
1581
+		// add extra slashes for \r\n since WP strips them
1582 1582
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1583 1583
 
1584
-        // allow for &quot
1585
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1584
+		// allow for &quot
1585
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1586 1586
 
1587
-        return $post_content;
1588
-    }
1587
+		return $post_content;
1588
+	}
1589 1589
 
1590 1590
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1591 1591
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1653,64 +1653,64 @@  discard block
 block discarded – undo
1653 1653
 	}
1654 1654
 
1655 1655
 	public static function maybe_json_decode( $string ) {
1656
-        if ( is_array($string) ) {
1657
-            return $string;
1658
-        }
1656
+		if ( is_array($string) ) {
1657
+			return $string;
1658
+		}
1659 1659
 
1660
-        $new_string = json_decode($string, true);
1661
-        if ( function_exists('json_last_error') ) {
1660
+		$new_string = json_decode($string, true);
1661
+		if ( function_exists('json_last_error') ) {
1662 1662
 			// php 5.3+
1663
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1664
-                $string = $new_string;
1665
-            }
1666
-        } else if ( isset($new_string) ) {
1663
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1664
+				$string = $new_string;
1665
+			}
1666
+		} else if ( isset($new_string) ) {
1667 1667
 			// php < 5.3 fallback
1668
-            $string = $new_string;
1669
-        }
1670
-        return $string;
1671
-    }
1672
-
1673
-    /**
1674
-     * @since 1.07.10
1675
-     *
1676
-     * @param string $post_type The name of the post type that may need to be highlighted
1677
-     * @return echo The javascript to open and highlight the Formidable menu
1678
-     */
1668
+			$string = $new_string;
1669
+		}
1670
+		return $string;
1671
+	}
1672
+
1673
+	/**
1674
+	 * @since 1.07.10
1675
+	 *
1676
+	 * @param string $post_type The name of the post type that may need to be highlighted
1677
+	 * @return echo The javascript to open and highlight the Formidable menu
1678
+	 */
1679 1679
 	public static function maybe_highlight_menu( $post_type ) {
1680
-        global $post, $pagenow;
1680
+		global $post, $pagenow;
1681 1681
 
1682
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1683
-            return;
1684
-        }
1682
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1683
+			return;
1684
+		}
1685 1685
 
1686
-        if ( is_object($post) && $post->post_type != $post_type ) {
1687
-            return;
1688
-        }
1686
+		if ( is_object($post) && $post->post_type != $post_type ) {
1687
+			return;
1688
+		}
1689 1689
 
1690
-        self::load_admin_wide_js();
1691
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1692
-    }
1690
+		self::load_admin_wide_js();
1691
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1692
+	}
1693 1693
 
1694
-    /**
1695
-     * Load the JS file on non-Formidable pages in the admin area
1696
-     * @since 2.0
1697
-     */
1694
+	/**
1695
+	 * Load the JS file on non-Formidable pages in the admin area
1696
+	 * @since 2.0
1697
+	 */
1698 1698
 	public static function load_admin_wide_js( $load = true ) {
1699
-        $version = FrmAppHelper::plugin_version();
1699
+		$version = FrmAppHelper::plugin_version();
1700 1700
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1701 1701
 
1702
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1702
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1703 1703
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1704
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1704
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1705 1705
 			'url'          => FrmAppHelper::plugin_url(),
1706 1706
 			'loading'      => __( 'Loading&hellip;' ),
1707 1707
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1708
-        ) );
1708
+		) );
1709 1709
 
1710 1710
 		if ( $load ) {
1711 1711
 			wp_enqueue_script( 'formidable_admin_global' );
1712 1712
 		}
1713
-    }
1713
+	}
1714 1714
 
1715 1715
 	/**
1716 1716
 	 * @since 2.0.9
@@ -1719,9 +1719,9 @@  discard block
 block discarded – undo
1719 1719
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1720 1720
 	}
1721 1721
 
1722
-    /**
1723
-     * @param string $location
1724
-     */
1722
+	/**
1723
+	 * @param string $location
1724
+	 */
1725 1725
 	public static function localize_script( $location ) {
1726 1726
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1727 1727
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1771,81 +1771,81 @@  discard block
 block discarded – undo
1771 1771
 		}
1772 1772
 	}
1773 1773
 
1774
-    /**
1775
-     * @since 1.07.10
1776
-     *
1777
-     * @param float $min_version The version the add-on requires
1778
-     * @return echo The message on the plugins listing page
1779
-     */
1774
+	/**
1775
+	 * @since 1.07.10
1776
+	 *
1777
+	 * @param float $min_version The version the add-on requires
1778
+	 * @return echo The message on the plugins listing page
1779
+	 */
1780 1780
 	public static function min_version_notice( $min_version ) {
1781
-        $frm_version = self::plugin_version();
1781
+		$frm_version = self::plugin_version();
1782 1782
 
1783
-        // check if Formidable meets minimum requirements
1784
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1785
-            return;
1786
-        }
1783
+		// check if Formidable meets minimum requirements
1784
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1785
+			return;
1786
+		}
1787 1787
 
1788
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1788
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1789 1789
 		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">' .
1790
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1791
-        '</div></td></tr>';
1792
-    }
1793
-
1794
-    public static function locales( $type = 'date' ) {
1795
-        $locales = array(
1796
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1797
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1798
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1799
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1800
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1801
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1802
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1803
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1804
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1805
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1806
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1807
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1808
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1809
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1810
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1811
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1812
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1813
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1814
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1815
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1816
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1817
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1818
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1819
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1820
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1821
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1822
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1823
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1824
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1825
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1826
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1827
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1828
-        );
1829
-
1830
-        if ( $type == 'captcha' ) {
1831
-            // remove the languages unavailable for the captcha
1832
-            $unset = array(
1833
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1834
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1835
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1836
-            );
1837
-        } else {
1838
-            // remove the languages unavailable for the datepicker
1839
-            $unset = array(
1840
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1841
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1842
-                'es-419', 'tr',
1843
-            );
1844
-        }
1845
-
1846
-        $locales = array_diff_key($locales, array_flip($unset));
1847
-        $locales = apply_filters('frm_locales', $locales);
1848
-
1849
-        return $locales;
1850
-    }
1790
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1791
+		'</div></td></tr>';
1792
+	}
1793
+
1794
+	public static function locales( $type = 'date' ) {
1795
+		$locales = array(
1796
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1797
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1798
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1799
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1800
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1801
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1802
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1803
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1804
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1805
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1806
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1807
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1808
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1809
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1810
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1811
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1812
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1813
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1814
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1815
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1816
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1817
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1818
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1819
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1820
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1821
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1822
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1823
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1824
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1825
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1826
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1827
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1828
+		);
1829
+
1830
+		if ( $type == 'captcha' ) {
1831
+			// remove the languages unavailable for the captcha
1832
+			$unset = array(
1833
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1834
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1835
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1836
+			);
1837
+		} else {
1838
+			// remove the languages unavailable for the datepicker
1839
+			$unset = array(
1840
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1841
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1842
+				'es-419', 'tr',
1843
+			);
1844
+		}
1845
+
1846
+		$locales = array_diff_key($locales, array_flip($unset));
1847
+		$locales = apply_filters('frm_locales', $locales);
1848
+
1849
+		return $locales;
1850
+	}
1851 1851
 }
Please login to merge, or discard this patch.
classes/helpers/FrmCSVExportHelper.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class FrmCSVExportHelper{
3
+class FrmCSVExportHelper {
4 4
 	protected static $separator        = ', ';
5 5
 	protected static $column_separator = ',';
6 6
 	protected static $line_break       = 'return';
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		header( 'Content-Description: File Transfer' );
64 64
 		header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' );
65 65
 		header( 'Content-Type: text/csv; charset=' . self::$charset, true );
66
-		header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date('Y' ) ) ) . ' GMT' );
66
+		header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) ) ) . ' GMT' );
67 67
 		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
68 68
 		header( 'Cache-Control: no-cache, must-revalidate' );
69 69
 		header( 'Pragma: no-cache' );
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 	private static function csv_headings( &$headings ) {
88 88
 		foreach ( self::$fields as $col ) {
89 89
 			if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ) ) ) {
90
-				$headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) );
90
+				$headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) );
91 91
 			}
92 92
 
93
-			$headings[ $col->id ] = strip_tags( $col->name );
93
+			$headings[$col->id] = strip_tags( $col->name );
94 94
 		}
95 95
 
96 96
 		if ( self::$comment_count ) {
97
-			for ( $i = 0; $i < self::$comment_count; $i++ ) {
98
-				$headings[ 'comment' . $i ] = __( 'Comment', 'formidable' );
99
-				$headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' );
100
-				$headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' );
97
+			for ( $i = 0; $i < self::$comment_count; $i ++ ) {
98
+				$headings['comment' . $i] = __( 'Comment', 'formidable' );
99
+				$headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' );
100
+				$headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' );
101 101
 			}
102
-			unset($i);
102
+			unset( $i );
103 103
 		}
104 104
 
105 105
 		$headings['created_at'] = __( 'Timestamp', 'formidable' );
@@ -146,30 +146,30 @@  discard block
 block discarded – undo
146 146
 					continue;
147 147
 				}
148 148
 
149
-				if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) {
150
-					$entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array();
151
-				} else if ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) {
149
+				if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) {
150
+					$entries[self::$entry->parent_item_id]->metas[$meta_id] = array();
151
+				} else if ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) {
152 152
 					// if the data is here, it should be an array but if this field has collected data
153 153
 					// both while inside and outside of the repeating section, it's possible this is a string
154
-					$entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ];
154
+					$entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id];
155 155
 				}
156 156
 
157 157
 				//add the repeated values
158
-				$entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value;
158
+				$entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value;
159 159
 			}
160
-			$entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas;
160
+			$entries[self::$entry->parent_item_id]->metas += self::$entry->metas;
161 161
 		}
162 162
 
163 163
 		// add the embedded form id
164
-		if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) {
165
-			$entries[ self::$entry->parent_item_id ]->embedded_fields = array();
164
+		if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) {
165
+			$entries[self::$entry->parent_item_id]->embedded_fields = array();
166 166
 		}
167
-		$entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id;
167
+		$entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id;
168 168
 	}
169 169
 
170 170
 	private static function add_field_values_to_csv( &$row ) {
171 171
 		foreach ( self::$fields as $col ) {
172
-			$field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false;
172
+			$field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false;
173 173
 
174 174
 			$field_value = maybe_unserialize( $field_value );
175 175
 			$field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator ) );
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 				$sep_value = FrmEntriesHelper::display_value( $field_value, $col, array(
179 179
 					'type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false,
180 180
 					'entry_id' => self::$entry->id, 'sep' => self::$separator,
181
-					'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0,
181
+					'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[self::$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0,
182 182
 					) );
183
-				$row[ $col->id . '_label' ] = $sep_value;
183
+				$row[$col->id . '_label'] = $sep_value;
184 184
 				unset( $sep_value );
185 185
 			}
186 186
 
187
-			$row[ $col->id ] = $field_value;
187
+			$row[$col->id] = $field_value;
188 188
 
189 189
 			unset( $col, $field_value );
190 190
 		}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 		$col_count = count( $rows );
206 206
 		$this_col = 0;
207 207
 		foreach ( $rows as $k => $row ) {
208
-			$this_col++;
208
+			$this_col ++;
209 209
 
210
-			if ( ! isset( self::$headings[ $k ] ) ) {
210
+			if ( ! isset( self::$headings[$k] ) ) {
211 211
 				// this column has been removed from the csv, so skip it
212 212
 				continue;
213 213
 			}
Please login to merge, or discard this patch.
classes/models/FrmAddon.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@
 block discarded – undo
275 275
 		return $message;
276 276
 	}
277 277
 
278
-    public function manually_queue_update() {
279
-        set_site_transient( 'update_plugins', null );
280
-    }
278
+	public function manually_queue_update() {
279
+		set_site_transient( 'update_plugins', null );
280
+	}
281 281
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	public function insert_installed_addon( $plugins ) {
41
-		$plugins[ $this->plugin_slug ] = $this;
41
+		$plugins[$this->plugin_slug] = $this;
42 42
 		return $plugins;
43 43
 	}
44 44
 
45 45
 	public static function get_addon( $plugin_slug ) {
46 46
 		$plugins = apply_filters( 'frm_installed_addons', array() );
47 47
 		$plugin = false;
48
-		if ( isset( $plugins[ $plugin_slug ] ) ) {
49
-			$plugin = $plugins[ $plugin_slug ];
48
+		if ( isset( $plugins[$plugin_slug] ) ) {
49
+			$plugin = $plugins[$plugin_slug];
50 50
 		}
51 51
 		return $plugin;
52 52
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	public function show_license_message( $file, $plugin ) {
99 99
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
100 100
 		echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
101
-		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
101
+		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
102 102
 		$id = sanitize_title( $plugin['Name'] );
103 103
 		echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
104 104
 		echo '</div></td></tr>';
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 
112 112
 		if ( $this->is_current_version( $transient ) ) {
113 113
 			//make sure it doesn't show there is an update if plugin is up-to-date
114
-			if ( isset( $transient->response[ $this->plugin_folder ] ) ) {
115
-				unset( $transient->response[ $this->plugin_folder ] );
114
+			if ( isset( $transient->response[$this->plugin_folder] ) ) {
115
+				unset( $transient->response[$this->plugin_folder] );
116 116
 			}
117
-		} else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) {
117
+		} else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) {
118 118
 			$cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' );
119 119
 			$version_info = get_transient( $cache_key );
120 120
 			if ( $version_info !== false && version_compare( $version_info->new_version, $this->version, '>' ) ) {
121
-				$transient->response[ $this->plugin_folder ] = $version_info;
121
+				$transient->response[$this->plugin_folder] = $version_info;
122 122
 			} else {
123 123
 				delete_transient( $cache_key );
124 124
 				if ( ! $this->has_been_cleared() ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 					$this->manually_queue_update();
128 128
 				}
129 129
 
130
-				unset( $transient->response[ $this->plugin_folder ] );
130
+				unset( $transient->response[$this->plugin_folder] );
131 131
 			}
132 132
 		}
133 133
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	private function is_current_version( $transient ) {
138
-		if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) {
138
+		if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) {
139 139
 			return false;
140 140
 		}
141 141
 
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
 			return true;
145 145
 		}
146 146
 
147
-		return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version;
147
+		return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version;
148 148
 	}
149 149
 
150 150
 	private function has_been_cleared() {
151 151
 		$last_cleared = get_option( 'frm_last_cleared' );
152
-		return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) );
152
+		return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) );
153 153
 	}
154 154
 
155 155
 	private function cleared_plugins() {
156
-		update_option( 'frm_last_cleared', date('Y-m-d H:i:s') );
156
+		update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) );
157 157
 	}
158 158
 
159 159
 	public static function activate() {
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 
254 254
 		$message = __( 'Your License Key was invalid', 'formidable' );
255 255
 		if ( is_wp_error( $resp ) ) {
256
-			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>');
256
+			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' );
257 257
 			if ( is_wp_error( $resp ) ) {
258
-				$message .= ' '. $resp->get_error_message();
258
+				$message .= ' ' . $resp->get_error_message();
259 259
 			}
260 260
 		} else if ( $body == 'error' || is_wp_error( $body ) ) {
261 261
 			$message = __( 'You had an HTTP error connecting to Formidable Pro\'s API', 'formidable' );
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 					$message = $json_res;
269 269
 				}
270 270
 			} else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) {
271
-				$message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] );
271
+				$message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] );
272 272
 			}
273 273
 		}
274 274
 
Please login to merge, or discard this patch.
classes/views/styles/_form-description.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <div class="field-group clearfix frm-half frm-first-row">
2 2
     <label><?php _e( 'Size', 'formidable' ) ?></label>
3
-    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" />
3
+    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" />
4 4
 </div>
5 5
 
6 6
 <div class="field-group clearfix frm-half frm-first-row">
7 7
     <label><?php _e( 'Color', 'formidable' ) ?></label>
8
-    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" />
8
+    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" />
9 9
 </div>
10 10
 <div class="field-group clearfix frm-half">
11 11
     <label><?php _e( 'Margin Top', 'formidable' ) ?></label>
12
-    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_top') ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" />
12
+    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_top' ) ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" />
13 13
 </div>
14 14
 <div class="field-group clearfix frm-half">
15 15
     <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label>
16
-    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_bottom') ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" />
16
+    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_bottom' ) ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" />
17 17
 </div>
Please login to merge, or discard this patch.
classes/views/styles/_form-title.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <div class="field-group clearfix frm-half frm-first-row">
2 2
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" />
4 4
 </div>
5 5
 
6 6
 <div class="field-group clearfix frm-half frm-first-row">
7 7
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
8
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" />
8
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" />
9 9
 </div>
10 10
 <div class="field-group clearfix frm-half">
11 11
 	<label><?php _e( 'Margin Top', 'formidable' ) ?></label>
12
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" />
12
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" />
13 13
 </div>
14 14
 <div class="field-group clearfix frm-half">
15 15
     <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label>
16
-    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" />
16
+    <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" />
17 17
 </div>
Please login to merge, or discard this patch.