Completed
Push — master ( 96f068...f666fb )
by Stephanie
03:52
created
classes/helpers/FrmAppHelper.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -746,6 +746,9 @@  discard block
 block discarded – undo
746 746
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
747 747
     }
748 748
 
749
+	/**
750
+	 * @param string $function
751
+	 */
749 752
 	public static function recursive_function_map( $value, $function ) {
750 753
 		if ( is_array( $value ) ) {
751 754
 			$original_function = $function;
@@ -1173,6 +1176,9 @@  discard block
 block discarded – undo
1173 1176
         return $sub . (($len < $original_len) ? $continue : '');
1174 1177
     }
1175 1178
 
1179
+	/**
1180
+	 * @param string[] $function_names
1181
+	 */
1176 1182
 	public static function mb_function( $function_names, $args ) {
1177 1183
 		$mb_function_name = $function_names[0];
1178 1184
 		$function_name = $function_names[1];
@@ -1206,6 +1212,9 @@  discard block
 block discarded – undo
1206 1212
         return $formatted;
1207 1213
     }
1208 1214
 
1215
+	/**
1216
+	 * @param string $time_format
1217
+	 */
1209 1218
 	private static function add_time_to_date( $time_format, $date ) {
1210 1219
 		if ( empty( $time_format ) ) {
1211 1220
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1181 added lines, -1181 removed lines patch added patch discarded remove patch
@@ -12,123 +12,123 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.0.19b3';
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
-    }
59
-
60
-    /**
61
-     * Get the Formidable settings
62
-     *
63
-     * @since 2.0
64
-     *
65
-     * @param None
66
-     * @return FrmSettings $frm_setings
67
-     */
68
-    public static function get_settings() {
69
-        global $frm_settings;
70
-        if ( empty($frm_settings) ) {
71
-            $frm_settings = new FrmSettings();
72
-        }
73
-        return $frm_settings;
74
-    }
75
-
76
-    /**
77
-     * Show a message in place of pro features
78
-     *
79
-     * @since 2.0
80
-     */
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
+
60
+	/**
61
+	 * Get the Formidable settings
62
+	 *
63
+	 * @since 2.0
64
+	 *
65
+	 * @param None
66
+	 * @return FrmSettings $frm_setings
67
+	 */
68
+	public static function get_settings() {
69
+		global $frm_settings;
70
+		if ( empty($frm_settings) ) {
71
+			$frm_settings = new FrmSettings();
72
+		}
73
+		return $frm_settings;
74
+	}
75
+
76
+	/**
77
+	 * Show a message in place of pro features
78
+	 *
79
+	 * @since 2.0
80
+	 */
81 81
 	public static function update_message( $features, $class = '' ) {
82 82
 		_deprecated_function( __FUNCTION__, '2.0.19' );
83
-    }
84
-
85
-    public static function pro_is_installed() {
86
-        return apply_filters('frm_pro_installed', false);
87
-    }
88
-
89
-    /**
90
-     * Check for certain page in Formidable settings
91
-     *
92
-     * @since 2.0
93
-     *
94
-     * @param string $page The name of the page to check
95
-     * @return boolean
96
-     */
83
+	}
84
+
85
+	public static function pro_is_installed() {
86
+		return apply_filters('frm_pro_installed', false);
87
+	}
88
+
89
+	/**
90
+	 * Check for certain page in Formidable settings
91
+	 *
92
+	 * @since 2.0
93
+	 *
94
+	 * @param string $page The name of the page to check
95
+	 * @return boolean
96
+	 */
97 97
 	public static function is_admin_page( $page = 'formidable' ) {
98
-        global $pagenow;
98
+		global $pagenow;
99 99
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
100
-        if ( $pagenow ) {
100
+		if ( $pagenow ) {
101 101
 			return $pagenow == 'admin.php' && $get_page == $page;
102
-        }
102
+		}
103 103
 
104 104
 		return is_admin() && $get_page == $page;
105
-    }
106
-
107
-    /**
108
-     * Check for the form preview page
109
-     *
110
-     * @since 2.0
111
-     *
112
-     * @param None
113
-     * @return boolean
114
-     */
115
-    public static function is_preview_page() {
116
-        global $pagenow;
105
+	}
106
+
107
+	/**
108
+	 * Check for the form preview page
109
+	 *
110
+	 * @since 2.0
111
+	 *
112
+	 * @param None
113
+	 * @return boolean
114
+	 */
115
+	public static function is_preview_page() {
116
+		global $pagenow;
117 117
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
118 118
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
119
-    }
119
+	}
120 120
 
121
-    /**
122
-     * Check for ajax except the form preview page
123
-     *
124
-     * @since 2.0
125
-     *
126
-     * @param None
127
-     * @return boolean
128
-     */
129
-    public static function doing_ajax() {
130
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
131
-    }
121
+	/**
122
+	 * Check for ajax except the form preview page
123
+	 *
124
+	 * @since 2.0
125
+	 *
126
+	 * @param None
127
+	 * @return boolean
128
+	 */
129
+	public static function doing_ajax() {
130
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
131
+	}
132 132
 
133 133
 	/**
134 134
 	 * @since 2.0.8
@@ -138,101 +138,101 @@  discard block
 block discarded – undo
138 138
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
139 139
 	}
140 140
 
141
-    /**
142
-     * Check if on an admin page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_admin() {
150
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
151
-    }
152
-
153
-    /**
154
-     * Check if value contains blank value or empty array
155
-     *
156
-     * @since 2.0
157
-     * @param $value - value to check
158
-     * @return boolean
159
-     */
160
-    public static function is_empty_value( $value, $empty = '' ) {
161
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
162
-    }
163
-
164
-    public static function is_not_empty_value( $value, $empty = '' ) {
165
-        return ! self::is_empty_value( $value, $empty );
166
-    }
167
-
168
-    /**
169
-     * Get any value from the $_SERVER
170
-     *
171
-     * @since 2.0
172
-     * @param string $value
173
-     * @return string
174
-     */
141
+	/**
142
+	 * Check if on an admin page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_admin() {
150
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
151
+	}
152
+
153
+	/**
154
+	 * Check if value contains blank value or empty array
155
+	 *
156
+	 * @since 2.0
157
+	 * @param $value - value to check
158
+	 * @return boolean
159
+	 */
160
+	public static function is_empty_value( $value, $empty = '' ) {
161
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
162
+	}
163
+
164
+	public static function is_not_empty_value( $value, $empty = '' ) {
165
+		return ! self::is_empty_value( $value, $empty );
166
+	}
167
+
168
+	/**
169
+	 * Get any value from the $_SERVER
170
+	 *
171
+	 * @since 2.0
172
+	 * @param string $value
173
+	 * @return string
174
+	 */
175 175
 	public static function get_server_value( $value ) {
176
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
177
-    }
178
-
179
-    /**
180
-     * Check for the IP address in several places
181
-     * Used by [ip] shortcode
182
-     *
183
-     * @return string The IP address of the current user
184
-     */
185
-    public static function get_ip_address() {
176
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
177
+	}
178
+
179
+	/**
180
+	 * Check for the IP address in several places
181
+	 * Used by [ip] shortcode
182
+	 *
183
+	 * @return string The IP address of the current user
184
+	 */
185
+	public static function get_ip_address() {
186 186
 		$ip = '';
187
-        foreach ( array(
188
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
189
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
190
-        ) as $key ) {
191
-            if ( ! isset( $_SERVER[ $key ] ) ) {
192
-                continue;
193
-            }
194
-
195
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
196
-                $ip = trim($ip); // just to be safe
197
-
198
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
199
-                    return $ip;
200
-                }
201
-            }
202
-        }
187
+		foreach ( array(
188
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
189
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
190
+		) as $key ) {
191
+			if ( ! isset( $_SERVER[ $key ] ) ) {
192
+				continue;
193
+			}
194
+
195
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
196
+				$ip = trim($ip); // just to be safe
197
+
198
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
199
+					return $ip;
200
+				}
201
+			}
202
+		}
203 203
 
204 204
 		return sanitize_text_field( $ip );
205
-    }
205
+	}
206 206
 
207
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
208
-        if ( strpos($param, '[') ) {
209
-            $params = explode('[', $param);
210
-            $param = $params[0];
211
-        }
207
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
208
+		if ( strpos($param, '[') ) {
209
+			$params = explode('[', $param);
210
+			$param = $params[0];
211
+		}
212 212
 
213 213
 		if ( $src == 'get' ) {
214
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
215
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
216
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
217
-            }
214
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
215
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
216
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
217
+			}
218 218
 			self::sanitize_value( $sanitize, $value );
219 219
 		} else {
220
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
221
-        }
220
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
221
+		}
222 222
 
223 223
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
224
-            foreach ( $params as $k => $p ) {
225
-                if ( ! $k || ! is_array($value) ) {
226
-                    continue;
227
-                }
224
+			foreach ( $params as $k => $p ) {
225
+				if ( ! $k || ! is_array($value) ) {
226
+					continue;
227
+				}
228 228
 
229
-                $p = trim($p, ']');
230
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
231
-            }
232
-        }
229
+				$p = trim($p, ']');
230
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
231
+			}
232
+		}
233 233
 
234
-        return $value;
235
-    }
234
+		return $value;
235
+	}
236 236
 
237 237
 	/**
238 238
 	 *
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
255 255
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
256
-    }
256
+	}
257 257
 
258 258
 	/**
259 259
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 	}
288 288
 
289 289
 	/**
290
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
291
-	*
292
-	* @since 2.0.8
293
-	* @param string $value
294
-	* @return string $value
295
-	*/
290
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
291
+	 *
292
+	 * @since 2.0.8
293
+	 * @param string $value
294
+	 * @return string $value
295
+	 */
296 296
 	public static function preserve_backslashes( $value ) {
297 297
 		// If backslashes have already been added, don't add them again
298 298
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 	}
313 313
 
314
-    public static function sanitize_request( $sanitize_method, &$values ) {
315
-        $temp_values = $values;
316
-        foreach ( $temp_values as $k => $val ) {
317
-            if ( isset( $sanitize_method[ $k ] ) ) {
314
+	public static function sanitize_request( $sanitize_method, &$values ) {
315
+		$temp_values = $values;
316
+		foreach ( $temp_values as $k => $val ) {
317
+			if ( isset( $sanitize_method[ $k ] ) ) {
318 318
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
319
-            }
320
-        }
321
-    }
319
+			}
320
+		}
321
+	}
322 322
 
323 323
 	public static function sanitize_array( &$values ) {
324 324
 		$temp_values = $values;
@@ -333,12 +333,12 @@  discard block
 block discarded – undo
333 333
 	 */
334 334
 	public static function kses( $value, $allowed = array() ) {
335 335
 		$html = array(
336
-		    'a' => array(
336
+			'a' => array(
337 337
 				'href'  => array(),
338 338
 				'title' => array(),
339 339
 				'id'    => array(),
340 340
 				'class' => array(),
341
-		    ),
341
+			),
342 342
 		);
343 343
 
344 344
 		$allowed_html = array();
@@ -349,176 +349,176 @@  discard block
 block discarded – undo
349 349
 		return wp_kses( $value, $allowed_html );
350 350
 	}
351 351
 
352
-    /**
353
-     * Used when switching the action for a bulk action
354
-     * @since 2.0
355
-     */
356
-    public static function remove_get_action() {
357
-        if ( ! isset($_GET) ) {
358
-            return;
359
-        }
352
+	/**
353
+	 * Used when switching the action for a bulk action
354
+	 * @since 2.0
355
+	 */
356
+	public static function remove_get_action() {
357
+		if ( ! isset($_GET) ) {
358
+			return;
359
+		}
360 360
 
361
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
362
-        if ( ! empty( $new_action ) ) {
361
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
362
+		if ( ! empty( $new_action ) ) {
363 363
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
364
-        }
365
-    }
366
-
367
-    /**
368
-     * Check the WP query for a parameter
369
-     *
370
-     * @since 2.0
371
-     * @return string|array
372
-     */
373
-    public static function get_query_var( $value, $param ) {
374
-        if ( $value != '' ) {
375
-            return $value;
376
-        }
377
-
378
-        global $wp_query;
379
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
380
-            $value = $wp_query->query_vars[ $param ];
381
-        }
382
-
383
-        return $value;
384
-    }
385
-
386
-    /**
387
-     * @param string $type
388
-     */
389
-    public static function trigger_hook_load( $type, $object = null ) {
390
-        // only load the form hooks once
391
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
392
-        if ( ! $hooks_loaded ) {
393
-            do_action('frm_load_'. $type .'_hooks');
394
-        }
395
-    }
396
-
397
-    /**
398
-     * Check cache before fetching values and saving to cache
399
-     *
400
-     * @since 2.0
401
-     *
402
-     * @param string $cache_key The unique name for this cache
403
-     * @param string $group The name of the cache group
404
-     * @param string $query If blank, don't run a db call
405
-     * @param string $type The wpdb function to use with this query
406
-     * @return mixed $results The cache or query results
407
-     */
408
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
409
-        $results = wp_cache_get($cache_key, $group);
410
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
411
-            return $results;
412
-        }
413
-
414
-        if ( 'get_posts' == $type ) {
415
-            $results = get_posts($query);
416
-        } else {
417
-            global $wpdb;
418
-            $results = $wpdb->{$type}($query);
419
-        }
364
+		}
365
+	}
366
+
367
+	/**
368
+	 * Check the WP query for a parameter
369
+	 *
370
+	 * @since 2.0
371
+	 * @return string|array
372
+	 */
373
+	public static function get_query_var( $value, $param ) {
374
+		if ( $value != '' ) {
375
+			return $value;
376
+		}
377
+
378
+		global $wp_query;
379
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
380
+			$value = $wp_query->query_vars[ $param ];
381
+		}
382
+
383
+		return $value;
384
+	}
385
+
386
+	/**
387
+	 * @param string $type
388
+	 */
389
+	public static function trigger_hook_load( $type, $object = null ) {
390
+		// only load the form hooks once
391
+		$hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
392
+		if ( ! $hooks_loaded ) {
393
+			do_action('frm_load_'. $type .'_hooks');
394
+		}
395
+	}
396
+
397
+	/**
398
+	 * Check cache before fetching values and saving to cache
399
+	 *
400
+	 * @since 2.0
401
+	 *
402
+	 * @param string $cache_key The unique name for this cache
403
+	 * @param string $group The name of the cache group
404
+	 * @param string $query If blank, don't run a db call
405
+	 * @param string $type The wpdb function to use with this query
406
+	 * @return mixed $results The cache or query results
407
+	 */
408
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
409
+		$results = wp_cache_get($cache_key, $group);
410
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
411
+			return $results;
412
+		}
413
+
414
+		if ( 'get_posts' == $type ) {
415
+			$results = get_posts($query);
416
+		} else {
417
+			global $wpdb;
418
+			$results = $wpdb->{$type}($query);
419
+		}
420 420
 
421 421
 		if ( ! self::prevent_caching() ) {
422 422
 			wp_cache_set( $cache_key, $results, $group, $time );
423 423
 		}
424 424
 
425
-        return $results;
426
-    }
425
+		return $results;
426
+	}
427 427
 
428
-    /**
429
-     * Data that should be stored for a long time can be stored in a transient.
430
-     * First check the cache, then check the transient
431
-     * @since 2.0
432
-     * @return mixed The cached value or false
433
-     */
428
+	/**
429
+	 * Data that should be stored for a long time can be stored in a transient.
430
+	 * First check the cache, then check the transient
431
+	 * @since 2.0
432
+	 * @return mixed The cached value or false
433
+	 */
434 434
 	public static function check_cache_and_transient( $cache_key ) {
435
-        // check caching layer first
436
-        $results = self::check_cache( $cache_key );
437
-        if ( $results ) {
438
-            return $results;
439
-        }
440
-
441
-        // then check the transient
442
-        $results = get_transient($cache_key);
443
-        if ( $results ) {
444
-            wp_cache_set($cache_key, $results);
445
-        }
446
-
447
-        return $results;
448
-    }
449
-
450
-    /**
451
-     * @since 2.0
452
-     * @param string $cache_key
453
-     */
435
+		// check caching layer first
436
+		$results = self::check_cache( $cache_key );
437
+		if ( $results ) {
438
+			return $results;
439
+		}
440
+
441
+		// then check the transient
442
+		$results = get_transient($cache_key);
443
+		if ( $results ) {
444
+			wp_cache_set($cache_key, $results);
445
+		}
446
+
447
+		return $results;
448
+	}
449
+
450
+	/**
451
+	 * @since 2.0
452
+	 * @param string $cache_key
453
+	 */
454 454
 	public static function delete_cache_and_transient( $cache_key ) {
455
-        delete_transient($cache_key);
456
-        wp_cache_delete($cache_key);
457
-    }
458
-
459
-    /**
460
-     * Delete all caching in a single group
461
-     *
462
-     * @since 2.0
463
-     *
464
-     * @param string $group The name of the cache group
465
-     * @return boolean True or False
466
-     */
455
+		delete_transient($cache_key);
456
+		wp_cache_delete($cache_key);
457
+	}
458
+
459
+	/**
460
+	 * Delete all caching in a single group
461
+	 *
462
+	 * @since 2.0
463
+	 *
464
+	 * @param string $group The name of the cache group
465
+	 * @return boolean True or False
466
+	 */
467 467
 	public static function cache_delete_group( $group ) {
468
-    	global $wp_object_cache;
469
-
470
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
471
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
472
-                wp_cache_delete($k, $group);
473
-            }
474
-            return true;
475
-        }
476
-
477
-    	return false;
478
-    }
479
-
480
-    /**
481
-     * Check a value from a shortcode to see if true or false.
482
-     * True when value is 1, true, 'true', 'yes'
483
-     *
484
-     * @since 1.07.10
485
-     *
486
-     * @param string $value The value to compare
487
-     * @return boolean True or False
488
-     */
468
+		global $wp_object_cache;
469
+
470
+		if ( isset( $wp_object_cache->cache[ $group ] ) ) {
471
+			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
472
+				wp_cache_delete($k, $group);
473
+			}
474
+			return true;
475
+		}
476
+
477
+		return false;
478
+	}
479
+
480
+	/**
481
+	 * Check a value from a shortcode to see if true or false.
482
+	 * True when value is 1, true, 'true', 'yes'
483
+	 *
484
+	 * @since 1.07.10
485
+	 *
486
+	 * @param string $value The value to compare
487
+	 * @return boolean True or False
488
+	 */
489 489
 	public static function is_true( $value ) {
490
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
491
-    }
490
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
491
+	}
492 492
 
493
-    /**
494
-     * Used to filter shortcode in text widgets
495
-     */
496
-    public static function widget_text_filter_callback( $matches ) {
497
-        return do_shortcode( $matches[0] );
498
-    }
493
+	/**
494
+	 * Used to filter shortcode in text widgets
495
+	 */
496
+	public static function widget_text_filter_callback( $matches ) {
497
+		return do_shortcode( $matches[0] );
498
+	}
499 499
 
500 500
 	public static function load_scripts( $scripts ) {
501
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
502
-        foreach ( (array) $scripts as $s ) {
503
-            wp_enqueue_script($s);
504
-        }
505
-    }
501
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
502
+		foreach ( (array) $scripts as $s ) {
503
+			wp_enqueue_script($s);
504
+		}
505
+	}
506 506
 
507 507
 	public static function load_styles( $styles ) {
508
-        _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
509
-        foreach ( (array) $styles as $s ) {
510
-            wp_enqueue_style($s);
511
-        }
512
-    }
508
+		_deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
509
+		foreach ( (array) $styles as $s ) {
510
+			wp_enqueue_style($s);
511
+		}
512
+	}
513 513
 
514
-    public static function get_pages() {
514
+	public static function get_pages() {
515 515
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
516
-    }
516
+	}
517 517
 
518
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
519
-        $pages = self::get_pages();
518
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
519
+		$pages = self::get_pages();
520 520
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
521
-    ?>
521
+	?>
522 522
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
523 523
             <option value=""> </option>
524 524
             <?php foreach ( $pages as $page ) { ?>
@@ -528,107 +528,107 @@  discard block
 block discarded – undo
528 528
             <?php } ?>
529 529
         </select>
530 530
     <?php
531
-    }
531
+	}
532 532
 
533 533
 	public static function post_edit_link( $post_id ) {
534
-        $post = get_post($post_id);
535
-        if ( $post ) {
536
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
537
-        }
538
-        return '';
539
-    }
534
+		$post = get_post($post_id);
535
+		if ( $post ) {
536
+			return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
537
+		}
538
+		return '';
539
+	}
540 540
 
541 541
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
542
-    ?>
542
+	?>
543 543
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
544
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
545
-            ?> class="frm_multiselect">
544
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
545
+			?> class="frm_multiselect">
546 546
             <?php self::roles_options($capability); ?>
547 547
         </select>
548 548
     <?php
549
-    }
549
+	}
550 550
 
551 551
 	public static function roles_options( $capability ) {
552
-        global $frm_vars;
553
-        if ( isset($frm_vars['editable_roles']) ) {
554
-            $editable_roles = $frm_vars['editable_roles'];
555
-        } else {
556
-            $editable_roles = get_editable_roles();
557
-            $frm_vars['editable_roles'] = $editable_roles;
558
-        }
559
-
560
-        foreach ( $editable_roles as $role => $details ) {
561
-            $name = translate_user_role($details['name'] ); ?>
552
+		global $frm_vars;
553
+		if ( isset($frm_vars['editable_roles']) ) {
554
+			$editable_roles = $frm_vars['editable_roles'];
555
+		} else {
556
+			$editable_roles = get_editable_roles();
557
+			$frm_vars['editable_roles'] = $editable_roles;
558
+		}
559
+
560
+		foreach ( $editable_roles as $role => $details ) {
561
+			$name = translate_user_role($details['name'] ); ?>
562 562
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
563 563
 <?php
564
-            unset($role, $details);
565
-        }
566
-    }
564
+			unset($role, $details);
565
+		}
566
+	}
567 567
 
568 568
 	public static function frm_capabilities( $type = 'auto' ) {
569
-        $cap = array(
570
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
571
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
572
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
573
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
574
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
575
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
576
-        );
569
+		$cap = array(
570
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
571
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
572
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
573
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
574
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
575
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
576
+		);
577 577
 
578 578
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
579
-            return $cap;
580
-        }
579
+			return $cap;
580
+		}
581 581
 
582
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
583
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
584
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
585
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
582
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
583
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
584
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
585
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
586 586
 
587
-        return $cap;
588
-    }
587
+		return $cap;
588
+	}
589 589
 
590 590
 	public static function user_has_permission( $needed_role ) {
591
-        if ( $needed_role == '-1' ) {
592
-            return false;
591
+		if ( $needed_role == '-1' ) {
592
+			return false;
593 593
 		}
594 594
 
595
-        // $needed_role will be equal to blank if "Logged-in users" is selected
596
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
597
-            return true;
598
-        }
595
+		// $needed_role will be equal to blank if "Logged-in users" is selected
596
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
597
+			return true;
598
+		}
599 599
 
600
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
601
-        foreach ( $roles as $role ) {
600
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
601
+		foreach ( $roles as $role ) {
602 602
 			if ( current_user_can( $role ) ) {
603
-        		return true;
603
+				return true;
604 604
 			}
605
-        	if ( $role == $needed_role ) {
606
-        		break;
605
+			if ( $role == $needed_role ) {
606
+				break;
607 607
 			}
608
-        }
609
-        return false;
610
-    }
611
-
612
-    /**
613
-     * Make sure administrators can see Formidable menu
614
-     *
615
-     * @since 2.0
616
-     */
617
-    public static function maybe_add_permissions() {
608
+		}
609
+		return false;
610
+	}
611
+
612
+	/**
613
+	 * Make sure administrators can see Formidable menu
614
+	 *
615
+	 * @since 2.0
616
+	 */
617
+	public static function maybe_add_permissions() {
618 618
 		self::force_capability( 'frm_view_entries' );
619 619
 
620
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
621
-            return;
622
-        }
620
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
621
+			return;
622
+		}
623 623
 
624 624
 		$user_id = get_current_user_id();
625 625
 		$user = new WP_User( $user_id );
626
-        $frm_roles = self::frm_capabilities();
627
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
626
+		$frm_roles = self::frm_capabilities();
627
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
628 628
 			$user->add_cap( $frm_role );
629
-            unset($frm_role, $frm_role_description);
630
-        }
631
-    }
629
+			unset($frm_role, $frm_role_description);
630
+		}
631
+	}
632 632
 
633 633
 	/**
634 634
 	 * Make sure admins have permission to see the menu items
@@ -644,28 +644,28 @@  discard block
 block discarded – undo
644 644
 		}
645 645
 	}
646 646
 
647
-    /**
648
-     * Check if the user has permision for action.
649
-     * Return permission message and stop the action if no permission
650
-     * @since 2.0
651
-     * @param string $permission
652
-     */
647
+	/**
648
+	 * Check if the user has permision for action.
649
+	 * Return permission message and stop the action if no permission
650
+	 * @since 2.0
651
+	 * @param string $permission
652
+	 */
653 653
 	public static function permission_check( $permission, $show_message = 'show' ) {
654
-        $permission_error = self::permission_nonce_error($permission);
655
-        if ( $permission_error !== false ) {
656
-            if ( 'hide' == $show_message ) {
657
-                $permission_error = '';
658
-            }
659
-            wp_die($permission_error);
660
-        }
661
-    }
662
-
663
-    /**
664
-     * Check user permission and nonce
665
-     * @since 2.0
666
-     * @param string $permission
667
-     * @return false|string The permission message or false if allowed
668
-     */
654
+		$permission_error = self::permission_nonce_error($permission);
655
+		if ( $permission_error !== false ) {
656
+			if ( 'hide' == $show_message ) {
657
+				$permission_error = '';
658
+			}
659
+			wp_die($permission_error);
660
+		}
661
+	}
662
+
663
+	/**
664
+	 * Check user permission and nonce
665
+	 * @since 2.0
666
+	 * @param string $permission
667
+	 * @return false|string The permission message or false if allowed
668
+	 */
669 669
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
670 670
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
671 671
 			$frm_settings = self::get_settings();
@@ -673,75 +673,75 @@  discard block
 block discarded – undo
673 673
 		}
674 674
 
675 675
 		$error = false;
676
-        if ( empty($nonce_name) ) {
677
-            return $error;
678
-        }
676
+		if ( empty($nonce_name) ) {
677
+			return $error;
678
+		}
679 679
 
680
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
681
-            $frm_settings = self::get_settings();
682
-            $error = $frm_settings->admin_permission;
683
-        }
680
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
681
+			$frm_settings = self::get_settings();
682
+			$error = $frm_settings->admin_permission;
683
+		}
684 684
 
685
-        return $error;
686
-    }
685
+		return $error;
686
+	}
687 687
 
688
-    public static function checked( $values, $current ) {
688
+	public static function checked( $values, $current ) {
689 689
 		if ( self::check_selected( $values, $current ) ) {
690
-            echo ' checked="checked"';
690
+			echo ' checked="checked"';
691 691
 		}
692
-    }
692
+	}
693 693
 
694 694
 	public static function check_selected( $values, $current ) {
695
-        $values = self::recursive_function_map( $values, 'trim' );
696
-        $current = trim($current);
697
-
698
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
699
-    }
700
-
701
-    /**
702
-    * Check if current field option is an "other" option
703
-    *
704
-    * @since 2.0
705
-    *
706
-    * @param string $opt_key
707
-    * @return boolean Returns true if current field option is an "Other" option
708
-    */
709
-    public static function is_other_opt( $opt_key ) {
710
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
711
-        return FrmFieldsHelper::is_other_opt( $opt_key );
712
-    }
713
-
714
-    /**
715
-    * Get value that belongs in "Other" text box
716
-    *
717
-    * @since 2.0
718
-    *
719
-    * @param string $opt_key
720
-    * @param array $field
721
-    * @return string $other_val
722
-    */
723
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
695
+		$values = self::recursive_function_map( $values, 'trim' );
696
+		$current = trim($current);
697
+
698
+		return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
699
+	}
700
+
701
+	/**
702
+	 * Check if current field option is an "other" option
703
+	 *
704
+	 * @since 2.0
705
+	 *
706
+	 * @param string $opt_key
707
+	 * @return boolean Returns true if current field option is an "Other" option
708
+	 */
709
+	public static function is_other_opt( $opt_key ) {
710
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
711
+		return FrmFieldsHelper::is_other_opt( $opt_key );
712
+	}
713
+
714
+	/**
715
+	 * Get value that belongs in "Other" text box
716
+	 *
717
+	 * @since 2.0
718
+	 *
719
+	 * @param string $opt_key
720
+	 * @param array $field
721
+	 * @return string $other_val
722
+	 */
723
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
724 724
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
725 725
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
726
-    }
727
-
728
-    /**
729
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
730
-    * Intended for front-end use
731
-    *
732
-    * @since 2.0
733
-    *
734
-    * @param array $field
735
-    * @param boolean $other_opt
736
-    * @param string $checked
737
-    * @param array $args should include opt_key and field name
738
-    * @return string $other_val
739
-    */
740
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
726
+	}
727
+
728
+	/**
729
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
730
+	 * Intended for front-end use
731
+	 *
732
+	 * @since 2.0
733
+	 *
734
+	 * @param array $field
735
+	 * @param boolean $other_opt
736
+	 * @param string $checked
737
+	 * @param array $args should include opt_key and field name
738
+	 * @return string $other_val
739
+	 */
740
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
741 741
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
742 742
 		$args['field'] = $field;
743 743
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
744
-    }
744
+	}
745 745
 
746 746
 	public static function recursive_function_map( $value, $function ) {
747 747
 		if ( is_array( $value ) ) {
@@ -771,334 +771,334 @@  discard block
 block discarded – undo
771 771
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
772 772
 	}
773 773
 
774
-    /**
775
-     * Flatten a multi-dimensional array
776
-     */
774
+	/**
775
+	 * Flatten a multi-dimensional array
776
+	 */
777 777
 	public static function array_flatten( $array, $keys = 'keep' ) {
778
-        $return = array();
779
-        foreach ( $array as $key => $value ) {
780
-            if ( is_array($value) ) {
778
+		$return = array();
779
+		foreach ( $array as $key => $value ) {
780
+			if ( is_array($value) ) {
781 781
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
782
-            } else {
782
+			} else {
783 783
 				if ( $keys == 'keep' ) {
784 784
 					$return[ $key ] = $value;
785 785
 				} else {
786 786
 					$return[] = $value;
787 787
 				}
788
-            }
789
-        }
790
-        return $return;
791
-    }
792
-
793
-    public static function esc_textarea( $text ) {
794
-        $safe_text = str_replace('&quot;', '"', $text);
795
-        $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
796
-    	return apply_filters( 'esc_textarea', $safe_text, $text );
797
-    }
798
-
799
-    /**
800
-     * Add auto paragraphs to text areas
801
-     * @since 2.0
802
-     */
788
+			}
789
+		}
790
+		return $return;
791
+	}
792
+
793
+	public static function esc_textarea( $text ) {
794
+		$safe_text = str_replace('&quot;', '"', $text);
795
+		$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
796
+		return apply_filters( 'esc_textarea', $safe_text, $text );
797
+	}
798
+
799
+	/**
800
+	 * Add auto paragraphs to text areas
801
+	 * @since 2.0
802
+	 */
803 803
 	public static function use_wpautop( $content ) {
804
-        if ( apply_filters('frm_use_wpautop', true) ) {
805
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
806
-        }
807
-        return $content;
808
-    }
804
+		if ( apply_filters('frm_use_wpautop', true) ) {
805
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
806
+		}
807
+		return $content;
808
+	}
809 809
 
810 810
 	public static function replace_quotes( $val ) {
811
-        //Replace double quotes
811
+		//Replace double quotes
812 812
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
813
-        //Replace single quotes
814
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
815
-        return $val;
816
-    }
817
-
818
-    /**
819
-     * @since 2.0
820
-     * @return string The base Google APIS url for the current version of jQuery UI
821
-     */
822
-    public static function jquery_ui_base_url() {
823
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
824
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
825
-        return $url;
826
-    }
827
-
828
-    /**
829
-     * @param string $handle
830
-     */
813
+		//Replace single quotes
814
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
815
+		return $val;
816
+	}
817
+
818
+	/**
819
+	 * @since 2.0
820
+	 * @return string The base Google APIS url for the current version of jQuery UI
821
+	 */
822
+	public static function jquery_ui_base_url() {
823
+		$url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
824
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
825
+		return $url;
826
+	}
827
+
828
+	/**
829
+	 * @param string $handle
830
+	 */
831 831
 	public static function script_version( $handle ) {
832
-        global $wp_scripts;
833
-    	if ( ! $wp_scripts ) {
834
-    	    return false;
835
-    	}
832
+		global $wp_scripts;
833
+		if ( ! $wp_scripts ) {
834
+			return false;
835
+		}
836 836
 
837
-        $ver = 0;
837
+		$ver = 0;
838 838
 
839
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
840
-            return $ver;
841
-        }
839
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
840
+			return $ver;
841
+		}
842 842
 
843
-        $query = $wp_scripts->registered[ $handle ];
844
-    	if ( is_object( $query ) ) {
845
-    	    $ver = $query->ver;
846
-    	}
843
+		$query = $wp_scripts->registered[ $handle ];
844
+		if ( is_object( $query ) ) {
845
+			$ver = $query->ver;
846
+		}
847 847
 
848
-    	return $ver;
849
-    }
848
+		return $ver;
849
+	}
850 850
 
851 851
 	public static function js_redirect( $url ) {
852 852
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
853
-    }
853
+	}
854 854
 
855 855
 	public static function get_user_id_param( $user_id ) {
856
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
857
-            return $user_id;
858
-        }
856
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
857
+			return $user_id;
858
+		}
859 859
 
860 860
 		if ( $user_id == 'current' ) {
861
-            $user_ID = get_current_user_id();
862
-            $user_id = $user_ID;
861
+			$user_ID = get_current_user_id();
862
+			$user_id = $user_ID;
863 863
 		} else {
864
-            if ( is_email($user_id) ) {
865
-                $user = get_user_by('email', $user_id);
866
-            } else {
867
-                $user = get_user_by('login', $user_id);
868
-            }
864
+			if ( is_email($user_id) ) {
865
+				$user = get_user_by('email', $user_id);
866
+			} else {
867
+				$user = get_user_by('login', $user_id);
868
+			}
869 869
 
870
-            if ( $user ) {
871
-                $user_id = $user->ID;
872
-            }
873
-            unset($user);
874
-        }
870
+			if ( $user ) {
871
+				$user_id = $user->ID;
872
+			}
873
+			unset($user);
874
+		}
875 875
 
876
-        return $user_id;
877
-    }
876
+		return $user_id;
877
+	}
878 878
 
879 879
 	public static function get_file_contents( $filename, $atts = array() ) {
880
-        if ( ! is_file($filename) ) {
881
-            return false;
882
-        }
883
-
884
-        extract($atts);
885
-        ob_start();
886
-        include($filename);
887
-        $contents = ob_get_contents();
888
-        ob_end_clean();
889
-        return $contents;
890
-    }
891
-
892
-    /**
893
-     * @param string $table_name
894
-     * @param string $column
895
-     */
896
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
897
-        global $wpdb;
898
-
899
-        $key = '';
900
-
901
-        if ( ! empty( $name ) ) {
902
-            $key = sanitize_key($name);
903
-        }
880
+		if ( ! is_file($filename) ) {
881
+			return false;
882
+		}
883
+
884
+		extract($atts);
885
+		ob_start();
886
+		include($filename);
887
+		$contents = ob_get_contents();
888
+		ob_end_clean();
889
+		return $contents;
890
+	}
891
+
892
+	/**
893
+	 * @param string $table_name
894
+	 * @param string $column
895
+	 */
896
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) {
897
+		global $wpdb;
898
+
899
+		$key = '';
900
+
901
+		if ( ! empty( $name ) ) {
902
+			$key = sanitize_key($name);
903
+		}
904 904
 
905 905
 		if ( empty( $key ) ) {
906
-            $max_slug_value = pow(36, $num_chars);
907
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
908
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
909
-        }
906
+			$max_slug_value = pow(36, $num_chars);
907
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
908
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
909
+		}
910 910
 
911 911
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
912
-            $key = $key .'a';
913
-        }
912
+			$key = $key .'a';
913
+		}
914 914
 
915 915
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
916 916
 
917
-        if ( $key_check || is_numeric($key_check) ) {
918
-            $suffix = 2;
917
+		if ( $key_check || is_numeric($key_check) ) {
918
+			$suffix = 2;
919 919
 			do {
920 920
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
921 921
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
922 922
 				$suffix++;
923 923
 			} while ($key_check || is_numeric($key_check));
924 924
 			$key = $alt_post_name;
925
-        }
926
-        return $key;
927
-    }
928
-
929
-    /**
930
-     * Editing a Form or Entry
931
-     * @param string $table
932
-     * @return bool|array
933
-     */
934
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
935
-        if ( ! $record ) {
936
-            return false;
937
-        }
938
-
939
-        global $frm_vars;
940
-
941
-        if ( empty($post_values) ) {
942
-            $post_values = stripslashes_deep($_POST);
943
-        }
925
+		}
926
+		return $key;
927
+	}
928
+
929
+	/**
930
+	 * Editing a Form or Entry
931
+	 * @param string $table
932
+	 * @return bool|array
933
+	 */
934
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
935
+		if ( ! $record ) {
936
+			return false;
937
+		}
938
+
939
+		global $frm_vars;
940
+
941
+		if ( empty($post_values) ) {
942
+			$post_values = stripslashes_deep($_POST);
943
+		}
944 944
 
945 945
 		$values = array( 'id' => $record->id, 'fields' => array() );
946 946
 
947 947
 		foreach ( array( 'name', 'description' ) as $var ) {
948
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
949
-            $values[ $var ] = self::get_param( $var, $default_val );
950
-            unset($var, $default_val);
951
-        }
952
-
953
-        $values['description'] = self::use_wpautop($values['description']);
954
-        $frm_settings = self::get_settings();
955
-        $is_form_builder = self::is_admin_page('formidable' );
956
-
957
-        foreach ( (array) $fields as $field ) {
958
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
959
-            if ( ! $is_form_builder ) {
960
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
961
-            }
948
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
949
+			$values[ $var ] = self::get_param( $var, $default_val );
950
+			unset($var, $default_val);
951
+		}
952
+
953
+		$values['description'] = self::use_wpautop($values['description']);
954
+		$frm_settings = self::get_settings();
955
+		$is_form_builder = self::is_admin_page('formidable' );
956
+
957
+		foreach ( (array) $fields as $field ) {
958
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
959
+			if ( ! $is_form_builder ) {
960
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
961
+			}
962 962
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
963 963
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
964
-        }
964
+		}
965 965
 
966
-        self::fill_form_opts($record, $table, $post_values, $values);
966
+		self::fill_form_opts($record, $table, $post_values, $values);
967 967
 
968
-        if ( $table == 'entries' ) {
969
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
970
-        } else if ( $table == 'forms' ) {
971
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
972
-        }
968
+		if ( $table == 'entries' ) {
969
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
970
+		} else if ( $table == 'forms' ) {
971
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
972
+		}
973 973
 
974
-        return $values;
975
-    }
974
+		return $values;
975
+	}
976 976
 
977 977
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
978
-        $post_values = $args['post_values'];
979
-
980
-        if ( $args['default'] ) {
981
-            $meta_value = $field->default_value;
982
-        } else {
983
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
984
-                if ( ! isset($field->field_options['custom_field']) ) {
985
-                    $field->field_options['custom_field'] = '';
986
-                }
978
+		$post_values = $args['post_values'];
979
+
980
+		if ( $args['default'] ) {
981
+			$meta_value = $field->default_value;
982
+		} else {
983
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
984
+				if ( ! isset($field->field_options['custom_field']) ) {
985
+					$field->field_options['custom_field'] = '';
986
+				}
987 987
 				$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 ) );
988
-            } else {
988
+			} else {
989 989
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
990
-            }
991
-        }
992
-
993
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
994
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
995
-
996
-        $field_array = array(
997
-            'id'            => $field->id,
998
-            'value'         => $new_value,
999
-            'default_value' => $field->default_value,
1000
-            'name'          => $field->name,
1001
-            'description'   => $field->description,
1002
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1003
-            'options'       => $field->options,
1004
-            'required'      => $field->required,
1005
-            'field_key'     => $field->field_key,
1006
-            'field_order'   => $field->field_order,
1007
-            'form_id'       => $field->form_id,
990
+			}
991
+		}
992
+
993
+		$field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
994
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
995
+
996
+		$field_array = array(
997
+			'id'            => $field->id,
998
+			'value'         => $new_value,
999
+			'default_value' => $field->default_value,
1000
+			'name'          => $field->name,
1001
+			'description'   => $field->description,
1002
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1003
+			'options'       => $field->options,
1004
+			'required'      => $field->required,
1005
+			'field_key'     => $field->field_key,
1006
+			'field_order'   => $field->field_order,
1007
+			'form_id'       => $field->form_id,
1008 1008
 			'parent_form_id' => $args['parent_form_id'],
1009
-        );
1009
+		);
1010 1010
 
1011
-        $args['field_type'] = $field_type;
1012
-        self::fill_field_opts($field, $field_array, $args);
1011
+		$args['field_type'] = $field_type;
1012
+		self::fill_field_opts($field, $field_array, $args);
1013 1013
 
1014
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1014
+		$field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1015 1015
 
1016
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1017
-            $field_array['unique_msg'] = '';
1018
-        }
1016
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1017
+			$field_array['unique_msg'] = '';
1018
+		}
1019 1019
 
1020
-        $field_array = array_merge( $field->field_options, $field_array );
1020
+		$field_array = array_merge( $field->field_options, $field_array );
1021 1021
 
1022
-        $values['fields'][ $field->id ] = $field_array;
1023
-    }
1022
+		$values['fields'][ $field->id ] = $field_array;
1023
+	}
1024 1024
 
1025 1025
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1026
-        $post_values = $args['post_values'];
1027
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1028
-
1029
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1030
-            $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 );
1031
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1032
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1033
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1034
-                if ( $args['field_type'] == 'captcha' ) {
1035
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1036
-                } else {
1037
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1038
-                }
1039
-            }
1040
-        }
1041
-
1042
-        if ( $field_array['custom_html'] == '' ) {
1043
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1044
-        }
1045
-    }
1046
-
1047
-    /**
1048
-     * @param string $table
1049
-     */
1026
+		$post_values = $args['post_values'];
1027
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1028
+
1029
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1030
+			$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 );
1031
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1032
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1033
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1034
+				if ( $args['field_type'] == 'captcha' ) {
1035
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1036
+				} else {
1037
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1038
+				}
1039
+			}
1040
+		}
1041
+
1042
+		if ( $field_array['custom_html'] == '' ) {
1043
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1044
+		}
1045
+	}
1046
+
1047
+	/**
1048
+	 * @param string $table
1049
+	 */
1050 1050
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1051
-        if ( $table == 'entries' ) {
1052
-            $form = $record->form_id;
1051
+		if ( $table == 'entries' ) {
1052
+			$form = $record->form_id;
1053 1053
 			FrmForm::maybe_get_form( $form );
1054
-        } else {
1055
-            $form = $record;
1056
-        }
1054
+		} else {
1055
+			$form = $record;
1056
+		}
1057 1057
 
1058
-        if ( ! $form ) {
1059
-            return;
1060
-        }
1058
+		if ( ! $form ) {
1059
+			return;
1060
+		}
1061 1061
 
1062
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1062
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1063 1063
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1064 1064
 
1065
-        if ( ! is_array($form->options) ) {
1066
-            return;
1067
-        }
1065
+		if ( ! is_array($form->options) ) {
1066
+			return;
1067
+		}
1068 1068
 
1069
-        foreach ( $form->options as $opt => $value ) {
1070
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1071
-        }
1069
+		foreach ( $form->options as $opt => $value ) {
1070
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1071
+		}
1072 1072
 
1073
-        self::fill_form_defaults($post_values, $values);
1074
-    }
1073
+		self::fill_form_defaults($post_values, $values);
1074
+	}
1075 1075
 
1076
-    /**
1077
-     * Set to POST value or default
1078
-     */
1076
+	/**
1077
+	 * Set to POST value or default
1078
+	 */
1079 1079
 	private static function fill_form_defaults( $post_values, array &$values ) {
1080
-        $form_defaults = FrmFormsHelper::get_default_opts();
1080
+		$form_defaults = FrmFormsHelper::get_default_opts();
1081 1081
 
1082
-        foreach ( $form_defaults as $opt => $default ) {
1083
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1082
+		foreach ( $form_defaults as $opt => $default ) {
1083
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1084 1084
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1085
-            }
1085
+			}
1086 1086
 
1087
-            unset($opt, $defaut);
1088
-        }
1087
+			unset($opt, $defaut);
1088
+		}
1089 1089
 
1090
-        if ( ! isset($values['custom_style']) ) {
1091
-            $frm_settings = self::get_settings();
1090
+		if ( ! isset($values['custom_style']) ) {
1091
+			$frm_settings = self::get_settings();
1092 1092
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1093
-        }
1093
+		}
1094 1094
 
1095 1095
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1096
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1097
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1098
-            }
1099
-            unset($h);
1100
-        }
1101
-    }
1096
+			if ( ! isset( $values[ $h .'_html' ] ) ) {
1097
+				$values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1098
+			}
1099
+			unset($h);
1100
+		}
1101
+	}
1102 1102
 
1103 1103
 	public static function get_meta_value( $field_id, $entry ) {
1104 1104
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1106,69 +1106,69 @@  discard block
 block discarded – undo
1106 1106
 	}
1107 1107
 
1108 1108
 	public static function insert_opt_html( $args ) {
1109
-        $class = '';
1110
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1111
-            $class .= 'show_frm_not_email_to';
1112
-        }
1113
-    ?>
1109
+		$class = '';
1110
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1111
+			$class .= 'show_frm_not_email_to';
1112
+		}
1113
+	?>
1114 1114
 <li>
1115 1115
     <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>
1116 1116
     <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>
1117 1117
     <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>
1118 1118
 </li>
1119 1119
     <?php
1120
-    }
1120
+	}
1121 1121
 
1122
-    public static function get_us_states() {
1123
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1124
-        return FrmFieldsHelper::get_us_states();
1125
-    }
1122
+	public static function get_us_states() {
1123
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' );
1124
+		return FrmFieldsHelper::get_us_states();
1125
+	}
1126 1126
 
1127
-    public static function get_countries() {
1128
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1129
-        return FrmFieldsHelper::get_countries();
1130
-    }
1127
+	public static function get_countries() {
1128
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' );
1129
+		return FrmFieldsHelper::get_countries();
1130
+	}
1131 1131
 
1132 1132
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1133
-        if ( is_array( $str ) ) {
1134
-            return;
1133
+		if ( is_array( $str ) ) {
1134
+			return;
1135 1135
 		}
1136 1136
 
1137
-        $length = (int) $length;
1137
+		$length = (int) $length;
1138 1138
 		$str = wp_strip_all_tags( $str );
1139 1139
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1140 1140
 
1141 1141
 		if ( $length == 0 ) {
1142
-            return '';
1143
-        } else if ( $length <= 10 ) {
1142
+			return '';
1143
+		} else if ( $length <= 10 ) {
1144 1144
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1145
-            return $sub . (($length < $original_len) ? $continue : '');
1146
-        }
1145
+			return $sub . (($length < $original_len) ? $continue : '');
1146
+		}
1147 1147
 
1148
-        $sub = '';
1149
-        $len = 0;
1148
+		$sub = '';
1149
+		$len = 0;
1150 1150
 
1151 1151
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1152 1152
 
1153 1153
 		foreach ( $words as $word ) {
1154
-            $part = (($sub != '') ? ' ' : '') . $word;
1154
+			$part = (($sub != '') ? ' ' : '') . $word;
1155 1155
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1156
-            if ( $total_len > $length && str_word_count($sub) ) {
1157
-                break;
1158
-            }
1156
+			if ( $total_len > $length && str_word_count($sub) ) {
1157
+				break;
1158
+			}
1159 1159
 
1160
-            $sub .= $part;
1160
+			$sub .= $part;
1161 1161
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1162 1162
 
1163
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1164
-                break;
1165
-            }
1163
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1164
+				break;
1165
+			}
1166 1166
 
1167
-            unset($total_len, $word);
1168
-        }
1167
+			unset($total_len, $word);
1168
+		}
1169 1169
 
1170
-        return $sub . (($len < $original_len) ? $continue : '');
1171
-    }
1170
+		return $sub . (($len < $original_len) ? $continue : '');
1171
+	}
1172 1172
 
1173 1173
 	public static function mb_function( $function_names, $args ) {
1174 1174
 		$mb_function_name = $function_names[0];
@@ -1180,18 +1180,18 @@  discard block
 block discarded – undo
1180 1180
 	}
1181 1181
 
1182 1182
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1183
-        if ( empty($date) ) {
1184
-            return $date;
1185
-        }
1183
+		if ( empty($date) ) {
1184
+			return $date;
1185
+		}
1186 1186
 
1187
-        if ( empty($date_format) ) {
1188
-            $date_format = get_option('date_format');
1189
-        }
1187
+		if ( empty($date_format) ) {
1188
+			$date_format = get_option('date_format');
1189
+		}
1190 1190
 
1191
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1192
-            $frmpro_settings = new FrmProSettings();
1193
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1194
-        }
1191
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1192
+			$frmpro_settings = new FrmProSettings();
1193
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1194
+		}
1195 1195
 
1196 1196
 		$formatted = self::get_localized_date( $date_format, $date );
1197 1197
 
@@ -1200,8 +1200,8 @@  discard block
 block discarded – undo
1200 1200
 			$formatted .= self::add_time_to_date( $time_format, $date );
1201 1201
 		}
1202 1202
 
1203
-        return $formatted;
1204
-    }
1203
+		return $formatted;
1204
+	}
1205 1205
 
1206 1206
 	private static function add_time_to_date( $time_format, $date ) {
1207 1207
 		if ( empty( $time_format ) ) {
@@ -1225,117 +1225,117 @@  discard block
 block discarded – undo
1225 1225
 		return date_i18n( $date_format, strtotime( $date ) );
1226 1226
 	}
1227 1227
 
1228
-    /**
1229
-     * @return string The time ago in words
1230
-     */
1231
-    public static function human_time_diff( $from, $to = '' ) {
1232
-    	if ( empty($to) ) {
1233
-    	    		$to = time();
1234
-    	}
1235
-
1236
-    	// Array of time period chunks
1237
-    	$chunks = array(
1238
-    		array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ),
1239
-    		array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ),
1240
-    		array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ),
1241
-    		array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ),
1242
-    		array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ),
1243
-    		array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ),
1244
-    		array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ),
1245
-    	);
1246
-
1247
-    	// Difference in seconds
1248
-    	$diff = (int) ($to - $from);
1249
-
1250
-    	// Something went wrong with date calculation and we ended up with a negative date.
1228
+	/**
1229
+	 * @return string The time ago in words
1230
+	 */
1231
+	public static function human_time_diff( $from, $to = '' ) {
1232
+		if ( empty($to) ) {
1233
+					$to = time();
1234
+		}
1235
+
1236
+		// Array of time period chunks
1237
+		$chunks = array(
1238
+			array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ),
1239
+			array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ),
1240
+			array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ),
1241
+			array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ),
1242
+			array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ),
1243
+			array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ),
1244
+			array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ),
1245
+		);
1246
+
1247
+		// Difference in seconds
1248
+		$diff = (int) ($to - $from);
1249
+
1250
+		// Something went wrong with date calculation and we ended up with a negative date.
1251 1251
 		if ( $diff < 1 ) {
1252 1252
 			return '0 ' . __( 'seconds', 'formidable' );
1253
-    	}
1253
+		}
1254 1254
 
1255
-    	/**
1256
-    	 * We only want to output one chunks of time here, eg:
1257
-    	 * x years
1258
-    	 * xx months
1259
-    	 * so there's only one bit of calculation below:
1260
-    	 */
1255
+		/**
1256
+		 * We only want to output one chunks of time here, eg:
1257
+		 * x years
1258
+		 * xx months
1259
+		 * so there's only one bit of calculation below:
1260
+		 */
1261 1261
 
1262
-        $count = 0;
1262
+		$count = 0;
1263 1263
 
1264
-    	//Step one: the first chunk
1264
+		//Step one: the first chunk
1265 1265
 		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
1266
-    		$seconds = $chunks[ $i ][0];
1267
-
1268
-    		// Finding the biggest chunk (if the chunk fits, break)
1269
-    		if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1270
-    		    			break;
1271
-    		}
1272
-    	}
1273
-
1274
-    	// Set output var
1275
-    	$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1276
-
1277
-    	if ( ! (int) trim( $output ) ) {
1278
-    		$output = '0 ' . __( 'seconds', 'formidable' );
1279
-        }
1280
-
1281
-    	return $output;
1282
-    }
1283
-
1284
-    /**
1285
-     * Added for < WP 4.0 compatability
1286
-     *
1287
-     * @since 1.07.10
1288
-     *
1289
-     * @param string $term The value to escape
1290
-     * @return string The escaped value
1291
-     */
1266
+			$seconds = $chunks[ $i ][0];
1267
+
1268
+			// Finding the biggest chunk (if the chunk fits, break)
1269
+			if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1270
+							break;
1271
+			}
1272
+		}
1273
+
1274
+		// Set output var
1275
+		$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1276
+
1277
+		if ( ! (int) trim( $output ) ) {
1278
+			$output = '0 ' . __( 'seconds', 'formidable' );
1279
+		}
1280
+
1281
+		return $output;
1282
+	}
1283
+
1284
+	/**
1285
+	 * Added for < WP 4.0 compatability
1286
+	 *
1287
+	 * @since 1.07.10
1288
+	 *
1289
+	 * @param string $term The value to escape
1290
+	 * @return string The escaped value
1291
+	 */
1292 1292
 	public static function esc_like( $term ) {
1293
-        global $wpdb;
1294
-        if ( method_exists($wpdb, 'esc_like') ) {
1293
+		global $wpdb;
1294
+		if ( method_exists($wpdb, 'esc_like') ) {
1295 1295
 			// WP 4.0
1296
-            $term = $wpdb->esc_like( $term );
1297
-        } else {
1298
-            $term = like_escape( $term );
1299
-        }
1296
+			$term = $wpdb->esc_like( $term );
1297
+		} else {
1298
+			$term = like_escape( $term );
1299
+		}
1300 1300
 
1301
-        return $term;
1302
-    }
1301
+		return $term;
1302
+	}
1303 1303
 
1304
-    /**
1305
-     * @param string $order_query
1306
-     */
1304
+	/**
1305
+	 * @param string $order_query
1306
+	 */
1307 1307
 	public static function esc_order( $order_query ) {
1308
-        if ( empty($order_query) ) {
1309
-            return '';
1310
-        }
1311
-
1312
-        // remove ORDER BY before santizing
1313
-        $order_query = strtolower($order_query);
1314
-        if ( strpos($order_query, 'order by') !== false ) {
1315
-            $order_query = str_replace('order by', '', $order_query);
1316
-        }
1317
-
1318
-        $order_query = explode(' ', trim($order_query));
1319
-
1320
-        $order_fields = array(
1321
-            'id', 'form_key', 'name', 'description',
1322
-            'parent_form_id', 'logged_in', 'is_template',
1323
-            'default_template', 'status', 'created_at',
1324
-        );
1325
-
1326
-        $order = trim(trim(reset($order_query), ','));
1327
-        if ( ! in_array($order, $order_fields) ) {
1328
-            return '';
1329
-        }
1330
-
1331
-        $order_by = '';
1332
-        if ( count($order_query) > 1 ) {
1308
+		if ( empty($order_query) ) {
1309
+			return '';
1310
+		}
1311
+
1312
+		// remove ORDER BY before santizing
1313
+		$order_query = strtolower($order_query);
1314
+		if ( strpos($order_query, 'order by') !== false ) {
1315
+			$order_query = str_replace('order by', '', $order_query);
1316
+		}
1317
+
1318
+		$order_query = explode(' ', trim($order_query));
1319
+
1320
+		$order_fields = array(
1321
+			'id', 'form_key', 'name', 'description',
1322
+			'parent_form_id', 'logged_in', 'is_template',
1323
+			'default_template', 'status', 'created_at',
1324
+		);
1325
+
1326
+		$order = trim(trim(reset($order_query), ','));
1327
+		if ( ! in_array($order, $order_fields) ) {
1328
+			return '';
1329
+		}
1330
+
1331
+		$order_by = '';
1332
+		if ( count($order_query) > 1 ) {
1333 1333
 			$order_by = end( $order_query );
1334 1334
 			self::esc_order_by( $order_by );
1335
-        }
1335
+		}
1336 1336
 
1337
-        return ' ORDER BY '. $order . ' '. $order_by;
1338
-    }
1337
+		return ' ORDER BY '. $order . ' '. $order_by;
1338
+	}
1339 1339
 
1340 1340
 	/**
1341 1341
 	 * Make sure this is ordering by either ASC or DESC
@@ -1347,183 +1347,183 @@  discard block
 block discarded – undo
1347 1347
 		}
1348 1348
 	}
1349 1349
 
1350
-    /**
1351
-     * @param string $limit
1352
-     */
1350
+	/**
1351
+	 * @param string $limit
1352
+	 */
1353 1353
 	public static function esc_limit( $limit ) {
1354
-        if ( empty($limit) ) {
1355
-            return '';
1356
-        }
1357
-
1358
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1359
-        if ( is_numeric($limit) ) {
1360
-            return ' LIMIT '. $limit;
1361
-        }
1362
-
1363
-        $limit = explode(',', trim($limit));
1364
-        foreach ( $limit as $k => $l ) {
1365
-            if ( is_numeric( $l ) ) {
1366
-                $limit[ $k ] = $l;
1367
-            }
1368
-        }
1369
-
1370
-        $limit = implode(',', $limit);
1371
-        return ' LIMIT '. $limit;
1372
-    }
1373
-
1374
-    /**
1375
-     * Get an array of values ready to go through $wpdb->prepare
1376
-     * @since 2.0
1377
-     */
1378
-    public static function prepare_array_values( $array, $type = '%s' ) {
1379
-        $placeholders = array_fill(0, count($array), $type);
1380
-        return implode(', ', $placeholders);
1381
-    }
1382
-
1383
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1384
-        if ( empty($where) ) {
1385
-            return '';
1386
-        }
1354
+		if ( empty($limit) ) {
1355
+			return '';
1356
+		}
1357
+
1358
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1359
+		if ( is_numeric($limit) ) {
1360
+			return ' LIMIT '. $limit;
1361
+		}
1362
+
1363
+		$limit = explode(',', trim($limit));
1364
+		foreach ( $limit as $k => $l ) {
1365
+			if ( is_numeric( $l ) ) {
1366
+				$limit[ $k ] = $l;
1367
+			}
1368
+		}
1369
+
1370
+		$limit = implode(',', $limit);
1371
+		return ' LIMIT '. $limit;
1372
+	}
1373
+
1374
+	/**
1375
+	 * Get an array of values ready to go through $wpdb->prepare
1376
+	 * @since 2.0
1377
+	 */
1378
+	public static function prepare_array_values( $array, $type = '%s' ) {
1379
+		$placeholders = array_fill(0, count($array), $type);
1380
+		return implode(', ', $placeholders);
1381
+	}
1382
+
1383
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1384
+		if ( empty($where) ) {
1385
+			return '';
1386
+		}
1387 1387
 
1388 1388
 		if ( is_array( $where ) ) {
1389
-            global $wpdb;
1390
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1389
+			global $wpdb;
1390
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1391 1391
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1392 1392
 		} else {
1393
-            $where = $starts_with . $where;
1394
-        }
1393
+			$where = $starts_with . $where;
1394
+		}
1395 1395
 
1396
-        return $where;
1397
-    }
1396
+		return $where;
1397
+	}
1398 1398
 
1399
-    // Pagination Methods
1399
+	// Pagination Methods
1400 1400
 
1401
-    /**
1402
-     * @param integer $current_p
1403
-     */
1401
+	/**
1402
+	 * @param integer $current_p
1403
+	 */
1404 1404
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1405 1405
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1406 1406
 	}
1407 1407
 
1408
-    /**
1409
-     * @param integer $current_p
1410
-     */
1411
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1412
-        if ( $current_p == 1 ) {
1413
-            return 1;
1414
-        } else {
1415
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1416
-        }
1417
-    }
1418
-
1419
-    /**
1420
-     * @param string $table_name
1421
-     */
1422
-    public static function &getRecordCount( $where = '', $table_name ) {
1423
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1424
-        $count = FrmDb::get_count( $table_name, $where );
1425
-        return $count;
1426
-    }
1427
-
1428
-    public static function get_referer_info() {
1429
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1430
-        return self::get_server_value('HTTP_REFERER');
1431
-    }
1408
+	/**
1409
+	 * @param integer $current_p
1410
+	 */
1411
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1412
+		if ( $current_p == 1 ) {
1413
+			return 1;
1414
+		} else {
1415
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1416
+		}
1417
+	}
1418
+
1419
+	/**
1420
+	 * @param string $table_name
1421
+	 */
1422
+	public static function &getRecordCount( $where = '', $table_name ) {
1423
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' );
1424
+		$count = FrmDb::get_count( $table_name, $where );
1425
+		return $count;
1426
+	}
1427
+
1428
+	public static function get_referer_info() {
1429
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1430
+		return self::get_server_value('HTTP_REFERER');
1431
+	}
1432 1432
 
1433 1433
 	/**
1434 1434
 	 * @return array
1435 1435
 	 */
1436 1436
 	public static function json_to_array( $json_vars ) {
1437
-        $vars = array();
1438
-        foreach ( $json_vars as $jv ) {
1439
-            $jv_name = explode('[', $jv['name']);
1440
-            $last = count($jv_name) - 1;
1441
-            foreach ( $jv_name as $p => $n ) {
1442
-                $name = trim($n, ']');
1443
-                if ( ! isset($l1) ) {
1444
-                    $l1 = $name;
1445
-                }
1446
-
1447
-                if ( ! isset($l2) ) {
1448
-                    $l2 = $name;
1449
-                }
1450
-
1451
-                if ( ! isset($l3) ) {
1452
-                    $l3 = $name;
1453
-                }
1454
-
1455
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1456
-
1457
-                switch ( $p ) {
1458
-                    case 0:
1459
-                        $l1 = $name;
1460
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1461
-                    break;
1462
-
1463
-                    case 1:
1464
-                        $l2 = $name;
1465
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1466
-                    break;
1467
-
1468
-                    case 2:
1469
-                        $l3 = $name;
1470
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1471
-                    break;
1472
-
1473
-                    case 3:
1474
-                        $l4 = $name;
1475
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1476
-                    break;
1477
-                }
1478
-
1479
-                unset($this_val, $n);
1480
-            }
1481
-
1482
-            unset($last, $jv);
1483
-        }
1484
-
1485
-        return $vars;
1486
-    }
1487
-
1488
-    /**
1489
-     * @param string $name
1490
-     * @param string $l1
1491
-     */
1492
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1493
-        if ( $name == '' ) {
1494
-            $vars[] = $val;
1495
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1496
-            $vars[ $l1 ] = $val;
1497
-        }
1498
-    }
1437
+		$vars = array();
1438
+		foreach ( $json_vars as $jv ) {
1439
+			$jv_name = explode('[', $jv['name']);
1440
+			$last = count($jv_name) - 1;
1441
+			foreach ( $jv_name as $p => $n ) {
1442
+				$name = trim($n, ']');
1443
+				if ( ! isset($l1) ) {
1444
+					$l1 = $name;
1445
+				}
1446
+
1447
+				if ( ! isset($l2) ) {
1448
+					$l2 = $name;
1449
+				}
1450
+
1451
+				if ( ! isset($l3) ) {
1452
+					$l3 = $name;
1453
+				}
1454
+
1455
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1456
+
1457
+				switch ( $p ) {
1458
+					case 0:
1459
+						$l1 = $name;
1460
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1461
+					break;
1462
+
1463
+					case 1:
1464
+						$l2 = $name;
1465
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1466
+					break;
1467
+
1468
+					case 2:
1469
+						$l3 = $name;
1470
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1471
+					break;
1472
+
1473
+					case 3:
1474
+						$l4 = $name;
1475
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1476
+					break;
1477
+				}
1478
+
1479
+				unset($this_val, $n);
1480
+			}
1481
+
1482
+			unset($last, $jv);
1483
+		}
1484
+
1485
+		return $vars;
1486
+	}
1487
+
1488
+	/**
1489
+	 * @param string $name
1490
+	 * @param string $l1
1491
+	 */
1492
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1493
+		if ( $name == '' ) {
1494
+			$vars[] = $val;
1495
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1496
+			$vars[ $l1 ] = $val;
1497
+		}
1498
+	}
1499 1499
 
1500 1500
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1501
-        $tooltips = array(
1502
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1503
-            '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' ),
1504
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1505
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1506
-            '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' ),
1507
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1508
-            '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() ) ),
1509
-        );
1510
-
1511
-        if ( ! isset( $tooltips[ $name ] ) ) {
1512
-            return;
1513
-        }
1514
-
1515
-        if ( 'open' == $class ) {
1516
-            echo ' frm_help"';
1517
-        } else {
1518
-            echo ' class="frm_help"';
1519
-        }
1520
-
1521
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1522
-
1523
-        if ( 'open' != $class ) {
1524
-            echo '"';
1525
-        }
1526
-    }
1501
+		$tooltips = array(
1502
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1503
+			'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' ),
1504
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1505
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1506
+			'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' ),
1507
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1508
+			'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() ) ),
1509
+		);
1510
+
1511
+		if ( ! isset( $tooltips[ $name ] ) ) {
1512
+			return;
1513
+		}
1514
+
1515
+		if ( 'open' == $class ) {
1516
+			echo ' frm_help"';
1517
+		} else {
1518
+			echo ' class="frm_help"';
1519
+		}
1520
+
1521
+		echo ' title="'. esc_attr( $tooltips[ $name ] );
1522
+
1523
+		if ( 'open' != $class ) {
1524
+			echo '"';
1525
+		}
1526
+	}
1527 1527
 
1528 1528
 	/**
1529 1529
 	 * Add the current_page class to that page in the form nav
@@ -1539,35 +1539,35 @@  discard block
 block discarded – undo
1539 1539
 		}
1540 1540
 	}
1541 1541
 
1542
-    /**
1543
-     * Prepare and json_encode post content
1544
-     *
1545
-     * @since 2.0
1546
-     *
1547
-     * @param array $post_content
1548
-     * @return string $post_content ( json encoded array )
1549
-     */
1550
-    public static function prepare_and_encode( $post_content ) {
1551
-        //Loop through array to strip slashes and add only the needed ones
1542
+	/**
1543
+	 * Prepare and json_encode post content
1544
+	 *
1545
+	 * @since 2.0
1546
+	 *
1547
+	 * @param array $post_content
1548
+	 * @return string $post_content ( json encoded array )
1549
+	 */
1550
+	public static function prepare_and_encode( $post_content ) {
1551
+		//Loop through array to strip slashes and add only the needed ones
1552 1552
 		foreach ( $post_content as $key => $val ) {
1553 1553
 			// Replace problematic characters (like &quot;)
1554 1554
 			$val = str_replace( '&quot;', '"', $val );
1555 1555
 
1556 1556
 			self::prepare_action_slashes( $val, $key, $post_content );
1557
-            unset( $key, $val );
1558
-        }
1557
+			unset( $key, $val );
1558
+		}
1559 1559
 
1560
-        // json_encode the array
1561
-        $post_content = json_encode( $post_content );
1560
+		// json_encode the array
1561
+		$post_content = json_encode( $post_content );
1562 1562
 
1563
-	    // add extra slashes for \r\n since WP strips them
1563
+		// add extra slashes for \r\n since WP strips them
1564 1564
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1565 1565
 
1566
-        // allow for &quot
1567
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1566
+		// allow for &quot
1567
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1568 1568
 
1569
-        return $post_content;
1570
-    }
1569
+		return $post_content;
1570
+	}
1571 1571
 
1572 1572
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1573 1573
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1635,64 +1635,64 @@  discard block
 block discarded – undo
1635 1635
 	}
1636 1636
 
1637 1637
 	public static function maybe_json_decode( $string ) {
1638
-        if ( is_array($string) ) {
1639
-            return $string;
1640
-        }
1638
+		if ( is_array($string) ) {
1639
+			return $string;
1640
+		}
1641 1641
 
1642
-        $new_string = json_decode($string, true);
1643
-        if ( function_exists('json_last_error') ) {
1642
+		$new_string = json_decode($string, true);
1643
+		if ( function_exists('json_last_error') ) {
1644 1644
 			// php 5.3+
1645
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1646
-                $string = $new_string;
1647
-            }
1648
-        } else if ( isset($new_string) ) {
1645
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1646
+				$string = $new_string;
1647
+			}
1648
+		} else if ( isset($new_string) ) {
1649 1649
 			// php < 5.3 fallback
1650
-            $string = $new_string;
1651
-        }
1652
-        return $string;
1653
-    }
1654
-
1655
-    /**
1656
-     * @since 1.07.10
1657
-     *
1658
-     * @param string $post_type The name of the post type that may need to be highlighted
1659
-     * @return echo The javascript to open and highlight the Formidable menu
1660
-     */
1650
+			$string = $new_string;
1651
+		}
1652
+		return $string;
1653
+	}
1654
+
1655
+	/**
1656
+	 * @since 1.07.10
1657
+	 *
1658
+	 * @param string $post_type The name of the post type that may need to be highlighted
1659
+	 * @return echo The javascript to open and highlight the Formidable menu
1660
+	 */
1661 1661
 	public static function maybe_highlight_menu( $post_type ) {
1662
-        global $post, $pagenow;
1662
+		global $post, $pagenow;
1663 1663
 
1664
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1665
-            return;
1666
-        }
1664
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1665
+			return;
1666
+		}
1667 1667
 
1668
-        if ( is_object($post) && $post->post_type != $post_type ) {
1669
-            return;
1670
-        }
1668
+		if ( is_object($post) && $post->post_type != $post_type ) {
1669
+			return;
1670
+		}
1671 1671
 
1672
-        self::load_admin_wide_js();
1673
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1674
-    }
1672
+		self::load_admin_wide_js();
1673
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1674
+	}
1675 1675
 
1676
-    /**
1677
-     * Load the JS file on non-Formidable pages in the admin area
1678
-     * @since 2.0
1679
-     */
1676
+	/**
1677
+	 * Load the JS file on non-Formidable pages in the admin area
1678
+	 * @since 2.0
1679
+	 */
1680 1680
 	public static function load_admin_wide_js( $load = true ) {
1681
-        $version = FrmAppHelper::plugin_version();
1681
+		$version = FrmAppHelper::plugin_version();
1682 1682
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1683 1683
 
1684
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1684
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1685 1685
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1686
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1686
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1687 1687
 			'url'          => FrmAppHelper::plugin_url(),
1688 1688
 			'loading'      => __( 'Loading&hellip;' ),
1689 1689
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1690
-        ) );
1690
+		) );
1691 1691
 
1692 1692
 		if ( $load ) {
1693 1693
 			wp_enqueue_script( 'formidable_admin_global' );
1694 1694
 		}
1695
-    }
1695
+	}
1696 1696
 
1697 1697
 	/**
1698 1698
 	 * @since 2.0.9
@@ -1701,9 +1701,9 @@  discard block
 block discarded – undo
1701 1701
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1702 1702
 	}
1703 1703
 
1704
-    /**
1705
-     * @param string $location
1706
-     */
1704
+	/**
1705
+	 * @param string $location
1706
+	 */
1707 1707
 	public static function localize_script( $location ) {
1708 1708
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1709 1709
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1753,81 +1753,81 @@  discard block
 block discarded – undo
1753 1753
 		}
1754 1754
 	}
1755 1755
 
1756
-    /**
1757
-     * @since 1.07.10
1758
-     *
1759
-     * @param float $min_version The version the add-on requires
1760
-     * @return echo The message on the plugins listing page
1761
-     */
1756
+	/**
1757
+	 * @since 1.07.10
1758
+	 *
1759
+	 * @param float $min_version The version the add-on requires
1760
+	 * @return echo The message on the plugins listing page
1761
+	 */
1762 1762
 	public static function min_version_notice( $min_version ) {
1763
-        $frm_version = self::plugin_version();
1763
+		$frm_version = self::plugin_version();
1764 1764
 
1765
-        // check if Formidable meets minimum requirements
1766
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1767
-            return;
1768
-        }
1765
+		// check if Formidable meets minimum requirements
1766
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1767
+			return;
1768
+		}
1769 1769
 
1770
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1770
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1771 1771
 		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">' .
1772
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1773
-        '</div></td></tr>';
1774
-    }
1775
-
1776
-    public static function locales( $type = 'date' ) {
1777
-        $locales = array(
1778
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1779
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1780
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1781
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1782
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1783
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1784
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1785
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1786
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1787
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1788
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1789
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1790
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1791
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1792
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1793
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1794
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1795
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1796
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1797
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1798
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1799
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1800
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1801
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1802
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1803
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1804
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1805
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1806
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1807
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1808
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1809
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1810
-        );
1811
-
1812
-        if ( $type == 'captcha' ) {
1813
-            // remove the languages unavailable for the captcha
1814
-            $unset = array(
1815
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1816
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1817
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1818
-            );
1819
-        } else {
1820
-            // remove the languages unavailable for the datepicker
1821
-            $unset = array(
1822
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1823
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1824
-                'es-419', 'tr',
1825
-            );
1826
-        }
1827
-
1828
-        $locales = array_diff_key($locales, array_flip($unset));
1829
-        $locales = apply_filters('frm_locales', $locales);
1830
-
1831
-        return $locales;
1832
-    }
1772
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1773
+		'</div></td></tr>';
1774
+	}
1775
+
1776
+	public static function locales( $type = 'date' ) {
1777
+		$locales = array(
1778
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1779
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1780
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1781
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1782
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1783
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1784
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1785
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1786
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1787
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1788
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1789
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1790
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1791
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1792
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1793
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1794
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1795
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1796
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1797
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1798
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1799
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1800
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1801
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1802
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1803
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1804
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1805
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1806
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1807
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1808
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1809
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1810
+		);
1811
+
1812
+		if ( $type == 'captcha' ) {
1813
+			// remove the languages unavailable for the captcha
1814
+			$unset = array(
1815
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1816
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1817
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1818
+			);
1819
+		} else {
1820
+			// remove the languages unavailable for the datepicker
1821
+			$unset = array(
1822
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1823
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1824
+				'es-419', 'tr',
1825
+			);
1826
+		}
1827
+
1828
+		$locales = array_diff_key($locales, array_flip($unset));
1829
+		$locales = apply_filters('frm_locales', $locales);
1830
+
1831
+		return $locales;
1832
+	}
1833 1833
 }
Please login to merge, or discard this patch.
Spacing   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
34 34
         //prevously FRM_URL constant
35
-        return plugins_url( '', self::plugin_path() .'/formidable.php' );
35
+        return plugins_url( '', self::plugin_path() . '/formidable.php' );
36 36
     }
37 37
 
38 38
 	public static function relative_plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public static function get_settings() {
69 69
         global $frm_settings;
70
-        if ( empty($frm_settings) ) {
70
+        if ( empty( $frm_settings ) ) {
71 71
             $frm_settings = new FrmSettings();
72 72
         }
73 73
         return $frm_settings;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     public static function pro_is_installed() {
86
-        return apply_filters('frm_pro_installed', false);
86
+        return apply_filters( 'frm_pro_installed', false );
87 87
     }
88 88
 
89 89
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      * @return boolean
128 128
      */
129 129
     public static function doing_ajax() {
130
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
130
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
131 131
     }
132 132
 
133 133
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      * @return boolean
148 148
      */
149 149
     public static function is_admin() {
150
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
150
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
151 151
     }
152 152
 
153 153
     /**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @return string
174 174
      */
175 175
 	public static function get_server_value( $value ) {
176
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
176
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
177 177
     }
178 178
 
179 179
     /**
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
189 189
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
190 190
         ) as $key ) {
191
-            if ( ! isset( $_SERVER[ $key ] ) ) {
191
+            if ( ! isset( $_SERVER[$key] ) ) {
192 192
                 continue;
193 193
             }
194 194
 
195
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
196
-                $ip = trim($ip); // just to be safe
195
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
196
+                $ip = trim( $ip ); // just to be safe
197 197
 
198
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
198
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
199 199
                     return $ip;
200 200
                 }
201 201
             }
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
     }
206 206
 
207 207
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
208
-        if ( strpos($param, '[') ) {
209
-            $params = explode('[', $param);
208
+        if ( strpos( $param, '[' ) ) {
209
+            $params = explode( '[', $param );
210 210
             $param = $params[0];
211 211
         }
212 212
 
213 213
 		if ( $src == 'get' ) {
214
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
215
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
216
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
214
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
215
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
216
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
217 217
             }
218 218
 			self::sanitize_value( $sanitize, $value );
219 219
 		} else {
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 
223 223
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
224 224
             foreach ( $params as $k => $p ) {
225
-                if ( ! $k || ! is_array($value) ) {
225
+                if ( ! $k || ! is_array( $value ) ) {
226 226
                     continue;
227 227
                 }
228 228
 
229
-                $p = trim($p, ']');
230
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
229
+                $p = trim( $p, ']' );
230
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
231 231
             }
232 232
         }
233 233
 
@@ -269,16 +269,16 @@  discard block
 block discarded – undo
269 269
 
270 270
 		$value = $args['default'];
271 271
 		if ( $args['type'] == 'get' ) {
272
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
273
-				$value = $_GET[ $args['param'] ];
272
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
273
+				$value = $_GET[$args['param']];
274 274
 			}
275 275
 		} else if ( $args['type'] == 'post' ) {
276
-			if ( isset( $_POST[ $args['param'] ] ) ) {
277
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
276
+			if ( isset( $_POST[$args['param']] ) ) {
277
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
278 278
 			}
279 279
 		} else {
280
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
281
-				$value = $_REQUEST[ $args['param'] ];
280
+			if ( isset( $_REQUEST[$args['param']] ) ) {
281
+				$value = $_REQUEST[$args['param']];
282 282
 			}
283 283
 		}
284 284
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
     public static function sanitize_request( $sanitize_method, &$values ) {
315 315
         $temp_values = $values;
316 316
         foreach ( $temp_values as $k => $val ) {
317
-            if ( isset( $sanitize_method[ $k ] ) ) {
318
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
317
+            if ( isset( $sanitize_method[$k] ) ) {
318
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
319 319
             }
320 320
         }
321 321
     }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	public static function sanitize_array( &$values ) {
324 324
 		$temp_values = $values;
325 325
 		foreach ( $temp_values as $k => $val ) {
326
-			$values[ $k ] = wp_kses_post( $val );
326
+			$values[$k] = wp_kses_post( $val );
327 327
 		}
328 328
 	}
329 329
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$allowed_html = array();
345 345
 		foreach ( $allowed as $a ) {
346
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
346
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
347 347
 		}
348 348
 
349 349
 		return wp_kses( $value, $allowed_html );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @since 2.0
355 355
      */
356 356
     public static function remove_get_action() {
357
-        if ( ! isset($_GET) ) {
357
+        if ( ! isset( $_GET ) ) {
358 358
             return;
359 359
         }
360 360
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
         }
377 377
 
378 378
         global $wp_query;
379
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
380
-            $value = $wp_query->query_vars[ $param ];
379
+        if ( isset( $wp_query->query_vars[$param] ) ) {
380
+            $value = $wp_query->query_vars[$param];
381 381
         }
382 382
 
383 383
         return $value;
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
      */
389 389
     public static function trigger_hook_load( $type, $object = null ) {
390 390
         // only load the form hooks once
391
-        $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object);
391
+        $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
392 392
         if ( ! $hooks_loaded ) {
393
-            do_action('frm_load_'. $type .'_hooks');
393
+            do_action( 'frm_load_' . $type . '_hooks' );
394 394
         }
395 395
     }
396 396
 
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
      * @return mixed $results The cache or query results
407 407
      */
408 408
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
409
-        $results = wp_cache_get($cache_key, $group);
410
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
409
+        $results = wp_cache_get( $cache_key, $group );
410
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
411 411
             return $results;
412 412
         }
413 413
 
414 414
         if ( 'get_posts' == $type ) {
415
-            $results = get_posts($query);
415
+            $results = get_posts( $query );
416 416
         } else {
417 417
             global $wpdb;
418
-            $results = $wpdb->{$type}($query);
418
+            $results = $wpdb->{$type}( $query );
419 419
         }
420 420
 
421 421
 		if ( ! self::prevent_caching() ) {
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
         }
440 440
 
441 441
         // then check the transient
442
-        $results = get_transient($cache_key);
442
+        $results = get_transient( $cache_key );
443 443
         if ( $results ) {
444
-            wp_cache_set($cache_key, $results);
444
+            wp_cache_set( $cache_key, $results );
445 445
         }
446 446
 
447 447
         return $results;
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
      * @param string $cache_key
453 453
      */
454 454
 	public static function delete_cache_and_transient( $cache_key ) {
455
-        delete_transient($cache_key);
456
-        wp_cache_delete($cache_key);
455
+        delete_transient( $cache_key );
456
+        wp_cache_delete( $cache_key );
457 457
     }
458 458
 
459 459
     /**
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	public static function cache_delete_group( $group ) {
468 468
     	global $wp_object_cache;
469 469
 
470
-        if ( isset( $wp_object_cache->cache[ $group ] ) ) {
471
-            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) {
472
-                wp_cache_delete($k, $group);
470
+        if ( isset( $wp_object_cache->cache[$group] ) ) {
471
+            foreach ( $wp_object_cache->cache[$group] as $k => $v ) {
472
+                wp_cache_delete( $k, $group );
473 473
             }
474 474
             return true;
475 475
         }
@@ -500,29 +500,29 @@  discard block
 block discarded – undo
500 500
 	public static function load_scripts( $scripts ) {
501 501
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' );
502 502
         foreach ( (array) $scripts as $s ) {
503
-            wp_enqueue_script($s);
503
+            wp_enqueue_script( $s );
504 504
         }
505 505
     }
506 506
 
507 507
 	public static function load_styles( $styles ) {
508 508
         _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' );
509 509
         foreach ( (array) $styles as $s ) {
510
-            wp_enqueue_style($s);
510
+            wp_enqueue_style( $s );
511 511
         }
512 512
     }
513 513
 
514 514
     public static function get_pages() {
515
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
515
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
516 516
     }
517 517
 
518 518
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
519 519
         $pages = self::get_pages();
520 520
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
521 521
     ?>
522
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
522
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
523 523
             <option value=""> </option>
524 524
             <?php foreach ( $pages as $page ) { ?>
525
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
525
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
526 526
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
527 527
 				</option>
528 528
             <?php } ?>
@@ -531,26 +531,26 @@  discard block
 block discarded – undo
531 531
     }
532 532
 
533 533
 	public static function post_edit_link( $post_id ) {
534
-        $post = get_post($post_id);
534
+        $post = get_post( $post_id );
535 535
         if ( $post ) {
536
-            return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>';
536
+            return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
537 537
         }
538 538
         return '';
539 539
     }
540 540
 
541 541
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
542 542
     ?>
543
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
543
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
544 544
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
545 545
             ?> class="frm_multiselect">
546
-            <?php self::roles_options($capability); ?>
546
+            <?php self::roles_options( $capability ); ?>
547 547
         </select>
548 548
     <?php
549 549
     }
550 550
 
551 551
 	public static function roles_options( $capability ) {
552 552
         global $frm_vars;
553
-        if ( isset($frm_vars['editable_roles']) ) {
553
+        if ( isset( $frm_vars['editable_roles'] ) ) {
554 554
             $editable_roles = $frm_vars['editable_roles'];
555 555
         } else {
556 556
             $editable_roles = get_editable_roles();
@@ -558,10 +558,10 @@  discard block
 block discarded – undo
558 558
         }
559 559
 
560 560
         foreach ( $editable_roles as $role => $details ) {
561
-            $name = translate_user_role($details['name'] ); ?>
562
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
561
+            $name = translate_user_role( $details['name'] ); ?>
562
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
563 563
 <?php
564
-            unset($role, $details);
564
+            unset( $role, $details );
565 565
         }
566 566
     }
567 567
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
     public static function maybe_add_permissions() {
618 618
 		self::force_capability( 'frm_view_entries' );
619 619
 
620
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
620
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
621 621
             return;
622 622
         }
623 623
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
         $frm_roles = self::frm_capabilities();
627 627
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
628 628
 			$user->add_cap( $frm_role );
629
-            unset($frm_role, $frm_role_description);
629
+            unset( $frm_role, $frm_role_description );
630 630
         }
631 631
     }
632 632
 
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
      * @param string $permission
652 652
      */
653 653
 	public static function permission_check( $permission, $show_message = 'show' ) {
654
-        $permission_error = self::permission_nonce_error($permission);
654
+        $permission_error = self::permission_nonce_error( $permission );
655 655
         if ( $permission_error !== false ) {
656 656
             if ( 'hide' == $show_message ) {
657 657
                 $permission_error = '';
658 658
             }
659
-            wp_die($permission_error);
659
+            wp_die( $permission_error );
660 660
         }
661 661
     }
662 662
 
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 		}
674 674
 
675 675
 		$error = false;
676
-        if ( empty($nonce_name) ) {
676
+        if ( empty( $nonce_name ) ) {
677 677
             return $error;
678 678
         }
679 679
 
680
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
680
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
681 681
             $frm_settings = self::get_settings();
682 682
             $error = $frm_settings->admin_permission;
683 683
         }
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 
694 694
 	public static function check_selected( $values, $current ) {
695 695
         $values = self::recursive_function_map( $values, 'trim' );
696
-        $current = trim($current);
696
+        $current = trim( $current );
697 697
 
698
-        return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current );
698
+        return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
699 699
     }
700 700
 
701 701
     /**
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			} else {
757 757
 				foreach ( $value as $k => $v ) {
758 758
 					if ( ! is_array( $v ) ) {
759
-						$value[ $k ] = call_user_func( $original_function, $v );
759
+						$value[$k] = call_user_func( $original_function, $v );
760 760
 					}
761 761
 				}
762 762
 			}
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 	public static function array_flatten( $array, $keys = 'keep' ) {
778 778
         $return = array();
779 779
         foreach ( $array as $key => $value ) {
780
-            if ( is_array($value) ) {
780
+            if ( is_array( $value ) ) {
781 781
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
782 782
             } else {
783 783
 				if ( $keys == 'keep' ) {
784
-					$return[ $key ] = $value;
784
+					$return[$key] = $value;
785 785
 				} else {
786 786
 					$return[] = $value;
787 787
 				}
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     }
792 792
 
793 793
     public static function esc_textarea( $text ) {
794
-        $safe_text = str_replace('&quot;', '"', $text);
794
+        $safe_text = str_replace( '&quot;', '"', $text );
795 795
         $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
796 796
     	return apply_filters( 'esc_textarea', $safe_text, $text );
797 797
     }
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
      * @since 2.0
802 802
      */
803 803
 	public static function use_wpautop( $content ) {
804
-        if ( apply_filters('frm_use_wpautop', true) ) {
805
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
804
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
805
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
806 806
         }
807 807
         return $content;
808 808
     }
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
      * @return string The base Google APIS url for the current version of jQuery UI
821 821
      */
822 822
     public static function jquery_ui_base_url() {
823
-        $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core');
824
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
823
+        $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
824
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
825 825
         return $url;
826 826
     }
827 827
 
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
 
837 837
         $ver = 0;
838 838
 
839
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
839
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
840 840
             return $ver;
841 841
         }
842 842
 
843
-        $query = $wp_scripts->registered[ $handle ];
843
+        $query = $wp_scripts->registered[$handle];
844 844
     	if ( is_object( $query ) ) {
845 845
     	    $ver = $query->ver;
846 846
     	}
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     }
854 854
 
855 855
 	public static function get_user_id_param( $user_id ) {
856
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
856
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
857 857
             return $user_id;
858 858
         }
859 859
 
@@ -861,29 +861,29 @@  discard block
 block discarded – undo
861 861
             $user_ID = get_current_user_id();
862 862
             $user_id = $user_ID;
863 863
 		} else {
864
-            if ( is_email($user_id) ) {
865
-                $user = get_user_by('email', $user_id);
864
+            if ( is_email( $user_id ) ) {
865
+                $user = get_user_by( 'email', $user_id );
866 866
             } else {
867
-                $user = get_user_by('login', $user_id);
867
+                $user = get_user_by( 'login', $user_id );
868 868
             }
869 869
 
870 870
             if ( $user ) {
871 871
                 $user_id = $user->ID;
872 872
             }
873
-            unset($user);
873
+            unset( $user );
874 874
         }
875 875
 
876 876
         return $user_id;
877 877
     }
878 878
 
879 879
 	public static function get_file_contents( $filename, $atts = array() ) {
880
-        if ( ! is_file($filename) ) {
880
+        if ( ! is_file( $filename ) ) {
881 881
             return false;
882 882
         }
883 883
 
884
-        extract($atts);
884
+        extract( $atts );
885 885
         ob_start();
886
-        include($filename);
886
+        include( $filename );
887 887
         $contents = ob_get_contents();
888 888
         ob_end_clean();
889 889
         return $contents;
@@ -899,28 +899,28 @@  discard block
 block discarded – undo
899 899
         $key = '';
900 900
 
901 901
         if ( ! empty( $name ) ) {
902
-            $key = sanitize_key($name);
902
+            $key = sanitize_key( $name );
903 903
         }
904 904
 
905 905
 		if ( empty( $key ) ) {
906
-            $max_slug_value = pow(36, $num_chars);
906
+            $max_slug_value = pow( 36, $num_chars );
907 907
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
908
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
908
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
909 909
         }
910 910
 
911
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
912
-            $key = $key .'a';
911
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
912
+            $key = $key . 'a';
913 913
         }
914 914
 
915 915
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
916 916
 
917
-        if ( $key_check || is_numeric($key_check) ) {
917
+        if ( $key_check || is_numeric( $key_check ) ) {
918 918
             $suffix = 2;
919 919
 			do {
920 920
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
921 921
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
922
-				$suffix++;
923
-			} while ($key_check || is_numeric($key_check));
922
+				$suffix ++;
923
+			} while ( $key_check || is_numeric( $key_check ) );
924 924
 			$key = $alt_post_name;
925 925
         }
926 926
         return $key;
@@ -938,32 +938,32 @@  discard block
 block discarded – undo
938 938
 
939 939
         global $frm_vars;
940 940
 
941
-        if ( empty($post_values) ) {
942
-            $post_values = stripslashes_deep($_POST);
941
+        if ( empty( $post_values ) ) {
942
+            $post_values = stripslashes_deep( $_POST );
943 943
         }
944 944
 
945 945
 		$values = array( 'id' => $record->id, 'fields' => array() );
946 946
 
947 947
 		foreach ( array( 'name', 'description' ) as $var ) {
948
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
949
-            $values[ $var ] = self::get_param( $var, $default_val );
950
-            unset($var, $default_val);
948
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
949
+            $values[$var] = self::get_param( $var, $default_val );
950
+            unset( $var, $default_val );
951 951
         }
952 952
 
953
-        $values['description'] = self::use_wpautop($values['description']);
953
+        $values['description'] = self::use_wpautop( $values['description'] );
954 954
         $frm_settings = self::get_settings();
955
-        $is_form_builder = self::is_admin_page('formidable' );
955
+        $is_form_builder = self::is_admin_page( 'formidable' );
956 956
 
957 957
         foreach ( (array) $fields as $field ) {
958 958
             // Make sure to filter default values (for placeholder text), but not on the form builder page
959 959
             if ( ! $is_form_builder ) {
960
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
960
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
961 961
             }
962 962
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
963
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
963
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
964 964
         }
965 965
 
966
-        self::fill_form_opts($record, $table, $post_values, $values);
966
+        self::fill_form_opts( $record, $table, $post_values, $values );
967 967
 
968 968
         if ( $table == 'entries' ) {
969 969
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
         if ( $args['default'] ) {
981 981
             $meta_value = $field->default_value;
982 982
         } else {
983
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
984
-                if ( ! isset($field->field_options['custom_field']) ) {
983
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
984
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
985 985
                     $field->field_options['custom_field'] = '';
986 986
                 }
987 987
 				$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 ) );
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
             }
991 991
         }
992 992
 
993
-        $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type;
994
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
993
+        $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
994
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
995 995
 
996 996
         $field_array = array(
997 997
             'id'            => $field->id,
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
             'default_value' => $field->default_value,
1000 1000
             'name'          => $field->name,
1001 1001
             'description'   => $field->description,
1002
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1002
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1003 1003
             'options'       => $field->options,
1004 1004
             'required'      => $field->required,
1005 1005
             'field_key'     => $field->field_key,
@@ -1009,38 +1009,38 @@  discard block
 block discarded – undo
1009 1009
         );
1010 1010
 
1011 1011
         $args['field_type'] = $field_type;
1012
-        self::fill_field_opts($field, $field_array, $args);
1012
+        self::fill_field_opts( $field, $field_array, $args );
1013 1013
 
1014
-        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
1014
+        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] );
1015 1015
 
1016
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1016
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1017 1017
             $field_array['unique_msg'] = '';
1018 1018
         }
1019 1019
 
1020 1020
         $field_array = array_merge( $field->field_options, $field_array );
1021 1021
 
1022
-        $values['fields'][ $field->id ] = $field_array;
1022
+        $values['fields'][$field->id] = $field_array;
1023 1023
     }
1024 1024
 
1025 1025
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1026 1026
         $post_values = $args['post_values'];
1027
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1027
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1028 1028
 
1029 1029
         foreach ( $opt_defaults as $opt => $default_opt ) {
1030
-            $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 );
1031
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1032
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1033
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1030
+            $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 );
1031
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1032
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1033
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1034 1034
                 if ( $args['field_type'] == 'captcha' ) {
1035
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1035
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1036 1036
                 } else {
1037
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1037
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1038 1038
                 }
1039 1039
             }
1040 1040
         }
1041 1041
 
1042 1042
         if ( $field_array['custom_html'] == '' ) {
1043
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1043
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1044 1044
         }
1045 1045
     }
1046 1046
 
@@ -1059,18 +1059,18 @@  discard block
 block discarded – undo
1059 1059
             return;
1060 1060
         }
1061 1061
 
1062
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1062
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1063 1063
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1064 1064
 
1065
-        if ( ! is_array($form->options) ) {
1065
+        if ( ! is_array( $form->options ) ) {
1066 1066
             return;
1067 1067
         }
1068 1068
 
1069 1069
         foreach ( $form->options as $opt => $value ) {
1070
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1070
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1071 1071
         }
1072 1072
 
1073
-        self::fill_form_defaults($post_values, $values);
1073
+        self::fill_form_defaults( $post_values, $values );
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,23 +1080,23 @@  discard block
 block discarded – undo
1080 1080
         $form_defaults = FrmFormsHelper::get_default_opts();
1081 1081
 
1082 1082
         foreach ( $form_defaults as $opt => $default ) {
1083
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1084
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1083
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1084
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1085 1085
             }
1086 1086
 
1087
-            unset($opt, $defaut);
1087
+            unset( $opt, $defaut );
1088 1088
         }
1089 1089
 
1090
-        if ( ! isset($values['custom_style']) ) {
1090
+        if ( ! isset( $values['custom_style'] ) ) {
1091 1091
             $frm_settings = self::get_settings();
1092 1092
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1093 1093
         }
1094 1094
 
1095 1095
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1096
-            if ( ! isset( $values[ $h .'_html' ] ) ) {
1097
-                $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) );
1096
+            if ( ! isset( $values[$h . '_html'] ) ) {
1097
+                $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1098 1098
             }
1099
-            unset($h);
1099
+            unset( $h );
1100 1100
         }
1101 1101
     }
1102 1102
 
@@ -1112,9 +1112,9 @@  discard block
 block discarded – undo
1112 1112
         }
1113 1113
     ?>
1114 1114
 <li>
1115
-    <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>
1116
-    <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>
1117
-    <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>
1115
+    <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>
1116
+    <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>
1117
+    <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>
1118 1118
 </li>
1119 1119
     <?php
1120 1120
     }
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
             return '';
1143 1143
         } else if ( $length <= 10 ) {
1144 1144
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1145
-            return $sub . (($length < $original_len) ? $continue : '');
1145
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1146 1146
         }
1147 1147
 
1148 1148
         $sub = '';
@@ -1151,23 +1151,23 @@  discard block
 block discarded – undo
1151 1151
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1152 1152
 
1153 1153
 		foreach ( $words as $word ) {
1154
-            $part = (($sub != '') ? ' ' : '') . $word;
1154
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1155 1155
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1156
-            if ( $total_len > $length && str_word_count($sub) ) {
1156
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1157 1157
                 break;
1158 1158
             }
1159 1159
 
1160 1160
             $sub .= $part;
1161 1161
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1162 1162
 
1163
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1163
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1164 1164
                 break;
1165 1165
             }
1166 1166
 
1167
-            unset($total_len, $word);
1167
+            unset( $total_len, $word );
1168 1168
         }
1169 1169
 
1170
-        return $sub . (($len < $original_len) ? $continue : '');
1170
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1171 1171
     }
1172 1172
 
1173 1173
 	public static function mb_function( $function_names, $args ) {
@@ -1180,17 +1180,17 @@  discard block
 block discarded – undo
1180 1180
 	}
1181 1181
 
1182 1182
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1183
-        if ( empty($date) ) {
1183
+        if ( empty( $date ) ) {
1184 1184
             return $date;
1185 1185
         }
1186 1186
 
1187
-        if ( empty($date_format) ) {
1188
-            $date_format = get_option('date_format');
1187
+        if ( empty( $date_format ) ) {
1188
+            $date_format = get_option( 'date_format' );
1189 1189
         }
1190 1190
 
1191
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1191
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1192 1192
             $frmpro_settings = new FrmProSettings();
1193
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1193
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1194 1194
         }
1195 1195
 
1196 1196
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
 	private static function add_time_to_date( $time_format, $date ) {
1207 1207
 		if ( empty( $time_format ) ) {
1208
-			$time_format = get_option('time_format');
1208
+			$time_format = get_option( 'time_format' );
1209 1209
 		}
1210 1210
 
1211 1211
 		$trimmed_format = trim( $time_format );
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
      * @return string The time ago in words
1230 1230
      */
1231 1231
     public static function human_time_diff( $from, $to = '' ) {
1232
-    	if ( empty($to) ) {
1232
+    	if ( empty( $to ) ) {
1233 1233
     	    		$to = time();
1234 1234
     	}
1235 1235
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
     	);
1246 1246
 
1247 1247
     	// Difference in seconds
1248
-    	$diff = (int) ($to - $from);
1248
+    	$diff = (int) ( $to - $from );
1249 1249
 
1250 1250
     	// Something went wrong with date calculation and we ended up with a negative date.
1251 1251
 		if ( $diff < 1 ) {
@@ -1262,17 +1262,17 @@  discard block
 block discarded – undo
1262 1262
         $count = 0;
1263 1263
 
1264 1264
     	//Step one: the first chunk
1265
-		for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
1266
-    		$seconds = $chunks[ $i ][0];
1265
+		for ( $i = 0, $j = count( $chunks ); $i < $j; $i ++ ) {
1266
+    		$seconds = $chunks[$i][0];
1267 1267
 
1268 1268
     		// Finding the biggest chunk (if the chunk fits, break)
1269
-    		if ( ( $count = floor($diff / $seconds) ) != 0 ) {
1269
+    		if ( ( $count = floor( $diff / $seconds ) ) != 0 ) {
1270 1270
     		    			break;
1271 1271
     		}
1272 1272
     	}
1273 1273
 
1274 1274
     	// Set output var
1275
-    	$output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2];
1275
+    	$output = ( 1 == $count ) ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
1276 1276
 
1277 1277
     	if ( ! (int) trim( $output ) ) {
1278 1278
     		$output = '0 ' . __( 'seconds', 'formidable' );
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      */
1292 1292
 	public static function esc_like( $term ) {
1293 1293
         global $wpdb;
1294
-        if ( method_exists($wpdb, 'esc_like') ) {
1294
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1295 1295
 			// WP 4.0
1296 1296
             $term = $wpdb->esc_like( $term );
1297 1297
         } else {
@@ -1305,17 +1305,17 @@  discard block
 block discarded – undo
1305 1305
      * @param string $order_query
1306 1306
      */
1307 1307
 	public static function esc_order( $order_query ) {
1308
-        if ( empty($order_query) ) {
1308
+        if ( empty( $order_query ) ) {
1309 1309
             return '';
1310 1310
         }
1311 1311
 
1312 1312
         // remove ORDER BY before santizing
1313
-        $order_query = strtolower($order_query);
1314
-        if ( strpos($order_query, 'order by') !== false ) {
1315
-            $order_query = str_replace('order by', '', $order_query);
1313
+        $order_query = strtolower( $order_query );
1314
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1315
+            $order_query = str_replace( 'order by', '', $order_query );
1316 1316
         }
1317 1317
 
1318
-        $order_query = explode(' ', trim($order_query));
1318
+        $order_query = explode( ' ', trim( $order_query ) );
1319 1319
 
1320 1320
         $order_fields = array(
1321 1321
             'id', 'form_key', 'name', 'description',
@@ -1323,18 +1323,18 @@  discard block
 block discarded – undo
1323 1323
             'default_template', 'status', 'created_at',
1324 1324
         );
1325 1325
 
1326
-        $order = trim(trim(reset($order_query), ','));
1327
-        if ( ! in_array($order, $order_fields) ) {
1326
+        $order = trim( trim( reset( $order_query ), ',' ) );
1327
+        if ( ! in_array( $order, $order_fields ) ) {
1328 1328
             return '';
1329 1329
         }
1330 1330
 
1331 1331
         $order_by = '';
1332
-        if ( count($order_query) > 1 ) {
1332
+        if ( count( $order_query ) > 1 ) {
1333 1333
 			$order_by = end( $order_query );
1334 1334
 			self::esc_order_by( $order_by );
1335 1335
         }
1336 1336
 
1337
-        return ' ORDER BY '. $order . ' '. $order_by;
1337
+        return ' ORDER BY ' . $order . ' ' . $order_by;
1338 1338
     }
1339 1339
 
1340 1340
 	/**
@@ -1351,24 +1351,24 @@  discard block
 block discarded – undo
1351 1351
      * @param string $limit
1352 1352
      */
1353 1353
 	public static function esc_limit( $limit ) {
1354
-        if ( empty($limit) ) {
1354
+        if ( empty( $limit ) ) {
1355 1355
             return '';
1356 1356
         }
1357 1357
 
1358
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1359
-        if ( is_numeric($limit) ) {
1360
-            return ' LIMIT '. $limit;
1358
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1359
+        if ( is_numeric( $limit ) ) {
1360
+            return ' LIMIT ' . $limit;
1361 1361
         }
1362 1362
 
1363
-        $limit = explode(',', trim($limit));
1363
+        $limit = explode( ',', trim( $limit ) );
1364 1364
         foreach ( $limit as $k => $l ) {
1365 1365
             if ( is_numeric( $l ) ) {
1366
-                $limit[ $k ] = $l;
1366
+                $limit[$k] = $l;
1367 1367
             }
1368 1368
         }
1369 1369
 
1370
-        $limit = implode(',', $limit);
1371
-        return ' LIMIT '. $limit;
1370
+        $limit = implode( ',', $limit );
1371
+        return ' LIMIT ' . $limit;
1372 1372
     }
1373 1373
 
1374 1374
     /**
@@ -1376,12 +1376,12 @@  discard block
 block discarded – undo
1376 1376
      * @since 2.0
1377 1377
      */
1378 1378
     public static function prepare_array_values( $array, $type = '%s' ) {
1379
-        $placeholders = array_fill(0, count($array), $type);
1380
-        return implode(', ', $placeholders);
1379
+        $placeholders = array_fill( 0, count( $array ), $type );
1380
+        return implode( ', ', $placeholders );
1381 1381
     }
1382 1382
 
1383 1383
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1384
-        if ( empty($where) ) {
1384
+        if ( empty( $where ) ) {
1385 1385
             return '';
1386 1386
         }
1387 1387
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 
1428 1428
     public static function get_referer_info() {
1429 1429
         _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' );
1430
-        return self::get_server_value('HTTP_REFERER');
1430
+        return self::get_server_value( 'HTTP_REFERER' );
1431 1431
     }
1432 1432
 
1433 1433
 	/**
@@ -1436,19 +1436,19 @@  discard block
 block discarded – undo
1436 1436
 	public static function json_to_array( $json_vars ) {
1437 1437
         $vars = array();
1438 1438
         foreach ( $json_vars as $jv ) {
1439
-            $jv_name = explode('[', $jv['name']);
1440
-            $last = count($jv_name) - 1;
1439
+            $jv_name = explode( '[', $jv['name'] );
1440
+            $last = count( $jv_name ) - 1;
1441 1441
             foreach ( $jv_name as $p => $n ) {
1442
-                $name = trim($n, ']');
1443
-                if ( ! isset($l1) ) {
1442
+                $name = trim( $n, ']' );
1443
+                if ( ! isset( $l1 ) ) {
1444 1444
                     $l1 = $name;
1445 1445
                 }
1446 1446
 
1447
-                if ( ! isset($l2) ) {
1447
+                if ( ! isset( $l2 ) ) {
1448 1448
                     $l2 = $name;
1449 1449
                 }
1450 1450
 
1451
-                if ( ! isset($l3) ) {
1451
+                if ( ! isset( $l3 ) ) {
1452 1452
                     $l3 = $name;
1453 1453
                 }
1454 1454
 
@@ -1462,24 +1462,24 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
                     case 1:
1464 1464
                         $l2 = $name;
1465
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1465
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1466 1466
                     break;
1467 1467
 
1468 1468
                     case 2:
1469 1469
                         $l3 = $name;
1470
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1470
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1471 1471
                     break;
1472 1472
 
1473 1473
                     case 3:
1474 1474
                         $l4 = $name;
1475
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1475
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1476 1476
                     break;
1477 1477
                 }
1478 1478
 
1479
-                unset($this_val, $n);
1479
+                unset( $this_val, $n );
1480 1480
             }
1481 1481
 
1482
-            unset($last, $jv);
1482
+            unset( $last, $jv );
1483 1483
         }
1484 1484
 
1485 1485
         return $vars;
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1493 1493
         if ( $name == '' ) {
1494 1494
             $vars[] = $val;
1495
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1496
-            $vars[ $l1 ] = $val;
1495
+        } else if ( ! isset( $vars[$l1] ) ) {
1496
+            $vars[$l1] = $val;
1497 1497
         }
1498 1498
     }
1499 1499
 
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
             '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() ) ),
1509 1509
         );
1510 1510
 
1511
-        if ( ! isset( $tooltips[ $name ] ) ) {
1511
+        if ( ! isset( $tooltips[$name] ) ) {
1512 1512
             return;
1513 1513
         }
1514 1514
 
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
             echo ' class="frm_help"';
1519 1519
         }
1520 1520
 
1521
-        echo ' title="'. esc_attr( $tooltips[ $name ] );
1521
+        echo ' title="' . esc_attr( $tooltips[$name] );
1522 1522
 
1523 1523
         if ( 'open' != $class ) {
1524 1524
             echo '"';
@@ -1570,13 +1570,13 @@  discard block
 block discarded – undo
1570 1570
     }
1571 1571
 
1572 1572
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1573
-		if ( ! isset( $post_content[ $key ] ) ) {
1573
+		if ( ! isset( $post_content[$key] ) ) {
1574 1574
 			return;
1575 1575
 		}
1576 1576
 
1577 1577
 		if ( is_array( $val ) ) {
1578 1578
 			foreach ( $val as $k1 => $v1 ) {
1579
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1579
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1580 1580
 				unset( $k1, $v1 );
1581 1581
 			}
1582 1582
 		} else {
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 			$val = stripslashes( $val );
1585 1585
 
1586 1586
 			// Add backslashes before double quotes and forward slashes only
1587
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1587
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1588 1588
 		}
1589 1589
 	}
1590 1590
 
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1602 1602
 
1603 1603
 		if ( empty( $settings['ID'] ) ) {
1604
-			unset( $settings['ID']);
1604
+			unset( $settings['ID'] );
1605 1605
 		}
1606 1606
 
1607 1607
 		// delete all caches for this group
@@ -1635,17 +1635,17 @@  discard block
 block discarded – undo
1635 1635
 	}
1636 1636
 
1637 1637
 	public static function maybe_json_decode( $string ) {
1638
-        if ( is_array($string) ) {
1638
+        if ( is_array( $string ) ) {
1639 1639
             return $string;
1640 1640
         }
1641 1641
 
1642
-        $new_string = json_decode($string, true);
1643
-        if ( function_exists('json_last_error') ) {
1642
+        $new_string = json_decode( $string, true );
1643
+        if ( function_exists( 'json_last_error' ) ) {
1644 1644
 			// php 5.3+
1645 1645
             if ( json_last_error() == JSON_ERROR_NONE ) {
1646 1646
                 $string = $new_string;
1647 1647
             }
1648
-        } else if ( isset($new_string) ) {
1648
+        } else if ( isset( $new_string ) ) {
1649 1649
 			// php < 5.3 fallback
1650 1650
             $string = $new_string;
1651 1651
         }
@@ -1661,11 +1661,11 @@  discard block
 block discarded – undo
1661 1661
 	public static function maybe_highlight_menu( $post_type ) {
1662 1662
         global $post, $pagenow;
1663 1663
 
1664
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1664
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1665 1665
             return;
1666 1666
         }
1667 1667
 
1668
-        if ( is_object($post) && $post->post_type != $post_type ) {
1668
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1669 1669
             return;
1670 1670
         }
1671 1671
 
@@ -1763,11 +1763,11 @@  discard block
 block discarded – undo
1763 1763
         $frm_version = self::plugin_version();
1764 1764
 
1765 1765
         // check if Formidable meets minimum requirements
1766
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1766
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1767 1767
             return;
1768 1768
         }
1769 1769
 
1770
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1770
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1771 1771
 		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">' .
1772 1772
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1773 1773
         '</div></td></tr>';
@@ -1775,38 +1775,38 @@  discard block
 block discarded – undo
1775 1775
 
1776 1776
     public static function locales( $type = 'date' ) {
1777 1777
         $locales = array(
1778
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1779
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1780
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1778
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1779
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1780
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1781 1781
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1782
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1783
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1782
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1783
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1784 1784
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1785
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1786
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1785
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1786
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1787 1787
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1788
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1788
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1789 1789
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1790
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1790
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1791 1791
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1792
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1792
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1793 1793
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1794
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1795
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1796
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1797
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1798
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1794
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1795
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1796
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1797
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1798
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1799 1799
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1800
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1800
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1801 1801
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1802 1802
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1803
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1803
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1804 1804
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1805
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1805
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1806 1806
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1807
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1808
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1809
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1807
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1808
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1809
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1810 1810
         );
1811 1811
 
1812 1812
         if ( $type == 'captcha' ) {
@@ -1825,8 +1825,8 @@  discard block
 block discarded – undo
1825 1825
             );
1826 1826
         }
1827 1827
 
1828
-        $locales = array_diff_key($locales, array_flip($unset));
1829
-        $locales = apply_filters('frm_locales', $locales);
1828
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1829
+        $locales = apply_filters( 'frm_locales', $locales );
1830 1830
 
1831 1831
         return $locales;
1832 1832
     }
Please login to merge, or discard this patch.
classes/models/FrmEntryMeta.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -61,6 +61,9 @@  discard block
 block discarded – undo
61 61
         return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64
+	/**
65
+	 * @param integer $entry_id
66
+	 */
64 67
 	public static function update_entry_metas( $entry_id, $values ) {
65 68
         global $wpdb;
66 69
 
@@ -286,6 +289,7 @@  discard block
 block discarded – undo
286 289
      * @param string|array $where
287 290
      * @param string $order_by
288 291
      * @param string $limit
292
+     * @param boolean $unique
289 293
      */
290 294
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
291 295
         global $wpdb;
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
24
-        );
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23
+			'created_at'    => current_time('mysql', 1),
24
+		);
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+		$new_values = apply_filters('frm_add_entry_meta', $new_values);
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+		$query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -34,89 +34,89 @@  discard block
 block discarded – undo
34 34
 			$id = 0;
35 35
 		}
36 36
 
37
-        return $id;
38
-    }
37
+		return $id;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $meta_key
42
-     */
40
+	/**
41
+	 * @param string $meta_key
42
+	 */
43 43
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
44
-        if ( ! $field_id ) {
45
-            return false;
46
-        }
44
+		if ( ! $field_id ) {
45
+			return false;
46
+		}
47 47
 
48
-        global $wpdb;
48
+		global $wpdb;
49 49
 
50
-        $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
-        $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
50
+		$values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51
+		$values['meta_value'] = $meta_value;
52
+		$values = apply_filters('frm_update_entry_meta', $values);
53 53
 		if ( is_array($values['meta_value']) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+		$meta_value = maybe_serialize($values['meta_value']);
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+		wp_cache_delete( $entry_id, 'frm_entry');
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
-    }
61
+		return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62
+	}
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65
-        global $wpdb;
65
+		global $wpdb;
66 66
 
67 67
 		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69
-        foreach ( $values as $field_id => $meta_value ) {
70
-            // set the value for the file upload field and add new tags (in Pro version)
71
-            $values = apply_filters( 'frm_prepare_data_before_db', $values, $field_id, $entry_id );
69
+		foreach ( $values as $field_id => $meta_value ) {
70
+			// set the value for the file upload field and add new tags (in Pro version)
71
+			$values = apply_filters( 'frm_prepare_data_before_db', $values, $field_id, $entry_id );
72 72
 
73
-            if ( $prev_values && in_array($field_id, $prev_values) ) {
74
-                if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
75
-                    // remove blank fields
73
+			if ( $prev_values && in_array($field_id, $prev_values) ) {
74
+				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
75
+					// remove blank fields
76 76
 					unset( $values[ $field_id ] );
77
-                } else {
78
-                    // if value exists, then update it
77
+				} else {
78
+					// if value exists, then update it
79 79
 					self::update_entry_meta( $entry_id, $field_id, '', $values[ $field_id ] );
80
-                }
81
-            } else {
82
-                // if value does not exist, then create it
80
+				}
81
+			} else {
82
+				// if value does not exist, then create it
83 83
 				self::add_entry_meta( $entry_id, $field_id, '', $values[ $field_id ] );
84
-            }
85
-        }
84
+			}
85
+		}
86 86
 
87
-        if ( empty($prev_values) ) {
88
-            return;
89
-        }
87
+		if ( empty($prev_values) ) {
88
+			return;
89
+		}
90 90
 
91
-        $prev_values = array_diff($prev_values, array_keys($values));
91
+		$prev_values = array_diff($prev_values, array_keys($values));
92 92
 
93
-        if ( empty($prev_values) ) {
94
-            return;
95
-        }
93
+		if ( empty($prev_values) ) {
94
+			return;
95
+		}
96 96
 
97 97
 		// prepare the query
98 98
 		$where = array( 'item_id' => $entry_id, 'field_id' => $prev_values );
99 99
 		FrmDb::get_where_clause_and_values( $where );
100 100
 
101
-        // Delete any leftovers
102
-        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
101
+		// Delete any leftovers
102
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
103 103
 		self::clear_cache();
104
-    }
104
+	}
105 105
 
106 106
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
107
-        $metas = self::get_entry_meta_info($old_id);
108
-        foreach ( $metas as $meta ) {
109
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
110
-            unset($meta);
111
-        }
107
+		$metas = self::get_entry_meta_info($old_id);
108
+		foreach ( $metas as $meta ) {
109
+			self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
110
+			unset($meta);
111
+		}
112 112
 		self::clear_cache();
113
-    }
113
+	}
114 114
 
115 115
 	public static function delete_entry_meta( $entry_id, $field_id ) {
116
-        global $wpdb;
116
+		global $wpdb;
117 117
 		self::clear_cache();
118
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
119
-    }
118
+		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
119
+	}
120 120
 
121 121
 	/**
122 122
 	 * Clear entry meta caching
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
144
-        global $wpdb;
144
+		global $wpdb;
145 145
 
146 146
 		if ( is_object( $entry_id ) ) {
147 147
 			$entry = $entry_id;
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
 
155 155
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
156 156
 			$result = $cached->metas[ $field_id ];
157
-            return stripslashes_deep($result);
158
-        }
157
+			return stripslashes_deep($result);
158
+		}
159 159
 
160 160
 		$get_table = $wpdb->prefix .'frm_item_metas';
161 161
 		$query = array( 'item_id' => $entry_id );
162
-        if ( is_numeric($field_id) ) {
162
+		if ( is_numeric($field_id) ) {
163 163
 			$query['field_id'] = $field_id;
164
-        } else {
164
+		} else {
165 165
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
166 166
 			$query['fi.field_key'] = $field_id;
167
-        }
167
+		}
168 168
 
169 169
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
170
-        $result = maybe_unserialize($result);
171
-        $result = stripslashes_deep($result);
170
+		$result = maybe_unserialize($result);
171
+		$result = stripslashes_deep($result);
172 172
 
173
-        return $result;
174
-    }
173
+		return $result;
174
+	}
175 175
 
176 176
 	public static function get_entry_meta( $entry_id, $field_id ) {
177 177
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' );
@@ -179,117 +179,117 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 	public static function get_entry_metas( $entry_id ) {
182
-        _deprecated_function( __FUNCTION__, '1.07.10');
182
+		_deprecated_function( __FUNCTION__, '1.07.10');
183 183
 
184
-        global $wpdb;
184
+		global $wpdb;
185 185
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
186
-    }
186
+	}
187 187
 
188
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
188
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
189 189
 		$defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false );
190
-        $args = wp_parse_args( $args, $defaults );
190
+		$args = wp_parse_args( $args, $defaults );
191 191
 
192
-        $query = array();
193
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
194
-        $query = implode(' ', $query);
192
+		$query = array();
193
+		self::meta_field_query($field_id, $order, $limit, $args, $query);
194
+		$query = implode(' ', $query);
195 195
 
196
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
197
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
196
+		$cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
197
+		$values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
198 198
 
199
-        if ( ! $args['stripslashes'] ) {
200
-            return $values;
201
-        }
199
+		if ( ! $args['stripslashes'] ) {
200
+			return $values;
201
+		}
202 202
 
203 203
 		foreach ( $values as $k => $v ) {
204 204
 			$values[ $k ] = maybe_unserialize( $v );
205
-            unset($k, $v);
206
-        }
205
+			unset($k, $v);
206
+		}
207 207
 
208
-        return stripslashes_deep($values);
209
-    }
208
+		return stripslashes_deep($values);
209
+	}
210 210
 
211
-    /**
212
-     * @param string $order
213
-     * @param string $limit
214
-     */
211
+	/**
212
+	 * @param string $order
213
+	 * @param string $limit
214
+	 */
215 215
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
216
-        global $wpdb;
217
-        $query[] = 'SELECT';
218
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
219
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
220
-
221
-        if ( ! $args['is_draft'] ) {
222
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
223
-        }
224
-
225
-        if ( is_numeric($field_id) ) {
226
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
227
-        } else {
228
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
229
-        }
230
-
231
-        if ( ! $args['is_draft'] ) {
232
-            $query[] = 'AND e.is_draft=0';
233
-        }
234
-
235
-        if ( $args['value'] ) {
236
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
237
-        }
238
-        $query[] = $order . $limit;
239
-    }
216
+		global $wpdb;
217
+		$query[] = 'SELECT';
218
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
219
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
220
+
221
+		if ( ! $args['is_draft'] ) {
222
+			$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
223
+		}
224
+
225
+		if ( is_numeric($field_id) ) {
226
+			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
227
+		} else {
228
+			$query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
229
+		}
230
+
231
+		if ( ! $args['is_draft'] ) {
232
+			$query[] = 'AND e.is_draft=0';
233
+		}
234
+
235
+		if ( $args['value'] ) {
236
+			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
237
+		}
238
+		$query[] = $order . $limit;
239
+	}
240 240
 
241 241
 	public static function get_entry_meta_info( $entry_id ) {
242 242
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
243
-    }
243
+	}
244 244
 
245 245
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
246
-        global $wpdb;
247
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
246
+		global $wpdb;
247
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
248 248
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
249 249
             FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
250
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
250
+			FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
251 251
 
252
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
253
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
252
+		$cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
253
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
254 254
 
255
-        if ( ! $results || ! $stripslashes ) {
256
-            return $results;
257
-        }
255
+		if ( ! $results || ! $stripslashes ) {
256
+			return $results;
257
+		}
258 258
 
259
-        foreach ( $results as $k => $result ) {
259
+		foreach ( $results as $k => $result ) {
260 260
 			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
261
-            unset($k, $result);
262
-        }
261
+			unset($k, $result);
262
+		}
263 263
 
264
-        return $results;
265
-    }
264
+		return $results;
265
+	}
266 266
 
267
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
267
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
268 268
 		$defaults = array(
269 269
 			'is_draft' => false,
270 270
 			'user_id'  => '',
271 271
 			'group_by' => '',
272 272
 		);
273
-        $args = wp_parse_args($args, $defaults);
273
+		$args = wp_parse_args($args, $defaults);
274 274
 
275
-        $query = array();
276
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
277
-        $query = implode(' ', $query);
275
+		$query = array();
276
+		self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
277
+		$query = implode(' ', $query);
278 278
 
279
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
280
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
279
+		$cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
280
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
281 281
 
282
-        return $results;
283
-    }
282
+		return $results;
283
+	}
284 284
 
285
-    /**
286
-     * @param string|array $where
287
-     * @param string $order_by
288
-     * @param string $limit
289
-     */
285
+	/**
286
+	 * @param string|array $where
287
+	 * @param string $order_by
288
+	 * @param string $limit
289
+	 */
290 290
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
291
-        global $wpdb;
292
-        $query[] = 'SELECT';
291
+		global $wpdb;
292
+		$query[] = 'SELECT';
293 293
 
294 294
 		$defaults = array( 'return_parent_id' => false );
295 295
 		$args = array_merge( $defaults, $args );
@@ -300,91 +300,91 @@  discard block
 block discarded – undo
300 300
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
301 301
 		}
302 302
 
303
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
303
+		$query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
304 304
 
305
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
306
-        if ( is_array($where) ) {
307
-            if ( ! $args['is_draft'] ) {
308
-                $where['e.is_draft'] = 0;
309
-            } else if ( $args['is_draft'] == 1 ) {
310
-                $where['e.is_draft'] = 1;
311
-            }
305
+		$query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
306
+		if ( is_array($where) ) {
307
+			if ( ! $args['is_draft'] ) {
308
+				$where['e.is_draft'] = 0;
309
+			} else if ( $args['is_draft'] == 1 ) {
310
+				$where['e.is_draft'] = 1;
311
+			}
312 312
 
313
-            if ( ! empty($args['user_id']) ) {
314
-                $where['e.user_id'] = $args['user_id'];
315
-            }
316
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
313
+			if ( ! empty($args['user_id']) ) {
314
+				$where['e.user_id'] = $args['user_id'];
315
+			}
316
+			$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
317 317
 
318 318
 			if ( $args['group_by'] ) {
319 319
 				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
320 320
 			}
321
-            return;
322
-        }
321
+			return;
322
+		}
323 323
 
324 324
 		$draft_where = $user_where = '';
325
-        if ( ! $args['is_draft'] ) {
325
+		if ( ! $args['is_draft'] ) {
326 326
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
327
-        } else if ( $args['is_draft'] == 1 ) {
327
+		} else if ( $args['is_draft'] == 1 ) {
328 328
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
329
-        }
330
-
331
-        if ( ! empty($args['user_id']) ) {
332
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
333
-        }
334
-
335
-        if ( strpos($where, ' GROUP BY ') ) {
336
-            // don't inject WHERE filtering after GROUP BY
337
-            $parts = explode(' GROUP BY ', $where);
338
-            $where = $parts[0];
339
-            $where .= $draft_where . $user_where;
340
-            $where .= ' GROUP BY '. $parts[1];
341
-        } else {
342
-            $where .= $draft_where . $user_where;
343
-        }
329
+		}
330
+
331
+		if ( ! empty($args['user_id']) ) {
332
+			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
333
+		}
334
+
335
+		if ( strpos($where, ' GROUP BY ') ) {
336
+			// don't inject WHERE filtering after GROUP BY
337
+			$parts = explode(' GROUP BY ', $where);
338
+			$where = $parts[0];
339
+			$where .= $draft_where . $user_where;
340
+			$where .= ' GROUP BY '. $parts[1];
341
+		} else {
342
+			$where .= $draft_where . $user_where;
343
+		}
344 344
 
345 345
 		// The query has already been prepared
346 346
 		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
347
-    }
347
+	}
348 348
 
349
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
350
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
351
-        $results = wp_cache_get($cache_key, 'frm_entry');
352
-        if ( false !== $results ) {
353
-            return $results;
354
-        }
349
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
350
+		$cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
351
+		$results = wp_cache_get($cache_key, 'frm_entry');
352
+		if ( false !== $results ) {
353
+			return $results;
354
+		}
355 355
 
356
-        global $wpdb;
356
+		global $wpdb;
357 357
 		if ( is_array( $search ) ) {
358
-            $where = '';
358
+			$where = '';
359 359
 			foreach ( $search as $field => $value ) {
360 360
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
361
-                    continue;
362
-                }
363
-
364
-                switch ( $field ) {
365
-                    case 'year':
366
-                        $value = '%'. $value;
367
-                    break;
368
-                    case 'month':
369
-                        $value .= '%';
370
-                    break;
371
-                    case 'day':
372
-                        $value = '%'. $value .'%';
373
-                }
374
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
375
-            }
376
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
377
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
378
-        } else {
361
+					continue;
362
+				}
363
+
364
+				switch ( $field ) {
365
+					case 'year':
366
+						$value = '%'. $value;
367
+					break;
368
+					case 'month':
369
+						$value .= '%';
370
+					break;
371
+					case 'day':
372
+						$value = '%'. $value .'%';
373
+				}
374
+				$where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
375
+			}
376
+			$where .= $wpdb->prepare(' field_id=%d', $field_id);
377
+			$query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
378
+		} else {
379 379
 			if ( $operator == 'LIKE' ) {
380
-                $search = '%' . $search . '%';
380
+				$search = '%' . $search . '%';
381 381
 			}
382
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
383
-        }
382
+			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
383
+		}
384 384
 
385
-        $results = $wpdb->get_col($query, 0);
386
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
385
+		$results = $wpdb->get_col($query, 0);
386
+		wp_cache_set($cache_key, $results, 'frm_entry', 300);
387 387
 
388
-        return $results;
389
-    }
388
+		return $results;
389
+	}
390 390
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21 21
             'item_id'       => $entry_id,
22 22
             'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
23
+            'created_at'    => current_time( 'mysql', 1 ),
24 24
         );
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+        $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
27 27
 
28
-        $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values );
28
+        $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
29 29
 
30 30
 		if ( $query_results ) {
31 31
 			self::clear_cache();
@@ -49,48 +49,48 @@  discard block
 block discarded – undo
49 49
 
50 50
         $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51 51
         $values['meta_value'] = $meta_value;
52
-        $values = apply_filters('frm_update_entry_meta', $values);
53
-		if ( is_array($values['meta_value']) ) {
52
+        $values = apply_filters( 'frm_update_entry_meta', $values );
53
+		if ( is_array( $values['meta_value'] ) ) {
54 54
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
55 55
 		}
56
-        $meta_value = maybe_serialize($values['meta_value']);
56
+        $meta_value = maybe_serialize( $values['meta_value'] );
57 57
 
58
-        wp_cache_delete( $entry_id, 'frm_entry');
58
+        wp_cache_delete( $entry_id, 'frm_entry' );
59 59
 		self::clear_cache();
60 60
 
61
-        return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
61
+        return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
62 62
     }
63 63
 
64 64
 	public static function update_entry_metas( $entry_id, $values ) {
65 65
         global $wpdb;
66 66
 
67
-		$prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
67
+		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
68 68
 
69 69
         foreach ( $values as $field_id => $meta_value ) {
70 70
             // set the value for the file upload field and add new tags (in Pro version)
71 71
             $values = apply_filters( 'frm_prepare_data_before_db', $values, $field_id, $entry_id );
72 72
 
73
-            if ( $prev_values && in_array($field_id, $prev_values) ) {
73
+            if ( $prev_values && in_array( $field_id, $prev_values ) ) {
74 74
                 if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
75 75
                     // remove blank fields
76
-					unset( $values[ $field_id ] );
76
+					unset( $values[$field_id] );
77 77
                 } else {
78 78
                     // if value exists, then update it
79
-					self::update_entry_meta( $entry_id, $field_id, '', $values[ $field_id ] );
79
+					self::update_entry_meta( $entry_id, $field_id, '', $values[$field_id] );
80 80
                 }
81 81
             } else {
82 82
                 // if value does not exist, then create it
83
-				self::add_entry_meta( $entry_id, $field_id, '', $values[ $field_id ] );
83
+				self::add_entry_meta( $entry_id, $field_id, '', $values[$field_id] );
84 84
             }
85 85
         }
86 86
 
87
-        if ( empty($prev_values) ) {
87
+        if ( empty( $prev_values ) ) {
88 88
             return;
89 89
         }
90 90
 
91
-        $prev_values = array_diff($prev_values, array_keys($values));
91
+        $prev_values = array_diff( $prev_values, array_keys( $values ) );
92 92
 
93
-        if ( empty($prev_values) ) {
93
+        if ( empty( $prev_values ) ) {
94 94
             return;
95 95
         }
96 96
 
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
107
-        $metas = self::get_entry_meta_info($old_id);
107
+        $metas = self::get_entry_meta_info( $old_id );
108 108
         foreach ( $metas as $meta ) {
109
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
110
-            unset($meta);
109
+            self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
110
+            unset( $meta );
111 111
         }
112 112
 		self::clear_cache();
113 113
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	public static function delete_entry_meta( $entry_id, $field_id ) {
116 116
         global $wpdb;
117 117
 		self::clear_cache();
118
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
118
+        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
119 119
     }
120 120
 
121 121
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public static function get_meta_value( $entry, $field_id ) {
136 136
 		if ( isset( $entry->metas ) ) {
137
-			return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false;
137
+			return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false;
138 138
 		} else {
139 139
 			return self::get_entry_meta_by_field( $entry->id, $field_id );
140 140
 		}
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 			$cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' );
153 153
 		}
154 154
 
155
-		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
156
-			$result = $cached->metas[ $field_id ];
157
-            return stripslashes_deep($result);
155
+		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) {
156
+			$result = $cached->metas[$field_id];
157
+            return stripslashes_deep( $result );
158 158
         }
159 159
 
160
-		$get_table = $wpdb->prefix .'frm_item_metas';
160
+		$get_table = $wpdb->prefix . 'frm_item_metas';
161 161
 		$query = array( 'item_id' => $entry_id );
162
-        if ( is_numeric($field_id) ) {
162
+        if ( is_numeric( $field_id ) ) {
163 163
 			$query['field_id'] = $field_id;
164 164
         } else {
165 165
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
         }
168 168
 
169 169
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
170
-        $result = maybe_unserialize($result);
171
-        $result = stripslashes_deep($result);
170
+        $result = maybe_unserialize( $result );
171
+        $result = stripslashes_deep( $result );
172 172
 
173 173
         return $result;
174 174
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 	public static function get_entry_metas( $entry_id ) {
182
-        _deprecated_function( __FUNCTION__, '1.07.10');
182
+        _deprecated_function( __FUNCTION__, '1.07.10' );
183 183
 
184 184
         global $wpdb;
185 185
 		return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' );
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
         $args = wp_parse_args( $args, $defaults );
191 191
 
192 192
         $query = array();
193
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
194
-        $query = implode(' ', $query);
193
+        self::meta_field_query( $field_id, $order, $limit, $args, $query );
194
+        $query = implode( ' ', $query );
195 195
 
196
-        $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args);
197
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
196
+        $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
197
+        $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
198 198
 
199 199
         if ( ! $args['stripslashes'] ) {
200 200
             return $values;
201 201
         }
202 202
 
203 203
 		foreach ( $values as $k => $v ) {
204
-			$values[ $k ] = maybe_unserialize( $v );
205
-            unset($k, $v);
204
+			$values[$k] = maybe_unserialize( $v );
205
+            unset( $k, $v );
206 206
         }
207 207
 
208
-        return stripslashes_deep($values);
208
+        return stripslashes_deep( $values );
209 209
     }
210 210
 
211 211
     /**
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
         global $wpdb;
217 217
         $query[] = 'SELECT';
218 218
         $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
219
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em ';
219
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
220 220
 
221 221
         if ( ! $args['is_draft'] ) {
222
-            $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)';
222
+            $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
223 223
         }
224 224
 
225
-        if ( is_numeric($field_id) ) {
226
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
225
+        if ( is_numeric( $field_id ) ) {
226
+            $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
227 227
         } else {
228
-            $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id);
228
+            $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
229 229
         }
230 230
 
231 231
         if ( ! $args['is_draft'] ) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         }
234 234
 
235 235
         if ( $args['value'] ) {
236
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
236
+            $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
237 237
         }
238 238
         $query[] = $order . $limit;
239 239
     }
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
         global $wpdb;
247 247
         $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
248 248
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
249
-            FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' .
250
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
249
+            FROM '. $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
250
+            FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
251 251
 
252
-        $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit;
253
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
252
+        $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
253
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
254 254
 
255 255
         if ( ! $results || ! $stripslashes ) {
256 256
             return $results;
257 257
         }
258 258
 
259 259
         foreach ( $results as $k => $result ) {
260
-			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
261
-            unset($k, $result);
260
+			$results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
261
+            unset( $k, $result );
262 262
         }
263 263
 
264 264
         return $results;
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
 			'user_id'  => '',
271 271
 			'group_by' => '',
272 272
 		);
273
-        $args = wp_parse_args($args, $defaults);
273
+        $args = wp_parse_args( $args, $defaults );
274 274
 
275 275
         $query = array();
276
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
277
-        $query = implode(' ', $query);
276
+        self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
277
+        $query = implode( ' ', $query );
278 278
 
279
-        $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args);
280
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
279
+        $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
280
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
281 281
 
282 282
         return $results;
283 283
     }
@@ -300,23 +300,23 @@  discard block
 block discarded – undo
300 300
 			$query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id';
301 301
 		}
302 302
 
303
-        $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id';
303
+        $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
304 304
 
305
-        $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)';
306
-        if ( is_array($where) ) {
305
+        $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
306
+        if ( is_array( $where ) ) {
307 307
             if ( ! $args['is_draft'] ) {
308 308
                 $where['e.is_draft'] = 0;
309 309
             } else if ( $args['is_draft'] == 1 ) {
310 310
                 $where['e.is_draft'] = 1;
311 311
             }
312 312
 
313
-            if ( ! empty($args['user_id']) ) {
313
+            if ( ! empty( $args['user_id'] ) ) {
314 314
                 $where['e.user_id'] = $args['user_id'];
315 315
             }
316
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
316
+            $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
317 317
 
318 318
 			if ( $args['group_by'] ) {
319
-				$query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] );
319
+				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
320 320
 			}
321 321
             return;
322 322
         }
@@ -328,27 +328,27 @@  discard block
 block discarded – undo
328 328
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
329 329
         }
330 330
 
331
-        if ( ! empty($args['user_id']) ) {
332
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
331
+        if ( ! empty( $args['user_id'] ) ) {
332
+            $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
333 333
         }
334 334
 
335
-        if ( strpos($where, ' GROUP BY ') ) {
335
+        if ( strpos( $where, ' GROUP BY ' ) ) {
336 336
             // don't inject WHERE filtering after GROUP BY
337
-            $parts = explode(' GROUP BY ', $where);
337
+            $parts = explode( ' GROUP BY ', $where );
338 338
             $where = $parts[0];
339 339
             $where .= $draft_where . $user_where;
340
-            $where .= ' GROUP BY '. $parts[1];
340
+            $where .= ' GROUP BY ' . $parts[1];
341 341
         } else {
342 342
             $where .= $draft_where . $user_where;
343 343
         }
344 344
 
345 345
 		// The query has already been prepared
346
-		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
346
+		$query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
347 347
     }
348 348
 
349 349
     public static function search_entry_metas( $search, $field_id = '', $operator ) {
350
-        $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator;
351
-        $results = wp_cache_get($cache_key, 'frm_entry');
350
+        $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
351
+        $results = wp_cache_get( $cache_key, 'frm_entry' );
352 352
         if ( false !== $results ) {
353 353
             return $results;
354 354
         }
@@ -363,27 +363,27 @@  discard block
 block discarded – undo
363 363
 
364 364
                 switch ( $field ) {
365 365
                     case 'year':
366
-                        $value = '%'. $value;
366
+                        $value = '%' . $value;
367 367
                     break;
368 368
                     case 'month':
369 369
                         $value .= '%';
370 370
                     break;
371 371
                     case 'day':
372
-                        $value = '%'. $value .'%';
372
+                        $value = '%' . $value . '%';
373 373
                 }
374
-                $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value);
374
+                $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
375 375
             }
376
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
377
-            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where);
376
+            $where .= $wpdb->prepare( ' field_id=%d', $field_id );
377
+            $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas" . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
378 378
         } else {
379 379
 			if ( $operator == 'LIKE' ) {
380 380
                 $search = '%' . $search . '%';
381 381
 			}
382
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
382
+            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
383 383
         }
384 384
 
385
-        $results = $wpdb->get_col($query, 0);
386
-        wp_cache_set($cache_key, $results, 'frm_entry', 300);
385
+        $results = $wpdb->get_col( $query, 0 );
386
+        wp_cache_set( $cache_key, $results, 'frm_entry', 300 );
387 387
 
388 388
         return $results;
389 389
     }
Please login to merge, or discard this patch.
classes/models/FrmStyle.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7
-	 * @param int|string $id The id of the stylsheet or 'default'
7
+	 * @param integer $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10 10
         $this->id = $id;
Please login to merge, or discard this patch.
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+	public $number = false;	// Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7 7
 	 * @param int|string $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10
-        $this->id = $id;
11
-    }
10
+		$this->id = $id;
11
+	}
12 12
 
13
-    public function get_new() {
13
+	public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
17
-        $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
-
20
-        $style = array(
21
-            'post_type'     => FrmStylesController::$post_type,
22
-            'ID'            => '',
23
-            'post_title'    => __( 'New Style', 'formidable' ),
24
-            'post_name'     => $key,
25
-            'post_content'  => $this->get_defaults(),
26
-            'menu_order'    => '',
27
-            'post_status'   => 'publish',
28
-        );
16
+		$max_slug_value = pow(36, 6);
17
+		$min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+		$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
+
20
+		$style = array(
21
+			'post_type'     => FrmStylesController::$post_type,
22
+			'ID'            => '',
23
+			'post_title'    => __( 'New Style', 'formidable' ),
24
+			'post_name'     => $key,
25
+			'post_content'  => $this->get_defaults(),
26
+			'menu_order'    => '',
27
+			'post_status'   => 'publish',
28
+		);
29 29
 
30
-        return (object) $style;
31
-    }
30
+		return (object) $style;
31
+	}
32 32
 
33 33
 	public function save( $settings ) {
34 34
 		return FrmAppHelper::save_settings( $settings, 'frm_styles' );
35
-    }
35
+	}
36 36
 
37 37
 	public function duplicate( $id ) {
38
-        // duplicating is a pro feature
39
-    }
38
+		// duplicating is a pro feature
39
+	}
40 40
 
41
-    public function update( $id = 'default' ) {
41
+	public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44 44
  		if ( empty($id) ) {
45
- 		     $new_style = (array) $this->get_new();
46
- 		     $all_instances[] = $new_style;
45
+ 			 $new_style = (array) $this->get_new();
46
+ 			 $all_instances[] = $new_style;
47 47
  		}
48 48
 
49
-        $action_ids = array();
49
+		$action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52 52
  			$new_instance = stripslashes_deep( (array) $new_instance);
@@ -54,40 +54,40 @@  discard block
 block discarded – undo
54 54
  			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55 55
 				$all_instances[ $number ] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
- 			        // this style was set to default, so remove default setting on previous default style
59
- 			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
61
- 			    }
57
+ 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
+ 					// this style was set to default, so remove default setting on previous default style
59
+ 					$new_instance['menu_order'] = 0;
60
+ 					$action_ids[] = $this->save($new_instance);
61
+ 				}
62 62
 
63
- 			    // don't continue if not saving this style
64
- 			    continue;
63
+ 				// don't continue if not saving this style
64
+ 				continue;
65 65
  			}
66 66
 
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+			$new_instance['post_status']  = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
74
-                $new_instance['post_name'] = $new_instance['post_title'];
75
-            }
73
+			if ( empty($id) ) {
74
+				$new_instance['post_name'] = $new_instance['post_title'];
75
+			}
76 76
 
77
-            $default_settings = $this->get_defaults();
77
+			$default_settings = $this->get_defaults();
78 78
 
79
-            foreach ( $default_settings as $setting => $default ) {
79
+			foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81
-                    //if is a color
81
+					//if is a color
82 82
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83 83
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84 84
 					$new_instance['post_content'][ $setting ] = 0;
85
-                }
86
-            }
85
+				}
86
+			}
87 87
 
88 88
 			$all_instances[ $number ] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+			$action_ids[] = $this->save($new_instance);
91 91
 
92 92
  		}
93 93
 
@@ -96,74 +96,74 @@  discard block
 block discarded – undo
96 96
  		return $action_ids;
97 97
  	}
98 98
 
99
-    /**
100
-     * Create static css file
101
-     */
99
+	/**
100
+	 * Create static css file
101
+	 */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+		$filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
106
-            return;
107
-        }
105
+		if ( ! is_file($filename) ) {
106
+			return;
107
+		}
108 108
 
109
-        $defaults = $this->get_defaults();
110
-        $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
113
-        $dirs_exist = true;
109
+		$defaults = $this->get_defaults();
110
+		$uploads = wp_upload_dir();
111
+		$target_path = $uploads['basedir'] .'/formidable';
112
+		$needed_dirs = array( $target_path, $target_path .'/css' );
113
+		$dirs_exist = true;
114 114
 
115
-        $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
115
+		$saving = true;
116
+		$css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
117 117
 
118
-        ob_start();
119
-        $frm_style = $this;
120
-        include($filename);
118
+		ob_start();
119
+		$frm_style = $this;
120
+		include($filename);
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122
-        ob_end_clean();
122
+		ob_end_clean();
123 123
 
124
-        $access_type = get_filesystem_method();
125
-        if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
124
+		$access_type = get_filesystem_method();
125
+		if ( $access_type === 'direct' ) {
126
+			$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
130 130
 
131 131
 		if ( ! empty( $creds ) ) {
132
-        	// initialize the API
133
-        	if ( ! WP_Filesystem( $creds ) ) {
134
-        		// any problems and we exit
135
-        		$dirs_exist = false;
132
+			// initialize the API
133
+			if ( ! WP_Filesystem( $creds ) ) {
134
+				// any problems and we exit
135
+				$dirs_exist = false;
136 136
 			}
137 137
 
138
-            if ( $dirs_exist ) {
139
-	        	global $wp_filesystem;
138
+			if ( $dirs_exist ) {
139
+				global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+				$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+				$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144
-                // Create the directories if need be:
145
-            	foreach ( $needed_dirs as $_dir ) {
146
-                    // Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
-            		if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
-            			$dirs_exist = false;
149
-                    }
150
-            	}
144
+				// Create the directories if need be:
145
+				foreach ( $needed_dirs as $_dir ) {
146
+					// Only check to see if the Dir exists upon creation failure. Less I/O this way.
147
+					if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) {
148
+						$dirs_exist = false;
149
+					}
150
+				}
151 151
 
152
-                $index_path = $target_path .'/index.php';
153
-                $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
152
+				$index_path = $target_path .'/index.php';
153
+				$wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155
-                // only write the file if the folders exist
156
-                if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
158
-                    $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
-                }
160
-            }
161
-        }
155
+				// only write the file if the folders exist
156
+				if ( $dirs_exist ) {
157
+					$css_file = $target_path .'/css/formidablepro.css';
158
+					$wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159
+				}
160
+			}
161
+		}
162 162
 
163
-        update_option('frmpro_css', $css);
163
+		update_option('frmpro_css', $css);
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+		delete_transient('frmpro_css');
166
+		set_transient('frmpro_css', $css);
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
@@ -217,264 +217,264 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
221
-    }
220
+		return wp_delete_post($id);
221
+	}
222 222
 
223
-    public function get_one() {
224
-        if ( 'default' == $this->id ) {
225
-            $style = $this->get_default_style();
226
-            if ( $style ) {
227
-                $this->id = $style->ID;
228
-            } else {
229
-                $this->id = 0;
230
-            }
231
-            return $style;
232
-        }
223
+	public function get_one() {
224
+		if ( 'default' == $this->id ) {
225
+			$style = $this->get_default_style();
226
+			if ( $style ) {
227
+				$this->id = $style->ID;
228
+			} else {
229
+				$this->id = 0;
230
+			}
231
+			return $style;
232
+		}
233 233
 
234
-        $style = get_post($this->id);
234
+		$style = get_post($this->id);
235 235
 
236
-        if ( ! $style ) {
237
-            return $style;
238
-        }
236
+		if ( ! $style ) {
237
+			return $style;
238
+		}
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
241 241
 
242
-        $default_values = $this->get_defaults();
242
+		$default_values = $this->get_defaults();
243 243
 
244
-        // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
244
+		// fill default values
245
+		$style->post_content = $this->override_defaults($style->post_content);
246
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
247 247
 
248
-        return $style;
249
-    }
248
+		return $style;
249
+	}
250 250
 
251
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
-        $post_atts = array(
251
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
252
+		$post_atts = array(
253 253
 			'post_type'   => FrmStylesController::$post_type,
254 254
 			'post_status' => 'publish',
255 255
 			'numberposts' => $limit,
256 256
 			'orderby'     => $orderby,
257 257
 			'order'       => $order,
258
-        );
259
-
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
-
262
-        if ( empty($temp_styles) ) {
263
-            global $wpdb;
264
-            // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
-
268
-            if ( empty($temp_styles) ) {
269
-                // create a new style if there are none
270
-         		$new = $this->get_new();
271
-         		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
-         		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
275
-
276
-                $post_atts['include'] = $new;
277
-
278
-                $temp_styles = get_posts( $post_atts );
279
-            }
280
-        }
281
-
282
-        $default_values = $this->get_defaults();
283
-        $default_style = false;
284
-
285
-        $styles = array();
286
-        foreach ( $temp_styles as $style ) {
287
-            $this->id = $style->ID;
288
-            if ( $style->menu_order ) {
289
-                if ( $default_style ) {
290
-                    // only return one default
291
-                    $style->menu_order = 0;
292
-                } else {
293
-                    // check for a default style
294
-                    $default_style = $style->ID;
295
-                }
296
-            }
297
-
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
-
300
-            // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
258
+		);
259
+
260
+		$temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
261
+
262
+		if ( empty($temp_styles) ) {
263
+			global $wpdb;
264
+			// make sure there wasn't a conflict with the query
265
+			$query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
+			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
267
+
268
+			if ( empty($temp_styles) ) {
269
+				// create a new style if there are none
270
+		 		$new = $this->get_new();
271
+		 		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272
+		 		$new->menu_order = 1;
273
+		 		$new = $this->save( (array) $new);
274
+		 		$this->update('default');
275
+
276
+				$post_atts['include'] = $new;
277
+
278
+				$temp_styles = get_posts( $post_atts );
279
+			}
280
+		}
281
+
282
+		$default_values = $this->get_defaults();
283
+		$default_style = false;
284
+
285
+		$styles = array();
286
+		foreach ( $temp_styles as $style ) {
287
+			$this->id = $style->ID;
288
+			if ( $style->menu_order ) {
289
+				if ( $default_style ) {
290
+					// only return one default
291
+					$style->menu_order = 0;
292
+				} else {
293
+					// check for a default style
294
+					$default_style = $style->ID;
295
+				}
296
+			}
297
+
298
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
299
+
300
+			// fill default values
301
+			$style->post_content = $this->override_defaults($style->post_content);
302
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
303 303
 
304 304
 			$styles[ $style->ID ] = $style;
305
-        }
305
+		}
306 306
 
307
-        if ( ! $default_style ) {
308
-            $default_style = reset($styles);
307
+		if ( ! $default_style ) {
308
+			$default_style = reset($styles);
309 309
 			$styles[ $default_style->ID ]->menu_order = 1;
310
-        }
310
+		}
311 311
 
312
-        return $styles;
313
-    }
312
+		return $styles;
313
+	}
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+		if ( ! isset($styles) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318
-        }
318
+		}
319 319
 
320
-        foreach ( $styles as $style ) {
321
-            if ( $style->menu_order ) {
322
-                return $style;
323
-            }
324
-        }
325
-    }
320
+		foreach ( $styles as $style ) {
321
+			if ( $style->menu_order ) {
322
+				return $style;
323
+			}
324
+		}
325
+	}
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
329
-	        return $settings;
330
-	    }
331
-
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
-
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
-	        $settings['form_desc_size'] = $settings['description_font_size'];
336
-	        $settings['form_desc_color'] = $settings['description_color'];
337
-	        $settings['title_color'] = $settings['label_color'];
338
-	    }
339
-
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
-	        $settings['section_color'] = $settings['label_color'];
342
-	        $settings['section_border_color'] = $settings['border_color'];
343
-	    }
344
-
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
-
350
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
352
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
353
-	    }
354
-
355
-	    return $settings;
328
+		if ( ! is_array($settings) ) {
329
+			return $settings;
330
+		}
331
+
332
+		$settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
333
+
334
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
335
+			$settings['form_desc_size'] = $settings['description_font_size'];
336
+			$settings['form_desc_color'] = $settings['description_color'];
337
+			$settings['title_color'] = $settings['label_color'];
338
+		}
339
+
340
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
341
+			$settings['section_color'] = $settings['label_color'];
342
+			$settings['section_border_color'] = $settings['border_color'];
343
+		}
344
+
345
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
346
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
348
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
349
+
350
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
351
+			$settings['submit_active_color'] = $settings['submit_text_color'];
352
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
353
+		}
354
+
355
+		return $settings;
356 356
 	}
357 357
 
358 358
 	public function get_defaults() {
359
-        return array(
360
-            'theme_css'         => 'ui-lightness',
361
-            'theme_name'        => 'UI Lightness',
359
+		return array(
360
+			'theme_css'         => 'ui-lightness',
361
+			'theme_name'        => 'UI Lightness',
362 362
 
363 363
 			'center_form'		=> '',
364
-            'form_width'        => '100%',
365
-            'form_align'        => 'left',
366
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
-            'fieldset'          => '0px',
368
-            'fieldset_color'    => '000000',
369
-            'fieldset_padding'  => '0 0 15px 0',
370
-            'fieldset_bg_color' => '',
371
-
372
-            'title_size'        => '20px',
373
-            'title_color'       => '444444',
374
-            'form_desc_size'    => '14px',
375
-            'form_desc_color'   => '666666',
376
-
377
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
-            'font_size'         => '14px',
379
-            'label_color'       => '444444',
380
-            'weight'            => 'bold',
381
-            'position'          => 'none',
382
-            'align'             => 'left',
383
-            'width'             => '150px',
384
-            'required_color'    => 'B94A48',
385
-            'required_weight'   => 'bold',
386
-            'label_padding'     => '0 0 3px 0',
387
-
388
-            'description_font_size' => '12px',
389
-            'description_color' => '666666',
390
-            'description_weight' => 'normal',
391
-            'description_style' => 'normal',
392
-            'description_align' => 'left',
393
-
394
-            'field_font_size'   => '14px',
395
-            'field_height' 		=> '32px',
396
-            'line_height'		=> 'normal',
397
-            'field_width'       => '100%',
398
-            'auto_width'        => false,
399
-            'field_pad'         => '6px 10px',
400
-            'field_margin'      => '20px',
401
-            'text_color'        => '555555',
402
-            //'border_color_hv'   => 'cccccc',
403
-            'border_color'      => 'cccccc',
404
-            'field_border_width' => '1px',
405
-            'field_border_style' => 'solid',
406
-
407
-            'bg_color'          => 'ffffff',
408
-            //'bg_color_hv'       => 'ffffff',
409
-            'bg_color_active'   => 'ffffff',
364
+			'form_width'        => '100%',
365
+			'form_align'        => 'left',
366
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
367
+			'fieldset'          => '0px',
368
+			'fieldset_color'    => '000000',
369
+			'fieldset_padding'  => '0 0 15px 0',
370
+			'fieldset_bg_color' => '',
371
+
372
+			'title_size'        => '20px',
373
+			'title_color'       => '444444',
374
+			'form_desc_size'    => '14px',
375
+			'form_desc_color'   => '666666',
376
+
377
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
378
+			'font_size'         => '14px',
379
+			'label_color'       => '444444',
380
+			'weight'            => 'bold',
381
+			'position'          => 'none',
382
+			'align'             => 'left',
383
+			'width'             => '150px',
384
+			'required_color'    => 'B94A48',
385
+			'required_weight'   => 'bold',
386
+			'label_padding'     => '0 0 3px 0',
387
+
388
+			'description_font_size' => '12px',
389
+			'description_color' => '666666',
390
+			'description_weight' => 'normal',
391
+			'description_style' => 'normal',
392
+			'description_align' => 'left',
393
+
394
+			'field_font_size'   => '14px',
395
+			'field_height' 		=> '32px',
396
+			'line_height'		=> 'normal',
397
+			'field_width'       => '100%',
398
+			'auto_width'        => false,
399
+			'field_pad'         => '6px 10px',
400
+			'field_margin'      => '20px',
401
+			'text_color'        => '555555',
402
+			//'border_color_hv'   => 'cccccc',
403
+			'border_color'      => 'cccccc',
404
+			'field_border_width' => '1px',
405
+			'field_border_style' => 'solid',
406
+
407
+			'bg_color'          => 'ffffff',
408
+			//'bg_color_hv'       => 'ffffff',
409
+			'bg_color_active'   => 'ffffff',
410 410
 			'border_color_active' => '66afe9',
411
-            'text_color_error'  => '444444',
412
-            'bg_color_error'    => 'ffffff',
411
+			'text_color_error'  => '444444',
412
+			'bg_color_error'    => 'ffffff',
413 413
 			'border_color_error' => 'B94A48',
414 414
 			'border_width_error' => '1px',
415 415
 			'border_style_error' => 'solid',
416
-            'bg_color_disabled' => 'ffffff',
417
-            'border_color_disabled' => 'E5E5E5',
418
-            'text_color_disabled' => 'A1A1A1',
419
-
420
-            'radio_align'       => 'block',
421
-            'check_align'       => 'block',
422
-            'check_font_size'   => '13px',
423
-            'check_label_color' => '444444',
424
-            'check_weight'      => 'normal',
425
-
426
-            'section_font_size' => '18px',
427
-            'section_color'     => '444444',
428
-            'section_weight'    => 'bold',
429
-            'section_pad'       => '15px 0 3px 0',
430
-            'section_mar_top'   => '15px',
416
+			'bg_color_disabled' => 'ffffff',
417
+			'border_color_disabled' => 'E5E5E5',
418
+			'text_color_disabled' => 'A1A1A1',
419
+
420
+			'radio_align'       => 'block',
421
+			'check_align'       => 'block',
422
+			'check_font_size'   => '13px',
423
+			'check_label_color' => '444444',
424
+			'check_weight'      => 'normal',
425
+
426
+			'section_font_size' => '18px',
427
+			'section_color'     => '444444',
428
+			'section_weight'    => 'bold',
429
+			'section_pad'       => '15px 0 3px 0',
430
+			'section_mar_top'   => '15px',
431 431
 			'section_mar_bottom' => '12px',
432
-            'section_bg_color'  => '',
433
-            'section_border_color' => 'e8e8e8',
434
-            'section_border_width' => '2px',
435
-            'section_border_style' => 'solid',
436
-            'section_border_loc' => '-top',
437
-            'collapse_icon'     => '6',
438
-            'collapse_pos'      => 'after',
439
-            'repeat_icon'       => '1',
440
-
441
-            'submit_style'      => false,
442
-            'submit_font_size'  => '14px',
443
-            'submit_width'      => 'auto',
444
-            'submit_height'     => 'auto',
445
-            'submit_bg_color'   => 'ffffff',
446
-            'submit_border_color' => 'cccccc',
447
-            'submit_border_width' => '1px',
448
-            'submit_text_color' => '444444',
449
-            'submit_weight'     => 'normal',
450
-            'submit_border_radius' => '4px',
451
-            'submit_bg_img'     => '',
452
-            'submit_margin'     => '10px',
453
-            'submit_padding'    => '6px 11px',
454
-            'submit_shadow_color' => 'eeeeee',
455
-            'submit_hover_bg_color' => 'efefef',
456
-            'submit_hover_color' => '444444',
457
-            'submit_hover_border_color' => 'cccccc',
458
-            'submit_active_bg_color' => 'efefef',
459
-            'submit_active_color' => '444444',
460
-            'submit_active_border_color' => 'cccccc',
461
-
462
-            'border_radius'     => '4px',
463
-            'error_bg'          => 'F2DEDE',
464
-            'error_border'      => 'EBCCD1',
465
-            'error_text'        => 'B94A48',
466
-            'error_font_size'   => '14px',
467
-
468
-            'success_bg_color'  => 'DFF0D8',
469
-            'success_border_color' => 'D6E9C6',
470
-            'success_text_color' => '468847',
471
-            'success_font_size' => '14px',
472
-
473
-            'important_style'   => false,
474
-
475
-            'custom_css'        => '',
476
-        );
477
-    }
432
+			'section_bg_color'  => '',
433
+			'section_border_color' => 'e8e8e8',
434
+			'section_border_width' => '2px',
435
+			'section_border_style' => 'solid',
436
+			'section_border_loc' => '-top',
437
+			'collapse_icon'     => '6',
438
+			'collapse_pos'      => 'after',
439
+			'repeat_icon'       => '1',
440
+
441
+			'submit_style'      => false,
442
+			'submit_font_size'  => '14px',
443
+			'submit_width'      => 'auto',
444
+			'submit_height'     => 'auto',
445
+			'submit_bg_color'   => 'ffffff',
446
+			'submit_border_color' => 'cccccc',
447
+			'submit_border_width' => '1px',
448
+			'submit_text_color' => '444444',
449
+			'submit_weight'     => 'normal',
450
+			'submit_border_radius' => '4px',
451
+			'submit_bg_img'     => '',
452
+			'submit_margin'     => '10px',
453
+			'submit_padding'    => '6px 11px',
454
+			'submit_shadow_color' => 'eeeeee',
455
+			'submit_hover_bg_color' => 'efefef',
456
+			'submit_hover_color' => '444444',
457
+			'submit_hover_border_color' => 'cccccc',
458
+			'submit_active_bg_color' => 'efefef',
459
+			'submit_active_color' => '444444',
460
+			'submit_active_border_color' => 'cccccc',
461
+
462
+			'border_radius'     => '4px',
463
+			'error_bg'          => 'F2DEDE',
464
+			'error_border'      => 'EBCCD1',
465
+			'error_text'        => 'B94A48',
466
+			'error_font_size'   => '14px',
467
+
468
+			'success_bg_color'  => 'DFF0D8',
469
+			'success_border_color' => 'D6E9C6',
470
+			'success_text_color' => '468847',
471
+			'success_font_size' => '14px',
472
+
473
+			'important_style'   => false,
474
+
475
+			'custom_css'        => '',
476
+		);
477
+	}
478 478
 
479 479
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
480 480
 		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStyle {
3
-    public $number = false;	// Unique ID number of the current instance.
3
+    public $number = false; // Unique ID number of the current instance.
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
     public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = pow(36, 6);
16
+        $max_slug_value = pow( 36, 6 );
17 17
         $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
18
+        $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19 19
 
20 20
         $style = array(
21 21
             'post_type'     => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44
- 		if ( empty($id) ) {
44
+ 		if ( empty( $id ) ) {
45 45
  		     $new_style = (array) $this->get_new();
46 46
  		     $all_instances[] = $new_style;
47 47
  		}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52
- 			$new_instance = stripslashes_deep( (array) $new_instance);
52
+ 			$new_instance = stripslashes_deep( (array) $new_instance );
53 53
  			$this->id = $new_instance['ID'];
54
- 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
-				$all_instances[ $number ] = $new_instance;
54
+ 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
+				$all_instances[$number] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
57
+ 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58 58
  			        // this style was set to default, so remove default setting on previous default style
59 59
  			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
60
+ 			        $action_ids[] = $this->save( $new_instance );
61 61
  			    }
62 62
 
63 63
  			    // don't continue if not saving this style
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+            $new_instance['post_status'] = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
73
+            if ( empty( $id ) ) {
74 74
                 $new_instance['post_name'] = $new_instance['post_title'];
75 75
             }
76 76
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
             foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
81 81
                     //if is a color
82
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
83
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
84
-					$new_instance['post_content'][ $setting ] = 0;
82
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
83
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
84
+					$new_instance['post_content'][$setting] = 0;
85 85
                 }
86 86
             }
87 87
 
88
-			$all_instances[ $number ] = $new_instance;
88
+			$all_instances[$number] = $new_instance;
89 89
 
90
-            $action_ids[] = $this->save($new_instance);
90
+            $action_ids[] = $this->save( $new_instance );
91 91
 
92 92
  		}
93 93
 
94
- 		$this->save_settings($all_instances);
94
+ 		$this->save_settings( $all_instances );
95 95
 
96 96
  		return $action_ids;
97 97
  	}
@@ -100,30 +100,30 @@  discard block
 block discarded – undo
100 100
      * Create static css file
101 101
      */
102 102
 	public function save_settings( $styles ) {
103
-        $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php';
103
+        $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
104 104
 
105
-        if ( ! is_file($filename) ) {
105
+        if ( ! is_file( $filename ) ) {
106 106
             return;
107 107
         }
108 108
 
109 109
         $defaults = $this->get_defaults();
110 110
         $uploads = wp_upload_dir();
111
-        $target_path = $uploads['basedir'] .'/formidable';
112
-        $needed_dirs = array( $target_path, $target_path .'/css' );
111
+        $target_path = $uploads['basedir'] . '/formidable';
112
+        $needed_dirs = array( $target_path, $target_path . '/css' );
113 113
         $dirs_exist = true;
114 114
 
115 115
         $saving = true;
116
-        $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n";
116
+        $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
117 117
 
118 118
         ob_start();
119 119
         $frm_style = $this;
120
-        include($filename);
120
+        include( $filename );
121 121
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
122 122
         ob_end_clean();
123 123
 
124 124
         $access_type = get_filesystem_method();
125 125
         if ( $access_type === 'direct' ) {
126
-        	$creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() );
126
+        	$creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() );
127 127
 		} else {
128 128
 			$creds = $this->get_ftp_creds( $access_type );
129 129
 		}
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
             if ( $dirs_exist ) {
139 139
 	        	global $wp_filesystem;
140 140
 
141
-            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
-            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
141
+            	$chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 );
142
+            	$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
143 143
 
144 144
                 // Create the directories if need be:
145 145
             	foreach ( $needed_dirs as $_dir ) {
@@ -149,33 +149,33 @@  discard block
 block discarded – undo
149 149
                     }
150 150
             	}
151 151
 
152
-                $index_path = $target_path .'/index.php';
152
+                $index_path = $target_path . '/index.php';
153 153
                 $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file );
154 154
 
155 155
                 // only write the file if the folders exist
156 156
                 if ( $dirs_exist ) {
157
-                    $css_file = $target_path .'/css/formidablepro.css';
157
+                    $css_file = $target_path . '/css/formidablepro.css';
158 158
                     $wp_filesystem->put_contents( $css_file, $css, $chmod_file );
159 159
                 }
160 160
             }
161 161
         }
162 162
 
163
-        update_option('frmpro_css', $css);
163
+        update_option( 'frmpro_css', $css );
164 164
 
165
-        delete_transient('frmpro_css');
166
-        set_transient('frmpro_css', $css);
165
+        delete_transient( 'frmpro_css' );
166
+        set_transient( 'frmpro_css', $css );
167 167
 	}
168 168
 
169 169
 	private function get_ftp_creds( $type ) {
170 170
 		$credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) );
171 171
 
172
-		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname'];
173
-		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username'];
174
-		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : '';
172
+		$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname'];
173
+		$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username'];
174
+		$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : '';
175 175
 
176 176
 		// Check to see if we are setting the public/private keys for ssh
177
-		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : '';
178
-		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : '';
177
+		$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : '';
178
+		$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : '';
179 179
 
180 180
 		// Sanitize the hostname, Some people might pass in odd-data:
181 181
 		$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	}
218 218
 
219 219
 	public function destroy( $id ) {
220
-        return wp_delete_post($id);
220
+        return wp_delete_post( $id );
221 221
     }
222 222
 
223 223
     public function get_one() {
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
             return $style;
232 232
         }
233 233
 
234
-        $style = get_post($this->id);
234
+        $style = get_post( $this->id );
235 235
 
236 236
         if ( ! $style ) {
237 237
             return $style;
238 238
         }
239 239
 
240
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
240
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
241 241
 
242 242
         $default_values = $this->get_defaults();
243 243
 
244 244
         // fill default values
245
-        $style->post_content = $this->override_defaults($style->post_content);
246
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
245
+        $style->post_content = $this->override_defaults( $style->post_content );
246
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
247 247
 
248 248
         return $style;
249 249
     }
@@ -257,21 +257,21 @@  discard block
 block discarded – undo
257 257
 			'order'       => $order,
258 258
         );
259 259
 
260
-        $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
260
+        $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
261 261
 
262
-        if ( empty($temp_styles) ) {
262
+        if ( empty( $temp_styles ) ) {
263 263
             global $wpdb;
264 264
             // make sure there wasn't a conflict with the query
265
-            $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
266
-            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
265
+            $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
266
+            $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
267 267
 
268
-            if ( empty($temp_styles) ) {
268
+            if ( empty( $temp_styles ) ) {
269 269
                 // create a new style if there are none
270 270
          		$new = $this->get_new();
271 271
          		$new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' );
272 272
          		$new->menu_order = 1;
273
-         		$new = $this->save( (array) $new);
274
-         		$this->update('default');
273
+         		$new = $this->save( (array) $new );
274
+         		$this->update( 'default' );
275 275
 
276 276
                 $post_atts['include'] = $new;
277 277
 
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
                 }
296 296
             }
297 297
 
298
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
298
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
299 299
 
300 300
             // fill default values
301
-            $style->post_content = $this->override_defaults($style->post_content);
302
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
301
+            $style->post_content = $this->override_defaults( $style->post_content );
302
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
303 303
 
304
-			$styles[ $style->ID ] = $style;
304
+			$styles[$style->ID] = $style;
305 305
         }
306 306
 
307 307
         if ( ! $default_style ) {
308
-            $default_style = reset($styles);
309
-			$styles[ $default_style->ID ]->menu_order = 1;
308
+            $default_style = reset( $styles );
309
+			$styles[$default_style->ID]->menu_order = 1;
310 310
         }
311 311
 
312 312
         return $styles;
313 313
     }
314 314
 
315 315
 	public function get_default_style( $styles = null ) {
316
-        if ( ! isset($styles) ) {
316
+        if ( ! isset( $styles ) ) {
317 317
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
318 318
         }
319 319
 
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
     }
326 326
 
327 327
 	public function override_defaults( $settings ) {
328
-	    if ( ! is_array($settings) ) {
328
+	    if ( ! is_array( $settings ) ) {
329 329
 	        return $settings;
330 330
 	    }
331 331
 
332
-	    $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height'];
332
+	    $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
333 333
 
334
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
334
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
335 335
 	        $settings['form_desc_size'] = $settings['description_font_size'];
336 336
 	        $settings['form_desc_color'] = $settings['description_color'];
337 337
 	        $settings['title_color'] = $settings['label_color'];
338 338
 	    }
339 339
 
340
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
340
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
341 341
 	        $settings['section_color'] = $settings['label_color'];
342 342
 	        $settings['section_border_color'] = $settings['border_color'];
343 343
 	    }
344 344
 
345
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
345
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
346 346
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
347 347
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
348 348
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     }
478 478
 
479 479
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
480
-		return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']';
480
+		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
481 481
 	}
482 482
 
483 483
 	public static function get_bold_options() {
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +362 added lines, -362 removed lines patch added patch discarded remove patch
@@ -2,199 +2,199 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11
-            $frm_settings = FrmAppHelper::get_settings();
11
+			$frm_settings = FrmAppHelper::get_settings();
12 12
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( $screen_id != 'formidable_page_formidable-entries' || ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 		unset( $action, $page );
50 50
 
51
-        $screen->add_help_tab( array(
52
-            'id'      => 'formidable-entries-tab',
53
-            'title'   => __( 'Overview', 'formidable' ),
51
+		$screen->add_help_tab( array(
52
+			'id'      => 'formidable-entries-tab',
53
+			'title'   => __( 'Overview', 'formidable' ),
54 54
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
-        ));
55
+		));
56 56
 
57
-        $screen->set_help_sidebar(
57
+		$screen->set_help_sidebar(
58 58
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
59 59
 			'<p><a href="http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
60 60
 			'<p><a href="http://formidablepro.com/help-topics/" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
61
-    	);
61
+		);
62 62
 
63
-        return $help;
64
-    }
63
+		return $help;
64
+	}
65 65
 
66 66
 	public static function manage_columns( $columns ) {
67
-        global $frm_vars, $wpdb;
67
+		global $frm_vars, $wpdb;
68 68
 		$form_id = FrmForm::get_current_form_id();
69 69
 
70
-        $columns[ $form_id .'_id' ] = 'ID';
70
+		$columns[ $form_id .'_id' ] = 'ID';
71 71
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
72 72
 
73
-        if ( ! $form_id ) {
74
-            return $columns;
75
-        }
73
+		if ( ! $form_id ) {
74
+			return $columns;
75
+		}
76 76
 
77
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
77
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78 78
 
79
-        foreach ( $form_cols as $form_col ) {
79
+		foreach ( $form_cols as $form_col ) {
80 80
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
81
-                continue;
82
-            }
81
+				continue;
82
+			}
83 83
 
84
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
84
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85 85
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
86 86
 
87
-                if ( $sub_form_cols ) {
88
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
87
+				if ( $sub_form_cols ) {
88
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
89 89
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
90
-                            unset( $sub_form_cols[ $k ] );
91
-                            continue;
92
-                        }
90
+							unset( $sub_form_cols[ $k ] );
91
+							continue;
92
+						}
93 93
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
-                        unset($sub_form_col);
95
-                    }
96
-                }
97
-                unset($sub_form_cols);
98
-            } else {
99
-                $col_id = $form_col->field_key;
100
-                if ( $form_col->form_id != $form_id ) {
101
-                    $col_id .= '-_-form'. $form_col->form_id;
102
-                }
103
-
104
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
106
-                }
107
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
-            }
109
-        }
110
-
111
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
-        $columns[ $form_id .'_ip' ] = 'IP';
114
-
115
-        $frm_vars['cols'] = $columns;
94
+						unset($sub_form_col);
95
+					}
96
+				}
97
+				unset($sub_form_cols);
98
+			} else {
99
+				$col_id = $form_col->field_key;
100
+				if ( $form_col->form_id != $form_id ) {
101
+					$col_id .= '-_-form'. $form_col->form_id;
102
+				}
103
+
104
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
+					$columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
106
+				}
107
+				$columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+			}
109
+		}
110
+
111
+		$columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
+		$columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
+		$columns[ $form_id .'_ip' ] = 'IP';
114
+
115
+		$frm_vars['cols'] = $columns;
116 116
 
117 117
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
118 118
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
119 119
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
120
-        }
120
+		}
121 121
 
122
-        return $columns;
123
-    }
122
+		return $columns;
123
+	}
124 124
 
125 125
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
126
-        $frm_settings = FrmAppHelper::get_settings();
127
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128
-            return $check;
129
-        }
126
+		$frm_settings = FrmAppHelper::get_settings();
127
+		if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128
+			return $check;
129
+		}
130 130
 
131 131
 		if ( empty( $prev_value ) ) {
132
-            		$prev_value = get_metadata('user', $object_id, $meta_key, true);
133
-        }
132
+					$prev_value = get_metadata('user', $object_id, $meta_key, true);
133
+		}
134 134
 
135
-        global $frm_vars;
136
-        //add a check so we don't create a loop
137
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
135
+		global $frm_vars;
136
+		//add a check so we don't create a loop
137
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
138 138
 
139
-        return $check;
140
-    }
139
+		return $check;
140
+	}
141 141
 
142
-    //add hidden columns back from other forms
142
+	//add hidden columns back from other forms
143 143
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
144
-        $frm_settings = FrmAppHelper::get_settings();
145
-
146
-        $sanitized = sanitize_title($frm_settings->menu);
147
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
148
-            return;
149
-        }
150
-
151
-        global $frm_vars;
152
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
-            return; //don't continue if there's no previous value
154
-        }
155
-
156
-        foreach ( $meta_value as $mk => $mv ) {
157
-            //remove blank values
158
-            if ( empty( $mv )  ) {
159
-                unset( $meta_value[ $mk ] );
160
-            }
161
-        }
162
-
163
-        $cur_form_prefix = reset($meta_value);
164
-        $cur_form_prefix = explode('_', $cur_form_prefix);
165
-        $cur_form_prefix = $cur_form_prefix[0];
166
-        $save = false;
167
-
168
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
144
+		$frm_settings = FrmAppHelper::get_settings();
145
+
146
+		$sanitized = sanitize_title($frm_settings->menu);
147
+		if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
148
+			return;
149
+		}
150
+
151
+		global $frm_vars;
152
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
+			return; //don't continue if there's no previous value
154
+		}
155
+
156
+		foreach ( $meta_value as $mk => $mv ) {
157
+			//remove blank values
158
+			if ( empty( $mv )  ) {
159
+				unset( $meta_value[ $mk ] );
160
+			}
161
+		}
162
+
163
+		$cur_form_prefix = reset($meta_value);
164
+		$cur_form_prefix = explode('_', $cur_form_prefix);
165
+		$cur_form_prefix = $cur_form_prefix[0];
166
+		$save = false;
167
+
168
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
169 169
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
170
-                //don't add blank cols or process included cols
171
-                continue;
172
-            }
170
+				//don't add blank cols or process included cols
171
+				continue;
172
+			}
173 173
 
174 174
 			$form_prefix = explode( '_', $prev_hidden );
175
-            $form_prefix = $form_prefix[0];
176
-            if ( $form_prefix == $cur_form_prefix ) {
177
-                //don't add back columns that are meant to be hidden
178
-                continue;
179
-            }
175
+			$form_prefix = $form_prefix[0];
176
+			if ( $form_prefix == $cur_form_prefix ) {
177
+				//don't add back columns that are meant to be hidden
178
+				continue;
179
+			}
180 180
 
181
-            $meta_value[] = $prev_hidden;
182
-            $save = true;
183
-            unset($form_prefix);
184
-        }
181
+			$meta_value[] = $prev_hidden;
182
+			$save = true;
183
+			unset($form_prefix);
184
+		}
185 185
 
186 186
 		if ( $save ) {
187
-            $user = wp_get_current_user();
188
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
-        }
190
-    }
187
+			$user = wp_get_current_user();
188
+			update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
+		}
190
+	}
191 191
 
192 192
 	public static function save_per_page( $save, $option, $value ) {
193
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
-            $save = (int) $value;
195
-        }
196
-        return $save;
197
-    }
193
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
194
+			$save = (int) $value;
195
+		}
196
+		return $save;
197
+	}
198 198
 
199 199
 	public static function sortable_columns() {
200 200
 		$form_id = FrmForm::get_current_form_id();
@@ -220,226 +220,226 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	public static function hidden_columns( $result ) {
223
-        global $frm_vars;
223
+		global $frm_vars;
224 224
 
225 225
 		$form_id = FrmForm::get_current_form_id();
226 226
 
227
-        $return = false;
228
-        foreach ( (array) $result as $r ) {
229
-            if ( ! empty( $r ) ) {
230
-                $form_prefix = explode( '_', $r );
231
-                $form_prefix = $form_prefix[0];
227
+		$return = false;
228
+		foreach ( (array) $result as $r ) {
229
+			if ( ! empty( $r ) ) {
230
+				$form_prefix = explode( '_', $r );
231
+				$form_prefix = $form_prefix[0];
232 232
 
233
-                if ( (int) $form_prefix == (int) $form_id ) {
234
-                    $return = true;
235
-                    break;
236
-                }
233
+				if ( (int) $form_prefix == (int) $form_id ) {
234
+					$return = true;
235
+					break;
236
+				}
237 237
 
238
-                unset($form_prefix);
239
-            }
240
-        }
238
+				unset($form_prefix);
239
+			}
240
+		}
241 241
 
242
-        if ( $return ) {
242
+		if ( $return ) {
243 243
 			return $result;
244 244
 		}
245 245
 
246
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
247
-        $max_columns = 8;
248
-        if ( $i <= $max_columns ) {
246
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
247
+		$max_columns = 8;
248
+		if ( $i <= $max_columns ) {
249 249
 			return $result;
250 250
 		}
251 251
 
252
-        global $frm_vars;
253
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
-        }
252
+		global $frm_vars;
253
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
+		}
256 256
 
257
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
258
-            $result = $frm_vars['current_form']->options['hidden_cols'];
259
-        } else {
260
-            $cols = $frm_vars['cols'];
261
-            $cols = array_reverse($cols, true);
257
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
258
+			$result = $frm_vars['current_form']->options['hidden_cols'];
259
+		} else {
260
+			$cols = $frm_vars['cols'];
261
+			$cols = array_reverse($cols, true);
262 262
 
263
-            $result[] = $form_id .'_id';
264
-            $i--;
263
+			$result[] = $form_id .'_id';
264
+			$i--;
265 265
 
266
-            $result[] = $form_id .'_item_key';
267
-            $i--;
266
+			$result[] = $form_id .'_item_key';
267
+			$i--;
268 268
 
269 269
 			foreach ( $cols as $col_key => $col ) {
270
-                if ( $i > $max_columns ) {
270
+				if ( $i > $max_columns ) {
271 271
 					$result[] = $col_key;
272 272
 				}
273
-                //remove some columns by default
274
-                $i--;
275
-                unset($col_key, $col);
276
-            }
277
-        }
273
+				//remove some columns by default
274
+				$i--;
275
+				unset($col_key, $col);
276
+			}
277
+		}
278 278
 
279
-        return $result;
280
-    }
279
+		return $result;
280
+	}
281 281
 
282 282
 	public static function display_list( $message = '', $errors = array() ) {
283
-        global $wpdb, $frm_vars;
283
+		global $wpdb, $frm_vars;
284 284
 
285 285
 		$form = FrmForm::get_current_form();
286 286
 		$params = FrmForm::get_admin_params( $form );
287 287
 
288
-        if ( $form ) {
289
-            $params['form'] = $form->id;
290
-            $frm_vars['current_form'] = $form;
288
+		if ( $form ) {
289
+			$params['form'] = $form->id;
290
+			$frm_vars['current_form'] = $form;
291 291
 
292
-	        if ( 'trash' == $form->status ) {
293
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
294
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
295
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
296
-	            unset( $time_to_delete, $delete_timestamp );
297
-	        }
292
+			if ( 'trash' == $form->status ) {
293
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
294
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
295
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
296
+				unset( $time_to_delete, $delete_timestamp );
297
+			}
298 298
 		}
299 299
 
300
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
300
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
301 301
 
302
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
302
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
303 303
 
304
-        $pagenum = $wp_list_table->get_pagenum();
304
+		$pagenum = $wp_list_table->get_pagenum();
305 305
 
306
-        $wp_list_table->prepare_items();
306
+		$wp_list_table->prepare_items();
307 307
 
308
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
309
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
308
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
309
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
310 310
 			$url = add_query_arg( 'paged', $total_pages );
311
-            if ( headers_sent() ) {
312
-                echo FrmAppHelper::js_redirect($url);
313
-            } else {
314
-                wp_redirect( esc_url_raw( $url ) );
315
-            }
316
-            die();
317
-        }
318
-
319
-        if ( empty($message) && isset($_GET['import-message']) ) {
320
-            $message = __( 'Your import is complete', 'formidable' );
321
-        }
322
-
323
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
324
-    }
325
-
326
-    /* Back End CRUD */
311
+			if ( headers_sent() ) {
312
+				echo FrmAppHelper::js_redirect($url);
313
+			} else {
314
+				wp_redirect( esc_url_raw( $url ) );
315
+			}
316
+			die();
317
+		}
318
+
319
+		if ( empty($message) && isset($_GET['import-message']) ) {
320
+			$message = __( 'Your import is complete', 'formidable' );
321
+		}
322
+
323
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
324
+	}
325
+
326
+	/* Back End CRUD */
327 327
 	public static function show( $id = 0 ) {
328
-        FrmAppHelper::permission_check('frm_view_entries');
328
+		FrmAppHelper::permission_check('frm_view_entries');
329 329
 
330
-        if ( ! $id ) {
330
+		if ( ! $id ) {
331 331
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
332 332
 
333
-            if ( ! $id ) {
333
+			if ( ! $id ) {
334 334
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
335
-            }
336
-        }
335
+			}
336
+		}
337 337
 
338
-        $entry = FrmEntry::getOne($id, true);
338
+		$entry = FrmEntry::getOne($id, true);
339 339
 
340
-        $data = maybe_unserialize($entry->description);
340
+		$data = maybe_unserialize($entry->description);
341 341
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
342 342
 			$data = array( 'referrer' => $data );
343 343
 		}
344 344
 
345 345
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
346
-        $to_emails = array();
346
+		$to_emails = array();
347 347
 
348
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
349
-    }
348
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
349
+	}
350 350
 
351
-    public static function destroy() {
352
-        FrmAppHelper::permission_check('frm_delete_entries');
351
+	public static function destroy() {
352
+		FrmAppHelper::permission_check('frm_delete_entries');
353 353
 
354 354
 		$params = FrmForm::get_admin_params();
355 355
 
356
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
357
-            //unlink entry from post
358
-            global $wpdb;
356
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
357
+			//unlink entry from post
358
+			global $wpdb;
359 359
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
360
-        }
360
+		}
361 361
 
362
-        $message = '';
363
-        if ( FrmEntry::destroy( $params['id'] ) ) {
364
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
365
-        }
362
+		$message = '';
363
+		if ( FrmEntry::destroy( $params['id'] ) ) {
364
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
365
+		}
366 366
 
367
-        self::display_list( $message );
368
-    }
367
+		self::display_list( $message );
368
+	}
369 369
 
370
-    public static function destroy_all() {
371
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
372
-            $frm_settings = FrmAppHelper::get_settings();
373
-            wp_die( $frm_settings->admin_permission );
374
-        }
370
+	public static function destroy_all() {
371
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
372
+			$frm_settings = FrmAppHelper::get_settings();
373
+			wp_die( $frm_settings->admin_permission );
374
+		}
375 375
 
376
-        global $wpdb;
376
+		global $wpdb;
377 377
 		$params = FrmForm::get_admin_params();
378
-        $message = '';
379
-        $errors = array();
380
-        $form_id = (int) $params['form'];
378
+		$message = '';
379
+		$errors = array();
380
+		$form_id = (int) $params['form'];
381 381
 
382
-        if ( $form_id ) {
383
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
382
+		if ( $form_id ) {
383
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
384 384
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
385 385
 
386
-            if ( $action ) {
387
-                // this action takes a while, so only trigger it if there are posts to delete
388
-                foreach ( $entry_ids as $entry_id ) {
389
-                    do_action( 'frm_before_destroy_entry', $entry_id );
390
-                    unset( $entry_id );
391
-                }
392
-            }
393
-
394
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
395
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
396
-            if ( $results ) {
397
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
398
-            }
399
-        } else {
400
-            $errors = __( 'No entries were specified', 'formidable' );
401
-        }
402
-
403
-        self::display_list( $message, $errors );
404
-    }
405
-
406
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
407
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
408
-        return FrmFormsController::show_form( $id, $key, $title, $description );
409
-    }
410
-
411
-    public static function get_form( $filename, $form, $title, $description ) {
412
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
413
-        return FrmFormsController::get_form( $form, $title, $description );
414
-    }
415
-
416
-    public static function process_entry( $errors = '', $ajax = false ) {
386
+			if ( $action ) {
387
+				// this action takes a while, so only trigger it if there are posts to delete
388
+				foreach ( $entry_ids as $entry_id ) {
389
+					do_action( 'frm_before_destroy_entry', $entry_id );
390
+					unset( $entry_id );
391
+				}
392
+			}
393
+
394
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
395
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
396
+			if ( $results ) {
397
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
398
+			}
399
+		} else {
400
+			$errors = __( 'No entries were specified', 'formidable' );
401
+		}
402
+
403
+		self::display_list( $message, $errors );
404
+	}
405
+
406
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
407
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
408
+		return FrmFormsController::show_form( $id, $key, $title, $description );
409
+	}
410
+
411
+	public static function get_form( $filename, $form, $title, $description ) {
412
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
413
+		return FrmFormsController::get_form( $form, $title, $description );
414
+	}
415
+
416
+	public static function process_entry( $errors = '', $ajax = false ) {
417 417
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
418 418
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
419
-            return;
420
-        }
419
+			return;
420
+		}
421 421
 
422
-        global $frm_vars;
422
+		global $frm_vars;
423 423
 
424 424
 		$form = FrmForm::getOne( $form_id );
425
-        if ( ! $form ) {
426
-            return;
427
-        }
425
+		if ( ! $form ) {
426
+			return;
427
+		}
428 428
 
429 429
 		$params = FrmForm::get_params( $form );
430 430
 
431
-        if ( ! isset( $frm_vars['form_params'] ) ) {
432
-            $frm_vars['form_params'] = array();
433
-        }
431
+		if ( ! isset( $frm_vars['form_params'] ) ) {
432
+			$frm_vars['form_params'] = array();
433
+		}
434 434
 		$frm_vars['form_params'][ $form->id ] = $params;
435 435
 
436 436
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
437
-            return;
438
-        }
437
+			return;
438
+		}
439 439
 
440
-        if ( $errors == '' ) {
440
+		if ( $errors == '' ) {
441 441
 			$errors = FrmEntryValidate::validate( $_POST );
442
-        }
442
+		}
443 443
 
444 444
 		/**
445 445
 		 * Use this filter to add trigger actions and add errors after
@@ -450,102 +450,102 @@  discard block
 block discarded – undo
450 450
 
451 451
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
452 452
 
453
-        if ( empty( $errors ) ) {
453
+		if ( empty( $errors ) ) {
454 454
 			$_POST['frm_skip_cookie'] = 1;
455
-            if ( $params['action'] == 'create' ) {
455
+			if ( $params['action'] == 'create' ) {
456 456
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
457 457
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
458
-                }
459
-            }
458
+				}
459
+			}
460 460
 
461
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
461
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
462 462
 			unset( $_POST['frm_skip_cookie'] );
463
-        }
464
-    }
465
-
466
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
467
-        self::_delete_entry( $atts['id'], $form );
468
-        return $url;
469
-    }
470
-
471
-    //Delete entry if not redirected
472
-    public static function delete_entry_after_save( $atts ) {
473
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
474
-    }
475
-
476
-    private static function _delete_entry( $entry_id, $form ) {
477
-        if ( ! $form ) {
478
-            return;
479
-        }
480
-
481
-        $form->options = maybe_unserialize( $form->options );
482
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
483
-            FrmEntry::destroy( $entry_id );
484
-        }
485
-    }
463
+		}
464
+	}
465
+
466
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
467
+		self::_delete_entry( $atts['id'], $form );
468
+		return $url;
469
+	}
470
+
471
+	//Delete entry if not redirected
472
+	public static function delete_entry_after_save( $atts ) {
473
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
474
+	}
475
+
476
+	private static function _delete_entry( $entry_id, $form ) {
477
+		if ( ! $form ) {
478
+			return;
479
+		}
480
+
481
+		$form->options = maybe_unserialize( $form->options );
482
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
483
+			FrmEntry::destroy( $entry_id );
484
+		}
485
+	}
486 486
 
487 487
 	public static function show_entry_shortcode( $atts ) {
488 488
 		return FrmEntryFormat::show_entry( $atts );
489 489
 	}
490 490
 
491
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
-        $field = FrmField::getOne($meta->field_id);
493
-        if ( ! $field ) {
494
-            return $value;
495
-        }
491
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
+		$field = FrmField::getOne($meta->field_id);
493
+		if ( ! $field ) {
494
+			return $value;
495
+		}
496 496
 
497
-        $value = self::filter_display_value($value, $field, $atts);
498
-        return $value;
499
-    }
497
+		$value = self::filter_display_value($value, $field, $atts);
498
+		return $value;
499
+	}
500 500
 
501 501
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
502
-        $plain_text = add_filter('frm_plain_text_email', true);
502
+		$plain_text = add_filter('frm_plain_text_email', true);
503 503
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504 504
 
505
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
506
-            return $value;
507
-        }
505
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
506
+			return $value;
507
+		}
508 508
 
509
-        return self::filter_display_value($value, $field, $atts);
510
-    }
509
+		return self::filter_display_value($value, $field, $atts);
510
+	}
511 511
 
512
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
513
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
512
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
513
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514 514
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
515
-            return $value;
516
-        }
517
-
518
-        $f_values = $f_labels = array();
519
-
520
-        foreach ( $field->options as $opt_key => $opt ) {
521
-            if ( ! is_array($opt) ) {
522
-                continue;
523
-            }
524
-
525
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
529
-            }
530
-            unset($opt_key, $opt);
531
-        }
532
-
533
-        if ( ! empty($f_values) ) {
534
-            foreach ( (array) $value as $v_key => $val ) {
535
-                if ( in_array($val, $f_values) ) {
536
-                    $opt = array_search($val, $f_values);
537
-                    if ( is_array($value) ) {
538
-                        $value[ $v_key ] = $f_labels[ $opt ];
539
-                    } else {
540
-                        $value = $f_labels[ $opt ];
541
-                    }
542
-                }
543
-                unset($v_key, $val);
544
-            }
545
-        }
546
-
547
-        return $value;
548
-    }
515
+			return $value;
516
+		}
517
+
518
+		$f_values = $f_labels = array();
519
+
520
+		foreach ( $field->options as $opt_key => $opt ) {
521
+			if ( ! is_array($opt) ) {
522
+				continue;
523
+			}
524
+
525
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
529
+			}
530
+			unset($opt_key, $opt);
531
+		}
532
+
533
+		if ( ! empty($f_values) ) {
534
+			foreach ( (array) $value as $v_key => $val ) {
535
+				if ( in_array($val, $f_values) ) {
536
+					$opt = array_search($val, $f_values);
537
+					if ( is_array($value) ) {
538
+						$value[ $v_key ] = $f_labels[ $opt ];
539
+					} else {
540
+						$value = $f_labels[ $opt ];
541
+					}
542
+				}
543
+				unset($v_key, $val);
544
+			}
545
+		}
546
+
547
+		return $value;
548
+	}
549 549
 
550 550
 	public static function get_params( $form = null ) {
551 551
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 	}
554 554
 
555 555
 	public static function entry_sidebar( $entry ) {
556
-        $data = maybe_unserialize($entry->description);
557
-        $date_format = get_option('date_format');
558
-        $time_format = get_option('time_format');
556
+		$data = maybe_unserialize($entry->description);
557
+		$date_format = get_option('date_format');
558
+		$time_format = get_option('time_format');
559 559
 		if ( isset( $data['browser'] ) ) {
560 560
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
561 561
 		}
562 562
 
563
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
-    }
563
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
564
+	}
565 565
 }
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
             $frm_settings = FrmAppHelper::get_settings();
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
         $screen->add_help_tab( array(
52 52
             'id'      => 'formidable-entries-tab',
53 53
             'title'   => __( 'Overview', 'formidable' ),
54
-			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
-        ));
54
+			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
55
+        ) );
56 56
 
57 57
         $screen->set_help_sidebar(
58 58
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         global $frm_vars, $wpdb;
68 68
 		$form_id = FrmForm::get_current_form_id();
69 69
 
70
-        $columns[ $form_id .'_id' ] = 'ID';
71
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
70
+        $columns[$form_id . '_id'] = 'ID';
71
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
72 72
 
73 73
         if ( ! $form_id ) {
74 74
             return $columns;
75 75
         }
76 76
 
77
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
77
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
78 78
 
79 79
         foreach ( $form_cols as $form_col ) {
80 80
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -87,30 +87,30 @@  discard block
 block discarded – undo
87 87
                 if ( $sub_form_cols ) {
88 88
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
89 89
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
90
-                            unset( $sub_form_cols[ $k ] );
90
+                            unset( $sub_form_cols[$k] );
91 91
                             continue;
92 92
                         }
93
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
-                        unset($sub_form_col);
93
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
94
+                        unset( $sub_form_col );
95 95
                     }
96 96
                 }
97
-                unset($sub_form_cols);
97
+                unset( $sub_form_cols );
98 98
             } else {
99 99
                 $col_id = $form_col->field_key;
100 100
                 if ( $form_col->form_id != $form_id ) {
101
-                    $col_id .= '-_-form'. $form_col->form_id;
101
+                    $col_id .= '-_-form' . $form_col->form_id;
102 102
                 }
103 103
 
104
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
104
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
105
+                    $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
106 106
                 }
107
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
+                $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
108 108
             }
109 109
         }
110 110
 
111
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
112
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
113
-        $columns[ $form_id .'_ip' ] = 'IP';
111
+        $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
112
+        $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
113
+        $columns[$form_id . '_ip'] = 'IP';
114 114
 
115 115
         $frm_vars['cols'] = $columns;
116 116
 
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 
125 125
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
126 126
         $frm_settings = FrmAppHelper::get_settings();
127
-        if ( $meta_key != 'manage'.  sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
127
+        if ( $meta_key != 'manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden' || $meta_value == $prev_value ) {
128 128
             return $check;
129 129
         }
130 130
 
131 131
 		if ( empty( $prev_value ) ) {
132
-            		$prev_value = get_metadata('user', $object_id, $meta_key, true);
132
+            		$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
133 133
         }
134 134
 
135 135
         global $frm_vars;
136 136
         //add a check so we don't create a loop
137
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
138 138
 
139 139
         return $check;
140 140
     }
@@ -143,25 +143,25 @@  discard block
 block discarded – undo
143 143
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
144 144
         $frm_settings = FrmAppHelper::get_settings();
145 145
 
146
-        $sanitized = sanitize_title($frm_settings->menu);
147
-        if ( $meta_key != 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden' ) {
146
+        $sanitized = sanitize_title( $frm_settings->menu );
147
+        if ( $meta_key != 'manage' . $sanitized . '_page_formidable-entriescolumnshidden' ) {
148 148
             return;
149 149
         }
150 150
 
151 151
         global $frm_vars;
152
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
152
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
153 153
             return; //don't continue if there's no previous value
154 154
         }
155 155
 
156 156
         foreach ( $meta_value as $mk => $mv ) {
157 157
             //remove blank values
158
-            if ( empty( $mv )  ) {
159
-                unset( $meta_value[ $mk ] );
158
+            if ( empty( $mv ) ) {
159
+                unset( $meta_value[$mk] );
160 160
             }
161 161
         }
162 162
 
163
-        $cur_form_prefix = reset($meta_value);
164
-        $cur_form_prefix = explode('_', $cur_form_prefix);
163
+        $cur_form_prefix = reset( $meta_value );
164
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
165 165
         $cur_form_prefix = $cur_form_prefix[0];
166 166
         $save = false;
167 167
 
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 
181 181
             $meta_value[] = $prev_hidden;
182 182
             $save = true;
183
-            unset($form_prefix);
183
+            unset( $form_prefix );
184 184
         }
185 185
 
186 186
 		if ( $save ) {
187 187
             $user = wp_get_current_user();
188
-            update_user_option( $user->ID, 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
188
+            update_user_option( $user->ID, 'manage' . $sanitized . '_page_formidable-entriescolumnshidden', $meta_value, true );
189 189
         }
190 190
     }
191 191
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		foreach ( $fields as $field ) {
213 213
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
214 214
 				// Can't sort on checkboxes because they are stored serialized, or post fields
215
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
215
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
216 216
 			}
217 217
 		}
218 218
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                     break;
236 236
                 }
237 237
 
238
-                unset($form_prefix);
238
+                unset( $form_prefix );
239 239
             }
240 240
         }
241 241
 
@@ -243,36 +243,36 @@  discard block
 block discarded – undo
243 243
 			return $result;
244 244
 		}
245 245
 
246
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
246
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
247 247
         $max_columns = 8;
248 248
         if ( $i <= $max_columns ) {
249 249
 			return $result;
250 250
 		}
251 251
 
252 252
         global $frm_vars;
253
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
254
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
253
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
254
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
255 255
         }
256 256
 
257
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
257
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
258 258
             $result = $frm_vars['current_form']->options['hidden_cols'];
259 259
         } else {
260 260
             $cols = $frm_vars['cols'];
261
-            $cols = array_reverse($cols, true);
261
+            $cols = array_reverse( $cols, true );
262 262
 
263
-            $result[] = $form_id .'_id';
264
-            $i--;
263
+            $result[] = $form_id . '_id';
264
+            $i --;
265 265
 
266
-            $result[] = $form_id .'_item_key';
267
-            $i--;
266
+            $result[] = $form_id . '_item_key';
267
+            $i --;
268 268
 
269 269
 			foreach ( $cols as $col_key => $col ) {
270 270
                 if ( $i > $max_columns ) {
271 271
 					$result[] = $col_key;
272 272
 				}
273 273
                 //remove some columns by default
274
-                $i--;
275
-                unset($col_key, $col);
274
+                $i --;
275
+                unset( $col_key, $col );
276 276
             }
277 277
         }
278 278
 
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
310 310
 			$url = add_query_arg( 'paged', $total_pages );
311 311
             if ( headers_sent() ) {
312
-                echo FrmAppHelper::js_redirect($url);
312
+                echo FrmAppHelper::js_redirect( $url );
313 313
             } else {
314 314
                 wp_redirect( esc_url_raw( $url ) );
315 315
             }
316 316
             die();
317 317
         }
318 318
 
319
-        if ( empty($message) && isset($_GET['import-message']) ) {
319
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
320 320
             $message = __( 'Your import is complete', 'formidable' );
321 321
         }
322 322
 
323
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
323
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
324 324
     }
325 325
 
326 326
     /* Back End CRUD */
327 327
 	public static function show( $id = 0 ) {
328
-        FrmAppHelper::permission_check('frm_view_entries');
328
+        FrmAppHelper::permission_check( 'frm_view_entries' );
329 329
 
330 330
         if ( ! $id ) {
331 331
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
             }
336 336
         }
337 337
 
338
-        $entry = FrmEntry::getOne($id, true);
338
+        $entry = FrmEntry::getOne( $id, true );
339 339
 
340
-        $data = maybe_unserialize($entry->description);
340
+        $data = maybe_unserialize( $entry->description );
341 341
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
342 342
 			$data = array( 'referrer' => $data );
343 343
 		}
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
346 346
         $to_emails = array();
347 347
 
348
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
348
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
349 349
     }
350 350
 
351 351
     public static function destroy() {
352
-        FrmAppHelper::permission_check('frm_delete_entries');
352
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
353 353
 
354 354
 		$params = FrmForm::get_admin_params();
355 355
 
356
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
356
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
357 357
             //unlink entry from post
358 358
             global $wpdb;
359
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
359
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
360 360
         }
361 361
 
362 362
         $message = '';
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
         if ( ! isset( $frm_vars['form_params'] ) ) {
432 432
             $frm_vars['form_params'] = array();
433 433
         }
434
-		$frm_vars['form_params'][ $form->id ] = $params;
434
+		$frm_vars['form_params'][$form->id] = $params;
435 435
 
436
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
436
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
437 437
             return;
438 438
         }
439 439
 
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
 		 */
449 449
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
450 450
 
451
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
451
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
452 452
 
453 453
         if ( empty( $errors ) ) {
454 454
 			$_POST['frm_skip_cookie'] = 1;
455 455
             if ( $params['action'] == 'create' ) {
456
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
457
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
456
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
457
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
458 458
                 }
459 459
             }
460 460
 
@@ -489,28 +489,28 @@  discard block
 block discarded – undo
489 489
 	}
490 490
 
491 491
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
492
-        $field = FrmField::getOne($meta->field_id);
492
+        $field = FrmField::getOne( $meta->field_id );
493 493
         if ( ! $field ) {
494 494
             return $value;
495 495
         }
496 496
 
497
-        $value = self::filter_display_value($value, $field, $atts);
497
+        $value = self::filter_display_value( $value, $field, $atts );
498 498
         return $value;
499 499
     }
500 500
 
501 501
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
502
-        $plain_text = add_filter('frm_plain_text_email', true);
502
+        $plain_text = add_filter( 'frm_plain_text_email', true );
503 503
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
504 504
 
505
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
505
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
506 506
             return $value;
507 507
         }
508 508
 
509
-        return self::filter_display_value($value, $field, $atts);
509
+        return self::filter_display_value( $value, $field, $atts );
510 510
     }
511 511
 
512 512
     public static function &filter_display_value( $value, $field, $atts = array() ) {
513
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
513
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
514 514
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
515 515
             return $value;
516 516
         }
@@ -518,29 +518,29 @@  discard block
 block discarded – undo
518 518
         $f_values = $f_labels = array();
519 519
 
520 520
         foreach ( $field->options as $opt_key => $opt ) {
521
-            if ( ! is_array($opt) ) {
521
+            if ( ! is_array( $opt ) ) {
522 522
                 continue;
523 523
             }
524 524
 
525
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
526
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
527
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
528
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
525
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
526
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
527
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
528
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
529 529
             }
530
-            unset($opt_key, $opt);
530
+            unset( $opt_key, $opt );
531 531
         }
532 532
 
533
-        if ( ! empty($f_values) ) {
533
+        if ( ! empty( $f_values ) ) {
534 534
             foreach ( (array) $value as $v_key => $val ) {
535
-                if ( in_array($val, $f_values) ) {
536
-                    $opt = array_search($val, $f_values);
537
-                    if ( is_array($value) ) {
538
-                        $value[ $v_key ] = $f_labels[ $opt ];
535
+                if ( in_array( $val, $f_values ) ) {
536
+                    $opt = array_search( $val, $f_values );
537
+                    if ( is_array( $value ) ) {
538
+                        $value[$v_key] = $f_labels[$opt];
539 539
                     } else {
540
-                        $value = $f_labels[ $opt ];
540
+                        $value = $f_labels[$opt];
541 541
                     }
542 542
                 }
543
-                unset($v_key, $val);
543
+                unset( $v_key, $val );
544 544
             }
545 545
         }
546 546
 
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 	}
554 554
 
555 555
 	public static function entry_sidebar( $entry ) {
556
-        $data = maybe_unserialize($entry->description);
557
-        $date_format = get_option('date_format');
558
-        $time_format = get_option('time_format');
556
+        $data = maybe_unserialize( $entry->description );
557
+        $date_format = get_option( 'date_format' );
558
+        $time_format = get_option( 'time_format' );
559 559
 		if ( isset( $data['browser'] ) ) {
560 560
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
561 561
 		}
562 562
 
563
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
563
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
564 564
     }
565 565
 }
Please login to merge, or discard this patch.
classes/controllers/FrmFormActionsController.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,109 +1,109 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmFormActionsController {
4
-    public static $action_post_type = 'frm_form_actions';
5
-    public static $registered_actions;
6
-
7
-    public static function register_post_types() {
8
-        register_post_type( self::$action_post_type, array(
9
-            'label' => __( 'Form Actions', 'formidable' ),
10
-            'description' => '',
11
-            'public' => false,
12
-            'show_ui' => false,
13
-            'exclude_from_search' => true,
14
-            'show_in_nav_menus' => false,
15
-            'show_in_menu' => true,
16
-            'capability_type' => 'page',
17
-            'supports' => array(
4
+	public static $action_post_type = 'frm_form_actions';
5
+	public static $registered_actions;
6
+
7
+	public static function register_post_types() {
8
+		register_post_type( self::$action_post_type, array(
9
+			'label' => __( 'Form Actions', 'formidable' ),
10
+			'description' => '',
11
+			'public' => false,
12
+			'show_ui' => false,
13
+			'exclude_from_search' => true,
14
+			'show_in_nav_menus' => false,
15
+			'show_in_menu' => true,
16
+			'capability_type' => 'page',
17
+			'supports' => array(
18 18
 				'title', 'editor', 'excerpt', 'custom-fields',
19 19
 				'page-attributes',
20
-            ),
21
-            'has_archive' => false,
22
-        ) );
23
-
24
-        /**
25
-         * post_content: json settings
26
-         * menu_order: form id
27
-         * post_excerpt: action type
28
-         */
29
-
30
-        self::actions_init();
31
-    }
32
-
33
-    public static function actions_init() {
34
-        self::$registered_actions = new Frm_Form_Action_Factory();
35
-        self::register_actions();
36
-        do_action( 'frm_form_actions_init' );
37
-    }
38
-
39
-    public static function register_actions() {
40
-        $action_classes = apply_filters( 'frm_registered_form_actions', array(
41
-            'email'     => 'FrmEmailAction',
42
-            'wppost'    => 'FrmDefPostAction',
43
-            'register'  => 'FrmDefRegAction',
44
-            'paypal'    => 'FrmDefPayPalAction',
45
-            //'aweber'    => 'FrmDefAweberAction',
46
-            'mailchimp' => 'FrmDefMlcmpAction',
47
-            'twilio'    => 'FrmDefTwilioAction',
48
-            'highrise'  => 'FrmDefHrsAction',
49
-        ) );
50
-
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
-
54
-        foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
56
-        }
57
-    }
20
+			),
21
+			'has_archive' => false,
22
+		) );
23
+
24
+		/**
25
+		 * post_content: json settings
26
+		 * menu_order: form id
27
+		 * post_excerpt: action type
28
+		 */
29
+
30
+		self::actions_init();
31
+	}
32
+
33
+	public static function actions_init() {
34
+		self::$registered_actions = new Frm_Form_Action_Factory();
35
+		self::register_actions();
36
+		do_action( 'frm_form_actions_init' );
37
+	}
38
+
39
+	public static function register_actions() {
40
+		$action_classes = apply_filters( 'frm_registered_form_actions', array(
41
+			'email'     => 'FrmEmailAction',
42
+			'wppost'    => 'FrmDefPostAction',
43
+			'register'  => 'FrmDefRegAction',
44
+			'paypal'    => 'FrmDefPayPalAction',
45
+			//'aweber'    => 'FrmDefAweberAction',
46
+			'mailchimp' => 'FrmDefMlcmpAction',
47
+			'twilio'    => 'FrmDefTwilioAction',
48
+			'highrise'  => 'FrmDefHrsAction',
49
+		) );
50
+
51
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
+
54
+		foreach ( $action_classes as $action_class ) {
55
+			self::$registered_actions->register($action_class);
56
+		}
57
+	}
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60
-        $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
62
-            self::actions_init();
63
-            $temp_actions = self::$registered_actions->actions;
64
-        } else {
65
-            $temp_actions = $temp_actions->actions;
66
-        }
60
+		$temp_actions = self::$registered_actions;
61
+		if ( empty($temp_actions) ) {
62
+			self::actions_init();
63
+			$temp_actions = self::$registered_actions->actions;
64
+		} else {
65
+			$temp_actions = $temp_actions->actions;
66
+		}
67 67
 
68
-        $actions = array();
68
+		$actions = array();
69 69
 
70
-        foreach ( $temp_actions as $a ) {
71
-            if ( 'all' != $action && $a->id_base == $action ) {
72
-                return $a;
73
-            }
70
+		foreach ( $temp_actions as $a ) {
71
+			if ( 'all' != $action && $a->id_base == $action ) {
72
+				return $a;
73
+			}
74 74
 
75 75
 			$actions[ $a->id_base ] = $a;
76
-        }
77
-        unset( $temp_actions, $a );
78
-
79
-        $action_limit = 10;
80
-        if ( count( $actions ) <= $action_limit ) {
81
-            return $actions;
82
-        }
83
-
84
-        // remove the last few inactive icons if there are too many
85
-        $temp_actions = $actions;
86
-        arsort( $temp_actions );
87
-        foreach ( $temp_actions as $type => $a ) {
88
-            if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
76
+		}
77
+		unset( $temp_actions, $a );
78
+
79
+		$action_limit = 10;
80
+		if ( count( $actions ) <= $action_limit ) {
81
+			return $actions;
82
+		}
83
+
84
+		// remove the last few inactive icons if there are too many
85
+		$temp_actions = $actions;
86
+		arsort( $temp_actions );
87
+		foreach ( $temp_actions as $type => $a ) {
88
+			if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89 89
 				unset( $actions[ $type ] );
90
-                if ( count( $actions ) <= $action_limit ) {
91
-                    break;
92
-                }
93
-            }
94
-            unset( $type, $a );
95
-        }
90
+				if ( count( $actions ) <= $action_limit ) {
91
+					break;
92
+				}
93
+			}
94
+			unset( $type, $a );
95
+		}
96 96
 
97
-        return $actions;
98
-    }
97
+		return $actions;
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * @since 2.0
102 102
 	 */
103
-    public static function list_actions( $form, $values ) {
104
-        if ( empty( $form ) ) {
105
-            return;
106
-        }
103
+	public static function list_actions( $form, $values ) {
104
+		if ( empty( $form ) ) {
105
+			return;
106
+		}
107 107
 
108 108
 		/**
109 109
 		 * use this hook to migrate old settings into a new action
@@ -113,114 +113,114 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$form_actions = FrmFormAction::get_action_for_form( $form->id );
115 115
 
116
-        $action_controls = self::get_form_actions();
116
+		$action_controls = self::get_form_actions();
117 117
 
118
-        $action_map = array();
118
+		$action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
122
-        }
121
+			$action_map[ $control->id_base ] = $key;
122
+		}
123 123
 
124
-    	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
-    	        // don't try and show settings if action no longer exists
127
-    	        continue;
128
-    	    }
124
+		foreach ( $form_actions as $action ) {
125
+			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
+				// don't try and show settings if action no longer exists
127
+				continue;
128
+			}
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
-    	}
132
-    }
130
+			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
+		}
132
+	}
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
-    }
135
+		$action_control->_set($action_key);
136
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
+	}
138 138
 
139
-    public static function add_form_action() {
140
-        check_ajax_referer( 'frm_ajax', 'nonce' );
139
+	public static function add_form_action() {
140
+		check_ajax_referer( 'frm_ajax', 'nonce' );
141 141
 
142
-        global $frm_vars;
142
+		global $frm_vars;
143 143
 
144 144
 		$action_key = absint( $_POST['list_id'] );
145
-        $action_type = sanitize_text_field( $_POST['type'] );
145
+		$action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147
-        $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
147
+		$action_control = self::get_form_actions( $action_type );
148
+		$action_control->_set($action_key);
149 149
 
150
-        $form_id = absint( $_POST['form_id'] );
150
+		$form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+		$form_action = $action_control->prepare_new($form_id);
153 153
 
154
-        $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
154
+		$values = array();
155
+		$form = self::fields_to_values($form_id, $values);
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
-        wp_die();
159
-    }
157
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
+		wp_die();
159
+	}
160 160
 
161
-    public static function fill_action() {
162
-        check_ajax_referer( 'frm_ajax', 'nonce' );
161
+	public static function fill_action() {
162
+		check_ajax_referer( 'frm_ajax', 'nonce' );
163 163
 
164
-        $action_key = absint( $_POST['action_id'] );
165
-        $action_type = sanitize_text_field( $_POST['action_type'] );
164
+		$action_key = absint( $_POST['action_id'] );
165
+		$action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167
-        $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
169
-            wp_die();
170
-        }
167
+		$action_control = self::get_form_actions( $action_type );
168
+		if ( empty($action_control) ) {
169
+			wp_die();
170
+		}
171 171
 
172
-        $form_action = $action_control->get_single_action( $action_key );
172
+		$form_action = $action_control->get_single_action( $action_key );
173 173
 
174
-        $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
174
+		$values = array();
175
+		$form = self::fields_to_values($form_action->menu_order, $values);
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
-        wp_die();
179
-    }
177
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
178
+		wp_die();
179
+	}
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+		$form = FrmForm::getOne($form_id);
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
187
-        foreach ( $fields as $k => $f ) {
188
-            $f = (array) $f;
189
-            $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
191
-            if ( ! isset( $f['post_field'] ) ) {
192
-                $f['post_field'] = '';
193
-            }
194
-            $values['fields'][] = $f;
195
-            unset($k, $f);
196
-        }
197
-
198
-        return $form;
199
-    }
186
+		$fields = FrmField::get_all_for_form($form->id);
187
+		foreach ( $fields as $k => $f ) {
188
+			$f = (array) $f;
189
+			$opts = (array) $f['field_options'];
190
+			$f = array_merge($opts, $f);
191
+			if ( ! isset( $f['post_field'] ) ) {
192
+				$f['post_field'] = '';
193
+			}
194
+			$values['fields'][] = $f;
195
+			unset($k, $f);
196
+		}
197
+
198
+		return $form;
199
+	}
200 200
 
201 201
 	public static function update_settings( $form_id ) {
202
-        global $wpdb;
202
+		global $wpdb;
203 203
 
204
-        $registered_actions = self::$registered_actions->actions;
204
+		$registered_actions = self::$registered_actions->actions;
205 205
 
206 206
 		$old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' );
207
-        $new_actions = array();
207
+		$new_actions = array();
208 208
 
209
-        foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
211
-            if ( ! empty( $action_ids ) ) {
212
-                $new_actions[] = $action_ids;
213
-            }
214
-        }
209
+		foreach ( $registered_actions as $registered_action ) {
210
+			$action_ids = $registered_action->update_callback($form_id);
211
+			if ( ! empty( $action_ids ) ) {
212
+				$new_actions[] = $action_ids;
213
+			}
214
+		}
215 215
 
216
-        //Only use array_merge if there are new actions
217
-        if ( ! empty( $new_actions ) ) {
218
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
219
-        }
220
-        $old_actions = array_diff( $old_actions, $new_actions );
216
+		//Only use array_merge if there are new actions
217
+		if ( ! empty( $new_actions ) ) {
218
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
219
+		}
220
+		$old_actions = array_diff( $old_actions, $new_actions );
221 221
 
222 222
 		self::delete_missing_actions( $old_actions );
223
-    }
223
+	}
224 224
 
225 225
 	public static function delete_missing_actions( $old_actions ) {
226 226
 		if ( ! empty( $old_actions ) ) {
@@ -235,36 +235,36 @@  discard block
 block discarded – undo
235 235
 		self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args );
236 236
 	}
237 237
 
238
-    /**
239
-     * @param string $event
240
-     */
238
+	/**
239
+	 * @param string $event
240
+	 */
241 241
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
242 242
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
243 243
 
244 244
 		if ( empty( $form_actions ) ) {
245
-            return;
246
-        }
245
+			return;
246
+		}
247 247
 
248 248
 		FrmForm::maybe_get_form( $form );
249 249
 
250
-        $link_settings = self::get_form_actions( $type );
251
-        if ( 'all' != $type ) {
252
-            $link_settings = array( $type => $link_settings );
253
-        }
250
+		$link_settings = self::get_form_actions( $type );
251
+		if ( 'all' != $type ) {
252
+			$link_settings = array( $type => $link_settings );
253
+		}
254 254
 
255
-        $stored_actions = $action_priority = array();
255
+		$stored_actions = $action_priority = array();
256 256
 
257 257
 		$importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING;
258 258
 
259
-        foreach ( $form_actions as $action ) {
259
+		foreach ( $form_actions as $action ) {
260 260
 			$trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] );
261 261
 			if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) {
262
-                continue;
263
-            }
262
+				continue;
263
+			}
264 264
 
265
-            if ( ! is_object( $entry ) ) {
266
-                $entry = FrmEntry::getOne( $entry, true );
267
-            }
265
+			if ( ! is_object( $entry ) ) {
266
+				$entry = FrmEntry::getOne( $entry, true );
267
+			}
268 268
 
269 269
 			if ( empty( $entry ) || $entry->is_draft ) {
270 270
 				continue;
@@ -273,66 +273,66 @@  discard block
 block discarded – undo
273 273
 			$child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
274 274
 
275 275
 			if ( $child_entry ) {
276
-                //don't trigger actions for sub forms
277
-                continue;
278
-            }
276
+				//don't trigger actions for sub forms
277
+				continue;
278
+			}
279 279
 
280
-            // check conditional logic
280
+			// check conditional logic
281 281
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
282
-            if ( $stop ) {
283
-                continue;
284
-            }
282
+			if ( $stop ) {
283
+				continue;
284
+			}
285 285
 
286
-            // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
286
+			// store actions so they can be triggered with the correct priority
287
+			$stored_actions[ $action->ID ] = $action;
288
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
289 289
 
290
-            unset($action);
291
-        }
290
+			unset($action);
291
+		}
292 292
 
293
-        if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
293
+		if ( ! empty( $stored_actions ) ) {
294
+			asort($action_priority);
295 295
 
296
-            // make sure hooks are loaded
297
-            new FrmNotification();
296
+			// make sure hooks are loaded
297
+			new FrmNotification();
298 298
 
299
-            foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
299
+			foreach ( $action_priority as $action_id => $priority ) {
300
+				$action = $stored_actions[ $action_id ];
301
+				do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
+				do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
303 303
 
304
-                // If post is created, get updated $entry object
305
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
307
-                }
308
-            }
309
-        }
310
-    }
304
+				// If post is created, get updated $entry object
305
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
+					$entry = FrmEntry::getOne($entry->id, true);
307
+				}
308
+			}
309
+		}
310
+	}
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
-            // continue if we know which actions to copy
315
-            return;
316
-        }
313
+		if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
314
+			// continue if we know which actions to copy
315
+			return;
316
+		}
317 317
 
318
-        $action_controls = self::get_form_actions( );
318
+		$action_controls = self::get_form_actions( );
319 319
 
320
-        foreach ( $action_controls as $action_control ) {
321
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
-            unset( $action_control );
323
-        }
324
-    }
320
+		foreach ( $action_controls as $action_control ) {
321
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
322
+			unset( $action_control );
323
+		}
324
+	}
325 325
 
326
-    public static function limit_by_type( $where ) {
327
-        global $frm_vars, $wpdb;
326
+	public static function limit_by_type( $where ) {
327
+		global $frm_vars, $wpdb;
328 328
 
329
-        if ( ! isset( $frm_vars['action_type'] ) ) {
330
-            return $where;
331
-        }
329
+		if ( ! isset( $frm_vars['action_type'] ) ) {
330
+			return $where;
331
+		}
332 332
 
333
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
-        return $where;
335
-    }
333
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
334
+		return $where;
335
+	}
336 336
 }
337 337
 
338 338
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361 361
 			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
362
+				$this->actions[ $key ]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
             'highrise'  => 'FrmDefHrsAction',
49 49
         ) );
50 50
 
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
51
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
52
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
53 53
 
54 54
         foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
55
+            self::$registered_actions->register( $action_class );
56 56
         }
57 57
     }
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60 60
         $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
61
+        if ( empty( $temp_actions ) ) {
62 62
             self::actions_init();
63 63
             $temp_actions = self::$registered_actions->actions;
64 64
         } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 return $a;
73 73
             }
74 74
 
75
-			$actions[ $a->id_base ] = $a;
75
+			$actions[$a->id_base] = $a;
76 76
         }
77 77
         unset( $temp_actions, $a );
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         arsort( $temp_actions );
87 87
         foreach ( $temp_actions as $type => $a ) {
88 88
             if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
-				unset( $actions[ $type ] );
89
+				unset( $actions[$type] );
90 90
                 if ( count( $actions ) <= $action_limit ) {
91 91
                     break;
92 92
                 }
@@ -118,22 +118,22 @@  discard block
 block discarded – undo
118 118
         $action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
121
+            $action_map[$control->id_base] = $key;
122 122
         }
123 123
 
124 124
     	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
125
+    	    if ( ! isset( $action_map[$action->post_excerpt] ) ) {
126 126
     	        // don't try and show settings if action no longer exists
127 127
     	        continue;
128 128
     	    }
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
130
+    		self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values );
131 131
     	}
132 132
     }
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
135
+        $action_control->_set( $action_key );
136
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
137 137
     }
138 138
 
139 139
     public static function add_form_action() {
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
         $action_type = sanitize_text_field( $_POST['type'] );
146 146
 
147 147
         $action_control = self::get_form_actions( $action_type );
148
-        $action_control->_set($action_key);
148
+        $action_control->_set( $action_key );
149 149
 
150 150
         $form_id = absint( $_POST['form_id'] );
151 151
 
152
-        $form_action = $action_control->prepare_new($form_id);
152
+        $form_action = $action_control->prepare_new( $form_id );
153 153
 
154 154
         $values = array();
155
-        $form = self::fields_to_values($form_id, $values);
155
+        $form = self::fields_to_values( $form_id, $values );
156 156
 
157
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
157
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
158 158
         wp_die();
159 159
     }
160 160
 
@@ -165,34 +165,34 @@  discard block
 block discarded – undo
165 165
         $action_type = sanitize_text_field( $_POST['action_type'] );
166 166
 
167 167
         $action_control = self::get_form_actions( $action_type );
168
-        if ( empty($action_control) ) {
168
+        if ( empty( $action_control ) ) {
169 169
             wp_die();
170 170
         }
171 171
 
172 172
         $form_action = $action_control->get_single_action( $action_key );
173 173
 
174 174
         $values = array();
175
-        $form = self::fields_to_values($form_action->menu_order, $values);
175
+        $form = self::fields_to_values( $form_action->menu_order, $values );
176 176
 
177
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
177
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
178 178
         wp_die();
179 179
     }
180 180
 
181 181
 	private static function fields_to_values( $form_id, array &$values ) {
182
-        $form = FrmForm::getOne($form_id);
182
+        $form = FrmForm::getOne( $form_id );
183 183
 
184 184
 		$values = array( 'fields' => array(), 'id' => $form->id );
185 185
 
186
-        $fields = FrmField::get_all_for_form($form->id);
186
+        $fields = FrmField::get_all_for_form( $form->id );
187 187
         foreach ( $fields as $k => $f ) {
188 188
             $f = (array) $f;
189 189
             $opts = (array) $f['field_options'];
190
-            $f = array_merge($opts, $f);
190
+            $f = array_merge( $opts, $f );
191 191
             if ( ! isset( $f['post_field'] ) ) {
192 192
                 $f['post_field'] = '';
193 193
             }
194 194
             $values['fields'][] = $f;
195
-            unset($k, $f);
195
+            unset( $k, $f );
196 196
         }
197 197
 
198 198
         return $form;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $new_actions = array();
208 208
 
209 209
         foreach ( $registered_actions as $registered_action ) {
210
-            $action_ids = $registered_action->update_callback($form_id);
210
+            $action_ids = $registered_action->update_callback( $form_id );
211 211
             if ( ! empty( $action_ids ) ) {
212 212
                 $new_actions[] = $action_ids;
213 213
             }
@@ -284,33 +284,33 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             // store actions so they can be triggered with the correct priority
287
-            $stored_actions[ $action->ID ] = $action;
288
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
287
+            $stored_actions[$action->ID] = $action;
288
+            $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
289 289
 
290
-            unset($action);
290
+            unset( $action );
291 291
         }
292 292
 
293 293
         if ( ! empty( $stored_actions ) ) {
294
-            asort($action_priority);
294
+            asort( $action_priority );
295 295
 
296 296
             // make sure hooks are loaded
297 297
             new FrmNotification();
298 298
 
299 299
             foreach ( $action_priority as $action_id => $priority ) {
300
-                $action = $stored_actions[ $action_id ];
301
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
302
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
300
+                $action = $stored_actions[$action_id];
301
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
302
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
303 303
 
304 304
                 // If post is created, get updated $entry object
305 305
                 if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
306
-                    $entry = FrmEntry::getOne($entry->id, true);
306
+                    $entry = FrmEntry::getOne( $entry->id, true );
307 307
                 }
308 308
             }
309 309
         }
310 310
     }
311 311
 
312 312
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
313
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
313
+        if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
314 314
             // continue if we know which actions to copy
315 315
             return;
316 316
         }
@@ -344,22 +344,22 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 
346 346
 	public function register( $action_class ) {
347
-		$this->actions[ $action_class ] = new $action_class();
347
+		$this->actions[$action_class] = new $action_class();
348 348
 	}
349 349
 
350 350
 	public function unregister( $action_class ) {
351
-		if ( isset( $this->actions[ $action_class ] ) ) {
352
-			unset($this->actions[ $action_class ]);
351
+		if ( isset( $this->actions[$action_class] ) ) {
352
+			unset( $this->actions[$action_class] );
353 353
 		}
354 354
 	}
355 355
 
356 356
 	public function _register_actions() {
357
-		$keys = array_keys($this->actions);
357
+		$keys = array_keys( $this->actions );
358 358
 
359 359
 		foreach ( $keys as $key ) {
360 360
 			// don't register new action if old action with the same id is already registered
361
-			if ( ! isset( $this->actions[ $key ] ) ) {
362
-			    $this->actions[ $key ]->_register();
361
+			if ( ! isset( $this->actions[$key] ) ) {
362
+			    $this->actions[$key]->_register();
363 363
 			}
364 364
 		}
365 365
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmHooksController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,8 +143,8 @@
 block discarded – undo
143 143
         add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
144 144
 
145 145
 		// Addons Controller
146
-		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
-		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146
+		add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
147
+		add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
148 148
 
149 149
         // Fields Controller
150 150
         add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,91 +1,91 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmHooksController {
4
-    /**
5
-     * Trigger plugin-wide hook loading
6
-     */
7
-    public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
-        $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
-
10
-        $trigger_hooks = $hooks;
11
-        $hooks = (array) $hooks;
12
-
13
-        if ( 'load_hooks' == $trigger_hooks ) {
14
-            if ( is_admin() ) {
15
-                $hooks[] = 'load_admin_hooks';
16
-                if ( defined( 'DOING_AJAX' ) ) {
17
-                    $hooks[] = 'load_ajax_hooks';
18
-                    $hooks[] = 'load_form_hooks';
19
-                }
20
-            }
21
-
22
-            if ( is_multisite() ) {
23
-                $hooks[] = 'load_multisite_hooks';
24
-            }
25
-        } else {
26
-            // Make sure the hooks are only triggered once
27
-            add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
-        }
29
-        unset( $trigger_hooks );
30
-
31
-        // Instansiate Controllers
32
-        foreach ( $controllers as $c ) {
33
-            foreach ( $hooks as $hook ) {
4
+	/**
5
+	 * Trigger plugin-wide hook loading
6
+	 */
7
+	public static function trigger_load_hook( $hooks = 'load_hooks' ) {
8
+		$controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
9
+
10
+		$trigger_hooks = $hooks;
11
+		$hooks = (array) $hooks;
12
+
13
+		if ( 'load_hooks' == $trigger_hooks ) {
14
+			if ( is_admin() ) {
15
+				$hooks[] = 'load_admin_hooks';
16
+				if ( defined( 'DOING_AJAX' ) ) {
17
+					$hooks[] = 'load_ajax_hooks';
18
+					$hooks[] = 'load_form_hooks';
19
+				}
20
+			}
21
+
22
+			if ( is_multisite() ) {
23
+				$hooks[] = 'load_multisite_hooks';
24
+			}
25
+		} else {
26
+			// Make sure the hooks are only triggered once
27
+			add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
28
+		}
29
+		unset( $trigger_hooks );
30
+
31
+		// Instansiate Controllers
32
+		foreach ( $controllers as $c ) {
33
+			foreach ( $hooks as $hook ) {
34 34
 				call_user_func( array( $c, $hook ) );
35 35
 				unset( $hook );
36
-            }
36
+			}
37 37
 			unset( $c );
38
-        }
38
+		}
39 39
 
40
-    }
40
+	}
41 41
 
42
-    public static function trigger_load_form_hooks() {
43
-        self::trigger_load_hook( 'load_form_hooks' );
44
-    }
42
+	public static function trigger_load_form_hooks() {
43
+		self::trigger_load_hook( 'load_form_hooks' );
44
+	}
45 45
 
46 46
 	public static function load_hooks() {
47
-        if ( ! is_admin() ) {
48
-            add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
-        }
50
-
51
-        add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
-        add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
-
54
-        // Entries controller
55
-        add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
-        add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
-        add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
-        add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
-        add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
-
61
-        // Form Actions Controller
62
-        add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
47
+		if ( ! is_admin() ) {
48
+			add_filter( 'the_content', 'FrmAppController::page_route', 10 );
49
+		}
50
+
51
+		add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
52
+		add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
53
+
54
+		// Entries controller
55
+		add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
56
+		add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 );
57
+		add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
58
+		add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 );
59
+		add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 );
60
+
61
+		// Form Actions Controller
62
+		add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
63 63
 		add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
64 64
 
65
-        // Forms Controller
66
-        add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
65
+		// Forms Controller
66
+		add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
67 67
 		add_action( 'init', 'FrmFormsController::front_head' );
68
-        add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
-        add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
-        add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
68
+		add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69
+		add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70
+		add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
71 71
 		add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
72 72
 
73 73
 		add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
74 74
 
75
-        // Form Shortcodes
76
-        add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
75
+		// Form Shortcodes
76
+		add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
77 77
 
78
-        // Styles Controller
79
-        add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
-        add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
-        add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
-        add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
-    }
78
+		// Styles Controller
79
+		add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80
+		add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81
+		add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82
+		add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
+	}
84 84
 
85 85
 	public static function load_admin_hooks() {
86
-        add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
-        add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
-        add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
86
+		add_action( 'admin_menu', 'FrmAppController::menu', 1 );
87
+		add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
88
+		add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
89 89
 		add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
90 90
 		add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
91 91
 		add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
@@ -94,122 +94,122 @@  discard block
 block discarded – undo
94 94
 		// Addons Controller
95 95
 		add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
96 96
 
97
-        // Entries Controller
98
-        add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
-        add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
-        add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
-        add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
-        add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
97
+		// Entries Controller
98
+		add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
99
+		add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 );
100
+		add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
101
+		add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
102
+		add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
103 103
 
104
-        // Fields Controller
105
-        add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
104
+		// Fields Controller
105
+		add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' );
106 106
 
107
-        // Form Actions Controller
108
-        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
-            add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
-        }
111
-        add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
107
+		// Form Actions Controller
108
+		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
109
+			add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
110
+		}
111
+		add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
112 112
 
113
-        // Forms Controller
114
-        add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
-        add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
113
+		// Forms Controller
114
+		add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
115
+		add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
116 116
 
117
-        add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
-        add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
117
+		add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
118
+		add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
119 119
 		add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
120 120
 
121
-        // Forms Model
122
-        add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
121
+		// Forms Model
122
+		add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
123 123
 
124
-        // Settings Controller
125
-        add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
-        add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
124
+		// Settings Controller
125
+		add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
126
+		add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
127 127
 
128
-        // Styles Controller
129
-        add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
-        add_action( 'admin_init', 'FrmStylesController::admin_init' );
128
+		// Styles Controller
129
+		add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
130
+		add_action( 'admin_init', 'FrmStylesController::admin_init' );
131 131
 
132
-        // XML Controller
133
-        add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
-    }
132
+		// XML Controller
133
+		add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
134
+	}
135 135
 
136 136
 	public static function load_ajax_hooks() {
137 137
 		add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' );
138 138
 		add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' );
139 139
 		add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
140
-        add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
-        add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
140
+		add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
141
+		add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
142 142
 
143 143
 		// Addons Controller
144 144
 		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
145 145
 		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
146 146
 
147
-        // Fields Controller
148
-        add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
-        add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
-        add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
-        add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
-        add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
-        add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
-        add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
-        add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
-        add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
-        add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
-        add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
-        add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
-        add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
-
162
-        // Form Actions Controller
163
-        add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
-        add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
-
166
-        // Forms Controller
147
+		// Fields Controller
148
+		add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
149
+		add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
150
+		add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' );
151
+		add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' );
152
+		add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' );
153
+		add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
154
+		add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
155
+		add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' );
156
+		add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' );
157
+		add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' );
158
+		add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' );
159
+		add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
160
+		add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' );
161
+
162
+		// Form Actions Controller
163
+		add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
164
+		add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
165
+
166
+		// Forms Controller
167 167
 		add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' );
168 168
 		add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
169 169
 		add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' );
170 170
 		add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' );
171
-        add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
-        add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
-        add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
-        add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
-
176
-        // Styles Controller
177
-        add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
-        add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
-        add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
-        add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
171
+		add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
172
+		add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
173
+		add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
174
+		add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
175
+
176
+		// Styles Controller
177
+		add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
178
+		add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
179
+		add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
180
+		add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
181 181
 		add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
182 182
 		add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
183 183
 
184
-        // XML Controller
184
+		// XML Controller
185 185
 		add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
186 186
 		add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
187
-        add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
-    }
187
+		add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
188
+	}
189 189
 
190 190
 	public static function load_form_hooks() {
191
-        // Fields Controller
192
-        add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
-        add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
-        add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
-        add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
191
+		// Fields Controller
192
+		add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
193
+		add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
194
+		add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
195
+		add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
196 196
 
197 197
 		// Forms Controller
198 198
 		add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' );
199 199
 
200
-        // Styles Controller
201
-        add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
-    }
200
+		// Styles Controller
201
+		add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
202
+	}
203 203
 
204 204
 	public static function load_view_hooks() {
205
-        // Hooks go here when a view is loaded
206
-    }
205
+		// Hooks go here when a view is loaded
206
+	}
207 207
 
208 208
 	public static function load_multisite_hooks() {
209 209
 		add_action( 'init', 'FrmAppController::front_head' );
210 210
 		add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
211 211
 
212
-        // drop tables when mu site is deleted
213
-        add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
-    }
212
+		// drop tables when mu site is deleted
213
+		add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
214
+	}
215 215
 }
Please login to merge, or discard this patch.
classes/controllers/FrmSettingsController.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -2,78 +2,78 @@
 block discarded – undo
2 2
 
3 3
 class FrmSettingsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		// Make sure admins can see the menu items
7 7
 		FrmAppHelper::force_capability( 'frm_change_settings' );
8 8
 
9
-        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
-    }
9
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' );
10
+	}
11 11
 
12
-    public static function license_box() {
12
+	public static function license_box() {
13 13
 		$a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' );
14
-        include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
-    }
14
+		include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' );
15
+	}
16 16
 
17
-    public static function display_form( $errors = array(), $message = '' ) {
18
-        global $frm_vars;
17
+	public static function display_form( $errors = array(), $message = '' ) {
18
+		global $frm_vars;
19 19
 
20
-        $frm_settings = FrmAppHelper::get_settings();
21
-        $frm_roles = FrmAppHelper::frm_capabilities();
20
+		$frm_settings = FrmAppHelper::get_settings();
21
+		$frm_roles = FrmAppHelper::frm_capabilities();
22 22
 
23
-        $uploads = wp_upload_dir();
24
-        $target_path = $uploads['basedir'] . '/formidable/css';
23
+		$uploads = wp_upload_dir();
24
+		$target_path = $uploads['basedir'] . '/formidable/css';
25 25
 
26 26
 		$sections = array();
27 27
 		if ( apply_filters( 'frm_include_addon_page', false ) ) {
28 28
 			$sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' );
29 29
 		}
30
-        $sections = apply_filters( 'frm_add_settings_section', $sections );
30
+		$sections = apply_filters( 'frm_add_settings_section', $sections );
31 31
 
32
-        $captcha_lang = FrmAppHelper::locales( 'captcha' );
32
+		$captcha_lang = FrmAppHelper::locales( 'captcha' );
33 33
 
34
-        require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
-    }
34
+		require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' );
35
+	}
36 36
 
37
-    public static function process_form( $stop_load = false ) {
38
-        global $frm_vars;
37
+	public static function process_form( $stop_load = false ) {
38
+		global $frm_vars;
39 39
 
40
-        $frm_settings = FrmAppHelper::get_settings();
40
+		$frm_settings = FrmAppHelper::get_settings();
41 41
 
42 42
 		$process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
43 43
 		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
44
-            wp_die( $frm_settings->admin_permission );
45
-        }
44
+			wp_die( $frm_settings->admin_permission );
45
+		}
46 46
 
47
-        $errors = array();
48
-        $message = '';
47
+		$errors = array();
48
+		$message = '';
49 49
 
50
-        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
-            //$errors = $frm_settings->validate($_POST,array());
52
-            $frm_settings->update( stripslashes_deep( $_POST ) );
50
+		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) {
51
+			//$errors = $frm_settings->validate($_POST,array());
52
+			$frm_settings->update( stripslashes_deep( $_POST ) );
53 53
 
54
-            if ( empty( $errors ) ) {
55
-                $frm_settings->store();
56
-                $message = __( 'Settings Saved', 'formidable' );
57
-            }
58
-        } else {
59
-            $message = __( 'Settings Saved', 'formidable' );
60
-        }
54
+			if ( empty( $errors ) ) {
55
+				$frm_settings->store();
56
+				$message = __( 'Settings Saved', 'formidable' );
57
+			}
58
+		} else {
59
+			$message = __( 'Settings Saved', 'formidable' );
60
+		}
61 61
 
62 62
 		if ( $stop_load == 'stop_load' ) {
63
-            $frm_vars['settings_routed'] = true;
64
-            return;
65
-        }
63
+			$frm_vars['settings_routed'] = true;
64
+			return;
65
+		}
66 66
 
67
-        self::display_form( $errors, $message );
68
-    }
67
+		self::display_form( $errors, $message );
68
+	}
69 69
 
70
-    public static function route( $stop_load = false ) {
71
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
70
+	public static function route( $stop_load = false ) {
71
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
72 72
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
73
-        if ( $action == 'process-form' ) {
74
-            return self::process_form( $stop_load );
75
-        } else if ( $stop_load != 'stop_load' ) {
76
-            return self::display_form();
77
-        }
78
-    }
73
+		if ( $action == 'process-form' ) {
74
+			return self::process_form( $stop_load );
75
+		} else if ( $stop_load != 'stop_load' ) {
76
+			return self::display_form();
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
classes/controllers/FrmStylesController.php 2 patches
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
     }
42 42
 
43 43
     public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
44
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' );
45 45
     }
46 46
 
47 47
     public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
48
+        if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
49 49
             return;
50 50
         }
51 51
 
52 52
         self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
53
+        wp_enqueue_script( 'jquery-ui-datepicker' );
54 54
 
55 55
         $version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+        wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' );
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
60
+        $style = apply_filters( 'frm_style_head', false );
61 61
         if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
62
+            wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_load_css&flat=1&' . http_build_query( $style->post_content ) );
63 63
         }
64 64
     }
65 65
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131 131
         FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
132
-        self::load_styler('default');
132
+        self::load_styler( 'default' );
133 133
     }
134 134
 
135 135
 	public static function duplicate() {
136 136
 		FrmAppHelper::update_message( __( 'duplicate styling templates', 'formidable' ), 'wrap' );
137
-		self::load_styler('default');
137
+		self::load_styler( 'default' );
138 138
 	}
139 139
 
140 140
 	public static function edit( $style_id = false, $message = '' ) {
141 141
         if ( ! $style_id ) {
142 142
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-            if ( empty($style_id) ) {
143
+            if ( empty( $style_id ) ) {
144 144
                 $style_id = 'default';
145 145
             }
146 146
         }
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
         if ( 'default' == $style_id ) {
149 149
             $style = 'default';
150 150
         } else {
151
-            $frm_style = new FrmStyle($style_id);
151
+            $frm_style = new FrmStyle( $style_id );
152 152
             $style = $frm_style->get_one();
153 153
             $style = $style->ID;
154 154
         }
155 155
 
156
-        self::load_styler($style, $message);
156
+        self::load_styler( $style, $message );
157 157
     }
158 158
 
159 159
     public static function save() {
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
164 164
 
165 165
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
166
-            $id = $frm_style->update($post_id);
167
-            if ( empty($post_id) && ! empty($id) ) {
166
+            $id = $frm_style->update( $post_id );
167
+            if ( empty( $post_id ) && ! empty( $id ) ) {
168 168
                 // set the post id to the new style so it will be loaded for editing
169
-                $post_id = reset($id);
169
+                $post_id = reset( $id );
170 170
             }
171 171
             // include the CSS that includes this style
172 172
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
173 173
             $message = __( 'Your styling settings have been saved.', 'formidable' );
174 174
         }
175 175
 
176
-        return self::edit($post_id, $message);
176
+        return self::edit( $post_id, $message );
177 177
     }
178 178
 
179 179
 	public static function load_styler( $style, $message = '' ) {
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         $frm_style = new FrmStyle();
183 183
         $styles = $frm_style->get_all();
184 184
 
185
-        if ( is_numeric($style) ) {
186
-            $style = $styles[ $style ];
185
+        if ( is_numeric( $style ) ) {
186
+            $style = $styles[$style];
187 187
         } else if ( 'default' == $style ) {
188
-            $style = $frm_style->get_default_style($styles);
188
+            $style = $frm_style->get_default_style( $styles );
189 189
         }
190 190
 
191 191
         self::add_meta_boxes();
192 192
 
193
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
193
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' );
194 194
     }
195 195
 
196 196
 	/**
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 	private static function manage( $message = '', $forms = array() ) {
201 201
         $frm_style = new FrmStyle();
202 202
         $styles = $frm_style->get_all();
203
-        $default_style = $frm_style->get_default_style($styles);
203
+        $default_style = $frm_style->get_default_style( $styles );
204 204
 
205
-        if ( empty($forms) ) {
205
+        if ( empty( $forms ) ) {
206 206
             $forms = FrmForm::get_published_forms();
207 207
         }
208 208
 
209
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
209
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' );
210 210
     }
211 211
 
212 212
     private static function manage_styles() {
@@ -219,31 +219,31 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$forms = FrmForm::get_published_forms();
221 221
         foreach ( $forms as $form ) {
222
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
222
+            if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) {
223 223
                 continue;
224 224
             }
225 225
 
226
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
226
+            $form->options['custom_style'] = $_POST['style'][$form->id];
227 227
 
228 228
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
229
-            unset($form);
229
+            unset( $form );
230 230
         }
231 231
 
232 232
         $message = __( 'Your form styles have been saved.', 'formidable' );
233
-        return self::manage($message, $forms);
233
+        return self::manage( $message, $forms );
234 234
     }
235 235
 
236 236
     public static function custom_css( $message = '', $style = null ) {
237
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
238
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+        wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' );
238
+        wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' );
239 239
         wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
240 240
 
241
-        if ( ! isset($style) ) {
241
+        if ( ! isset( $style ) ) {
242 242
             $frm_style = new FrmStyle();
243 243
             $style = $frm_style->get_default_style();
244 244
         }
245 245
 
246
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
246
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' );
247 247
     }
248 248
 
249 249
     public static function save_css() {
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
254 254
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
255 255
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
256
-            $frm_style->update($post_id);
256
+            $frm_style->update( $post_id );
257 257
             $message = __( 'Your styling settings have been saved.', 'formidable' );
258 258
         }
259 259
 
260
-        return self::custom_css($message);
260
+        return self::custom_css( $message );
261 261
     }
262 262
 
263 263
     public static function route() {
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 
304 304
         // remove the # from the colors
305 305
         foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
306
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
307
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+            if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) {
307
+                $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v );
308 308
             }
309 309
         }
310 310
 
311 311
         echo '<style type="text/css">';
312
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
312
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
313 313
         echo '</style>';
314 314
         wp_die();
315 315
     }
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
         );
332 332
 
333 333
         foreach ( $meta_boxes as $nicename => $name ) {
334
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
-            unset($nicename, $name);
334
+            add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
335
+            unset( $nicename, $name );
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function include_style_section( $atts, $sec ) {
340
-        extract($atts);
340
+        extract( $atts );
341 341
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
342
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
342
+        include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' );
343 343
     }
344 344
 
345 345
     public static function load_css() {
346
-        header('Content-type: text/css');
346
+        header( 'Content-type: text/css' );
347 347
 
348 348
         $frm_style = new FrmStyle();
349 349
         $defaults = $frm_style->get_defaults();
350 350
 
351
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
351
+        include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
352 352
         wp_die();
353 353
     }
354 354
 
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
             $style = 'default';
408 408
         }
409 409
 
410
-        $frm_style = new FrmStyle($style);
410
+        $frm_style = new FrmStyle( $style );
411 411
         $style = $frm_style->get_one();
412 412
 
413 413
         if ( $style ) {
414
-            $class .= ' frm_style_'. $style->post_name;
414
+            $class .= ' frm_style_' . $style->post_name;
415 415
         }
416 416
 
417 417
         return $class;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
      * @param string $val
422 422
      */
423 423
 	public static function get_style_val( $val, $form = 'default' ) {
424
-        $style = self::get_form_style($form);
425
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
426
-            return $style->post_content[ $val ];
424
+        $style = self::get_form_style( $form );
425
+        if ( $style && isset( $style->post_content[$val] ) ) {
426
+            return $style->post_content[$val];
427 427
         }
428 428
     }
429 429
 
430 430
 	public static function show_entry_styles( $default_styles ) {
431
-        $frm_style = new FrmStyle('default');
431
+        $frm_style = new FrmStyle( 'default' );
432 432
         $style = $frm_style->get_one();
433 433
 
434 434
         if ( ! $style ) {
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
             } else if ( 'alt_bg_color' == $name ) {
443 443
                 $setting = 'bg_color_active';
444 444
             }
445
-            $default_styles[ $name ] = $style->post_content[ $setting ];
446
-            unset($name, $val);
445
+            $default_styles[$name] = $style->post_content[$setting];
446
+            unset( $name, $val );
447 447
         }
448 448
 
449 449
         return $default_styles;
450 450
     }
451 451
 
452 452
 	public static function &important_style( $important, $field ) {
453
-        $important = self::get_style_val('important_style', $field['form_id']);
453
+        $important = self::get_style_val( 'important_style', $field['form_id'] );
454 454
         return $important;
455 455
     }
456 456
 
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
     	$i = 0;
477 477
     	$first_open = false;
478 478
     	do {
479
-			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
479
+			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) {
480 480
 				break;
481 481
 			}
482 482
 
483 483
     		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
484
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
485
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+    			if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
485
+    				foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
486 486
     					if ( false == $box || ! $box['title'] ) {
487 487
     						continue;
488 488
 						}
489 489
 
490
-    					$i++;
490
+    					$i ++;
491 491
     					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
492 492
 
493 493
     					if ( ! $first_open && empty( $hidden_class ) ) {
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmStylesController {
4
-    public static $post_type = 'frm_styles';
5
-    public static $screen = 'formidable_page_formidable-styles';
6
-
7
-    public static function load_pro_hooks() {
8
-        if ( FrmAppHelper::pro_is_installed() ) {
9
-            FrmProStylesController::load_pro_hooks();
10
-        }
11
-    }
12
-
13
-    public static function register_post_types() {
14
-        register_post_type( self::$post_type, array(
15
-            'label' => __( 'Styles', 'formidable' ),
16
-            'public' => false,
17
-            'show_ui' => false,
18
-            'capability_type' => 'page',
4
+	public static $post_type = 'frm_styles';
5
+	public static $screen = 'formidable_page_formidable-styles';
6
+
7
+	public static function load_pro_hooks() {
8
+		if ( FrmAppHelper::pro_is_installed() ) {
9
+			FrmProStylesController::load_pro_hooks();
10
+		}
11
+	}
12
+
13
+	public static function register_post_types() {
14
+		register_post_type( self::$post_type, array(
15
+			'label' => __( 'Styles', 'formidable' ),
16
+			'public' => false,
17
+			'show_ui' => false,
18
+			'capability_type' => 'page',
19 19
 			'capabilities' => array(
20 20
 				'edit_post'		=> 'frm_change_settings',
21 21
 				'edit_posts'	=> 'frm_change_settings',
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 				'delete_posts'	=> 'frm_change_settings',
26 26
 				'read_private_posts' => 'read_private_posts',
27 27
 			),
28
-            'supports' => array(
28
+			'supports' => array(
29 29
 				'title',
30
-            ),
31
-            'has_archive' => false,
32
-            'labels' => array(
30
+			),
31
+			'has_archive' => false,
32
+			'labels' => array(
33 33
 				'name' => __( 'Styles', 'formidable' ),
34 34
 				'singular_name' => __( 'Style', 'formidable' ),
35 35
 				'menu_name' => __( 'Style', 'formidable' ),
@@ -37,31 +37,31 @@  discard block
 block discarded – undo
37 37
 				'add_new_item' => __( 'Create a New Style', 'formidable' ),
38 38
 				'edit_item'    => __( 'Edit Style', 'formidable' ),
39 39
 			),
40
-        ) );
41
-    }
40
+		) );
41
+	}
42 42
 
43
-    public static function menu() {
44
-        add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
-    }
43
+	public static function menu() {
44
+		add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route');
45
+	}
46 46
 
47
-    public static function admin_init() {
48
-        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
-            return;
50
-        }
47
+	public static function admin_init() {
48
+		if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
+			return;
50
+		}
51 51
 
52
-        self::load_pro_hooks();
53
-        wp_enqueue_script('jquery-ui-datepicker');
52
+		self::load_pro_hooks();
53
+		wp_enqueue_script('jquery-ui-datepicker');
54 54
 
55
-        $version = FrmAppHelper::plugin_version();
55
+		$version = FrmAppHelper::plugin_version();
56 56
 		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version );
57 57
 
58
-        wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
58
+		wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css');
59 59
 
60
-        $style = apply_filters('frm_style_head', false);
61
-        if ( $style ) {
62
-            wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
-        }
64
-    }
60
+		$style = apply_filters('frm_style_head', false);
61
+		if ( $style ) {
62
+			wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content));
63
+		}
64
+	}
65 65
 
66 66
 	public static function enqueue_css( $register = 'enqueue' ) {
67 67
 		global $frm_vars;
@@ -128,227 +128,227 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	public static function new_style( $return = '' ) {
131
-        self::load_styler('default');
132
-    }
131
+		self::load_styler('default');
132
+	}
133 133
 
134 134
 	public static function duplicate() {
135 135
 		self::load_styler('default');
136 136
 	}
137 137
 
138 138
 	public static function edit( $style_id = false, $message = '' ) {
139
-        if ( ! $style_id ) {
139
+		if ( ! $style_id ) {
140 140
 			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
141
-            if ( empty($style_id) ) {
142
-                $style_id = 'default';
143
-            }
144
-        }
145
-
146
-        if ( 'default' == $style_id ) {
147
-            $style = 'default';
148
-        } else {
149
-            $frm_style = new FrmStyle($style_id);
150
-            $style = $frm_style->get_one();
151
-            $style = $style->ID;
152
-        }
153
-
154
-        self::load_styler($style, $message);
155
-    }
156
-
157
-    public static function save() {
158
-        $frm_style = new FrmStyle();
159
-        $message = '';
141
+			if ( empty($style_id) ) {
142
+				$style_id = 'default';
143
+			}
144
+		}
145
+
146
+		if ( 'default' == $style_id ) {
147
+			$style = 'default';
148
+		} else {
149
+			$frm_style = new FrmStyle($style_id);
150
+			$style = $frm_style->get_one();
151
+			$style = $style->ID;
152
+		}
153
+
154
+		self::load_styler($style, $message);
155
+	}
156
+
157
+	public static function save() {
158
+		$frm_style = new FrmStyle();
159
+		$message = '';
160 160
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' );
161 161
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
162 162
 
163 163
 		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
164
-            $id = $frm_style->update($post_id);
165
-            if ( empty($post_id) && ! empty($id) ) {
166
-                // set the post id to the new style so it will be loaded for editing
167
-                $post_id = reset($id);
168
-            }
169
-            // include the CSS that includes this style
164
+			$id = $frm_style->update($post_id);
165
+			if ( empty($post_id) && ! empty($id) ) {
166
+				// set the post id to the new style so it will be loaded for editing
167
+				$post_id = reset($id);
168
+			}
169
+			// include the CSS that includes this style
170 170
 			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
171
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
172
-        }
171
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
172
+		}
173 173
 
174
-        return self::edit($post_id, $message);
175
-    }
174
+		return self::edit($post_id, $message);
175
+	}
176 176
 
177 177
 	public static function load_styler( $style, $message = '' ) {
178
-        global $frm_settings;
178
+		global $frm_settings;
179 179
 
180
-        $frm_style = new FrmStyle();
181
-        $styles = $frm_style->get_all();
180
+		$frm_style = new FrmStyle();
181
+		$styles = $frm_style->get_all();
182 182
 
183
-        if ( is_numeric($style) ) {
184
-            $style = $styles[ $style ];
185
-        } else if ( 'default' == $style ) {
186
-            $style = $frm_style->get_default_style($styles);
187
-        }
183
+		if ( is_numeric($style) ) {
184
+			$style = $styles[ $style ];
185
+		} else if ( 'default' == $style ) {
186
+			$style = $frm_style->get_default_style($styles);
187
+		}
188 188
 
189
-        self::add_meta_boxes();
189
+		self::add_meta_boxes();
190 190
 
191
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
-    }
191
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php');
192
+	}
193 193
 
194 194
 	/**
195 195
 	 * @param string $message
196 196
 	 * @param array|object $forms
197 197
 	 */
198 198
 	private static function manage( $message = '', $forms = array() ) {
199
-        $frm_style = new FrmStyle();
200
-        $styles = $frm_style->get_all();
201
-        $default_style = $frm_style->get_default_style($styles);
199
+		$frm_style = new FrmStyle();
200
+		$styles = $frm_style->get_all();
201
+		$default_style = $frm_style->get_default_style($styles);
202 202
 
203
-        if ( empty($forms) ) {
204
-            $forms = FrmForm::get_published_forms();
205
-        }
203
+		if ( empty($forms) ) {
204
+			$forms = FrmForm::get_published_forms();
205
+		}
206 206
 
207
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
-    }
207
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php');
208
+	}
209 209
 
210
-    private static function manage_styles() {
210
+	private static function manage_styles() {
211 211
 		$style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' );
212 212
 		if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) {
213
-            return self::manage();
214
-        }
213
+			return self::manage();
214
+		}
215 215
 
216
-        global $wpdb;
216
+		global $wpdb;
217 217
 
218 218
 		$forms = FrmForm::get_published_forms();
219
-        foreach ( $forms as $form ) {
220
-            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
-                continue;
222
-            }
219
+		foreach ( $forms as $form ) {
220
+			if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
221
+				continue;
222
+			}
223 223
 
224
-            $form->options['custom_style'] = $_POST['style'][ $form->id ];
224
+			$form->options['custom_style'] = $_POST['style'][ $form->id ];
225 225
 
226 226
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
227
-            unset($form);
228
-        }
227
+			unset($form);
228
+		}
229 229
 
230
-        $message = __( 'Your form styles have been saved.', 'formidable' );
231
-        return self::manage($message, $forms);
232
-    }
230
+		$message = __( 'Your form styles have been saved.', 'formidable' );
231
+		return self::manage($message, $forms);
232
+	}
233 233
 
234
-    public static function custom_css( $message = '', $style = null ) {
235
-        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
-        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
-        wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
234
+	public static function custom_css( $message = '', $style = null ) {
235
+		wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
236
+		wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
237
+		wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
238 238
 
239
-        if ( ! isset($style) ) {
240
-            $frm_style = new FrmStyle();
241
-            $style = $frm_style->get_default_style();
242
-        }
239
+		if ( ! isset($style) ) {
240
+			$frm_style = new FrmStyle();
241
+			$style = $frm_style->get_default_style();
242
+		}
243 243
 
244
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
-    }
244
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php');
245
+	}
246 246
 
247
-    public static function save_css() {
248
-        $frm_style = new FrmStyle();
247
+	public static function save_css() {
248
+		$frm_style = new FrmStyle();
249 249
 
250
-        $message = '';
250
+		$message = '';
251 251
 		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
252 252
 		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
253 253
 		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
254
-            $frm_style->update($post_id);
255
-            $message = __( 'Your styling settings have been saved.', 'formidable' );
256
-        }
254
+			$frm_style->update($post_id);
255
+			$message = __( 'Your styling settings have been saved.', 'formidable' );
256
+		}
257 257
 
258
-        return self::custom_css($message);
259
-    }
258
+		return self::custom_css($message);
259
+	}
260 260
 
261
-    public static function route() {
261
+	public static function route() {
262 262
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
263 263
 
264
-        switch ( $action ) {
265
-            case 'edit':
266
-            case 'save':
267
-            case 'manage':
268
-            case 'manage_styles':
269
-            case 'custom_css':
270
-            case 'save_css':
264
+		switch ( $action ) {
265
+			case 'edit':
266
+			case 'save':
267
+			case 'manage':
268
+			case 'manage_styles':
269
+			case 'custom_css':
270
+			case 'save_css':
271 271
 				return self::$action();
272
-            default:
273
-            	do_action( 'frm_style_action_route', $action );
274
-            	if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
-                	return;
276
-            	}
277
-
278
-                if ( 'new_style' == $action || 'duplicate' == $action ) {
279
-                    return self::$action();
280
-                }
281
-
282
-                return self::edit();
283
-        }
284
-    }
285
-
286
-    public static function reset_styling() {
287
-        check_ajax_referer( 'frm_ajax', 'nonce' );
288
-
289
-        $frm_style = new FrmStyle();
290
-        $defaults = $frm_style->get_defaults();
291
-
292
-        echo json_encode( $defaults );
293
-        wp_die();
294
-    }
295
-
296
-    public static function change_styling() {
297
-        check_ajax_referer( 'frm_ajax', 'nonce' );
298
-
299
-        $frm_style = new FrmStyle();
300
-        $defaults = $frm_style->get_defaults();
301
-
302
-        // remove the # from the colors
303
-        foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
-            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
-                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
-            }
307
-        }
308
-
309
-        echo '<style type="text/css">';
310
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
-        echo '</style>';
312
-        wp_die();
313
-    }
314
-
315
-    private static function add_meta_boxes() {
316
-
317
-        // setup meta boxes
318
-        $meta_boxes = array(
319
-            'general'           => __( 'General', 'formidable' ),
320
-            'field-labels'      => __( 'Field Labels', 'formidable' ),
321
-            'field-description' => __( 'Field Description', 'formidable' ),
322
-            'field-colors'      => __( 'Field Colors', 'formidable' ),
323
-            'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
-            'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
-            'section-fields'    => __( 'Section Fields', 'formidable' ),
326
-            'date-fields'       => __( 'Date Fields', 'formidable' ),
327
-            'buttons'           => __( 'Buttons', 'formidable' ),
328
-            'form-messages'     => __( 'Form Messages', 'formidable' ),
329
-        );
330
-
331
-        foreach ( $meta_boxes as $nicename => $name ) {
332
-            add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
-            unset($nicename, $name);
334
-        }
335
-    }
272
+			default:
273
+				do_action( 'frm_style_action_route', $action );
274
+				if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
275
+					return;
276
+				}
277
+
278
+				if ( 'new_style' == $action || 'duplicate' == $action ) {
279
+					return self::$action();
280
+				}
281
+
282
+				return self::edit();
283
+		}
284
+	}
285
+
286
+	public static function reset_styling() {
287
+		check_ajax_referer( 'frm_ajax', 'nonce' );
288
+
289
+		$frm_style = new FrmStyle();
290
+		$defaults = $frm_style->get_defaults();
291
+
292
+		echo json_encode( $defaults );
293
+		wp_die();
294
+	}
295
+
296
+	public static function change_styling() {
297
+		check_ajax_referer( 'frm_ajax', 'nonce' );
298
+
299
+		$frm_style = new FrmStyle();
300
+		$defaults = $frm_style->get_defaults();
301
+
302
+		// remove the # from the colors
303
+		foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
304
+			if ( ! is_array($v) && strpos($v, '#') === 0 ) {
305
+				$_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
306
+			}
307
+		}
308
+
309
+		echo '<style type="text/css">';
310
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
311
+		echo '</style>';
312
+		wp_die();
313
+	}
314
+
315
+	private static function add_meta_boxes() {
316
+
317
+		// setup meta boxes
318
+		$meta_boxes = array(
319
+			'general'           => __( 'General', 'formidable' ),
320
+			'field-labels'      => __( 'Field Labels', 'formidable' ),
321
+			'field-description' => __( 'Field Description', 'formidable' ),
322
+			'field-colors'      => __( 'Field Colors', 'formidable' ),
323
+			'field-sizes'       => __( 'Field Settings', 'formidable' ),
324
+			'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
325
+			'section-fields'    => __( 'Section Fields', 'formidable' ),
326
+			'date-fields'       => __( 'Date Fields', 'formidable' ),
327
+			'buttons'           => __( 'Buttons', 'formidable' ),
328
+			'form-messages'     => __( 'Form Messages', 'formidable' ),
329
+		);
330
+
331
+		foreach ( $meta_boxes as $nicename => $name ) {
332
+			add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
333
+			unset($nicename, $name);
334
+		}
335
+	}
336 336
 
337 337
 	public static function include_style_section( $atts, $sec ) {
338
-        extract($atts);
338
+		extract($atts);
339 339
 		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
340
-        include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
-    }
340
+		include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php');
341
+	}
342 342
 
343
-    public static function load_css() {
344
-        header('Content-type: text/css');
343
+	public static function load_css() {
344
+		header('Content-type: text/css');
345 345
 
346
-        $frm_style = new FrmStyle();
347
-        $defaults = $frm_style->get_defaults();
346
+		$frm_style = new FrmStyle();
347
+		$defaults = $frm_style->get_defaults();
348 348
 
349
-        include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
-        wp_die();
351
-    }
349
+		include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php');
350
+		wp_die();
351
+	}
352 352
 
353 353
 	public static function load_saved_css() {
354 354
 		$css = get_transient( 'frmpro_css' );
@@ -357,142 +357,142 @@  discard block
 block discarded – undo
357 357
 		wp_die();
358 358
 	}
359 359
 
360
-    /**
361
-     * Check if the Formidable styling should be loaded,
362
-     * then enqueue it for the footer
363
-     * @since 2.0
364
-     */
365
-    public static function enqueue_style() {
366
-        global $frm_vars;
367
-
368
-        if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
-            // the CSS has already been loaded
370
-            return;
371
-        }
372
-
373
-        $frm_settings = FrmAppHelper::get_settings();
374
-        if ( $frm_settings->load_style != 'none' ) {
375
-            wp_enqueue_style( 'formidable' );
376
-            $frm_vars['css_loaded'] = true;
377
-        }
378
-    }
379
-
380
-    // Get the stylesheets for the form settings page
381
-    public static function get_style_opts() {
382
-        $frm_style = new FrmStyle();
383
-        $styles = $frm_style->get_all();
384
-
385
-        return $styles;
386
-    }
387
-
388
-    public static function get_form_style( $form = 'default' ) {
389
-        $style = FrmFormsHelper::get_form_style( $form );
390
-
391
-        if ( empty( $style ) || 1 == $style ) {
392
-            $style = 'default';
393
-        }
394
-
395
-        $frm_style = new FrmStyle( $style );
396
-        return $frm_style->get_one();
397
-    }
398
-
399
-    /**
400
-     * @param string $class
401
-     * @param string $style
402
-     */
360
+	/**
361
+	 * Check if the Formidable styling should be loaded,
362
+	 * then enqueue it for the footer
363
+	 * @since 2.0
364
+	 */
365
+	public static function enqueue_style() {
366
+		global $frm_vars;
367
+
368
+		if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
369
+			// the CSS has already been loaded
370
+			return;
371
+		}
372
+
373
+		$frm_settings = FrmAppHelper::get_settings();
374
+		if ( $frm_settings->load_style != 'none' ) {
375
+			wp_enqueue_style( 'formidable' );
376
+			$frm_vars['css_loaded'] = true;
377
+		}
378
+	}
379
+
380
+	// Get the stylesheets for the form settings page
381
+	public static function get_style_opts() {
382
+		$frm_style = new FrmStyle();
383
+		$styles = $frm_style->get_all();
384
+
385
+		return $styles;
386
+	}
387
+
388
+	public static function get_form_style( $form = 'default' ) {
389
+		$style = FrmFormsHelper::get_form_style( $form );
390
+
391
+		if ( empty( $style ) || 1 == $style ) {
392
+			$style = 'default';
393
+		}
394
+
395
+		$frm_style = new FrmStyle( $style );
396
+		return $frm_style->get_one();
397
+	}
398
+
399
+	/**
400
+	 * @param string $class
401
+	 * @param string $style
402
+	 */
403 403
 	public static function get_form_style_class( $class, $style ) {
404
-        if ( 1 == $style ) {
405
-            $style = 'default';
406
-        }
404
+		if ( 1 == $style ) {
405
+			$style = 'default';
406
+		}
407 407
 
408
-        $frm_style = new FrmStyle($style);
409
-        $style = $frm_style->get_one();
408
+		$frm_style = new FrmStyle($style);
409
+		$style = $frm_style->get_one();
410 410
 
411
-        if ( $style ) {
412
-            $class .= ' frm_style_'. $style->post_name;
413
-        }
411
+		if ( $style ) {
412
+			$class .= ' frm_style_'. $style->post_name;
413
+		}
414 414
 
415
-        return $class;
416
-    }
415
+		return $class;
416
+	}
417 417
 
418
-    /**
419
-     * @param string $val
420
-     */
418
+	/**
419
+	 * @param string $val
420
+	 */
421 421
 	public static function get_style_val( $val, $form = 'default' ) {
422
-        $style = self::get_form_style($form);
423
-        if ( $style && isset( $style->post_content[ $val ] ) ) {
424
-            return $style->post_content[ $val ];
425
-        }
426
-    }
422
+		$style = self::get_form_style($form);
423
+		if ( $style && isset( $style->post_content[ $val ] ) ) {
424
+			return $style->post_content[ $val ];
425
+		}
426
+	}
427 427
 
428 428
 	public static function show_entry_styles( $default_styles ) {
429
-        $frm_style = new FrmStyle('default');
430
-        $style = $frm_style->get_one();
431
-
432
-        if ( ! $style ) {
433
-            return $default_styles;
434
-        }
435
-
436
-        foreach ( $default_styles as $name => $val ) {
437
-            $setting = $name;
438
-            if ( 'border_width' == $name ) {
439
-                $setting = 'field_border_width';
440
-            } else if ( 'alt_bg_color' == $name ) {
441
-                $setting = 'bg_color_active';
442
-            }
443
-            $default_styles[ $name ] = $style->post_content[ $setting ];
444
-            unset($name, $val);
445
-        }
446
-
447
-        return $default_styles;
448
-    }
429
+		$frm_style = new FrmStyle('default');
430
+		$style = $frm_style->get_one();
431
+
432
+		if ( ! $style ) {
433
+			return $default_styles;
434
+		}
435
+
436
+		foreach ( $default_styles as $name => $val ) {
437
+			$setting = $name;
438
+			if ( 'border_width' == $name ) {
439
+				$setting = 'field_border_width';
440
+			} else if ( 'alt_bg_color' == $name ) {
441
+				$setting = 'bg_color_active';
442
+			}
443
+			$default_styles[ $name ] = $style->post_content[ $setting ];
444
+			unset($name, $val);
445
+		}
446
+
447
+		return $default_styles;
448
+	}
449 449
 
450 450
 	public static function &important_style( $important, $field ) {
451
-        $important = self::get_style_val('important_style', $field['form_id']);
452
-        return $important;
453
-    }
451
+		$important = self::get_style_val('important_style', $field['form_id']);
452
+		return $important;
453
+	}
454 454
 
455
-    /**
456
-     * Fallback for WP < 3.6
457
-     */
458
-    public static function do_accordion_sections( $screen, $context, $object ) {
459
-        if ( function_exists( 'do_accordion_sections' ) ) {
460
-            return do_accordion_sections( $screen, $context, $object );
461
-        }
455
+	/**
456
+	 * Fallback for WP < 3.6
457
+	 */
458
+	public static function do_accordion_sections( $screen, $context, $object ) {
459
+		if ( function_exists( 'do_accordion_sections' ) ) {
460
+			return do_accordion_sections( $screen, $context, $object );
461
+		}
462 462
 
463
-    	global $wp_meta_boxes;
463
+		global $wp_meta_boxes;
464 464
 
465
-        $screen = 'formidable_page_formidable-styles';
466
-        $screen = convert_to_screen( $screen );
465
+		$screen = 'formidable_page_formidable-styles';
466
+		$screen = convert_to_screen( $screen );
467 467
 
468
-    	$page = $screen->id;
468
+		$page = $screen->id;
469 469
 
470
-    	$hidden = get_hidden_meta_boxes( $screen );
471
-    	?>
470
+		$hidden = get_hidden_meta_boxes( $screen );
471
+		?>
472 472
     	<div id="side-sortables" class="accordion-container">
473 473
     	<?php
474
-    	$i = 0;
475
-    	$first_open = false;
476
-    	do {
474
+		$i = 0;
475
+		$first_open = false;
476
+		do {
477 477
 			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
478 478
 				break;
479 479
 			}
480 480
 
481
-    		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
-    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
-    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
-    					if ( false == $box || ! $box['title'] ) {
485
-    						continue;
481
+			foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
482
+				if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
483
+					foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
484
+						if ( false == $box || ! $box['title'] ) {
485
+							continue;
486 486
 						}
487 487
 
488
-    					$i++;
489
-    					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
488
+						$i++;
489
+						$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
490 490
 
491
-    					if ( ! $first_open && empty( $hidden_class ) ) {
492
-    						$first_open = true;
493
-    					}
491
+						if ( ! $first_open && empty( $hidden_class ) ) {
492
+							$first_open = true;
493
+						}
494 494
 
495
-    					?>
495
+						?>
496 496
 						<div class="postbox <?php echo esc_attr( $box['id'] ); ?>">
497 497
 						<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div>
498 498
                         <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3>
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
     						</div><!-- .accordion-section-content -->
504 504
     					</div><!-- .postbox -->
505 505
     					<?php
506
-    				}
507
-    			}
508
-    		}
509
-    	} while ( 0 );
510
-    	?>
506
+					}
507
+				}
508
+			}
509
+		} while ( 0 );
510
+		?>
511 511
     	</div><!-- .accordion-container -->
512 512
     	<?php
513
-    	return $i;
514
-    }
513
+		return $i;
514
+	}
515 515
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -5,68 +5,68 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        global $frm_vars;
10
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		global $frm_vars;
10
+		$values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
-        }
14
-
15
-        $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
18
-        }
19
-
20
-        foreach ( (array) $fields as $field ) {
21
-            $new_value = self::get_field_value_for_new_entry( $field, $reset );
22
-
23
-            $field_array = array(
24
-                'id' => $field->id,
25
-                'value' => $new_value,
26
-                'default_value' => $field->default_value,
27
-                'name' => $field->name,
28
-                'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
-                'options' => $field->options,
31
-                'required' => $field->required,
32
-                'field_key' => $field->field_key,
33
-                'field_order' => $field->field_order,
34
-                'form_id' => $field->form_id,
12
+			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
+		}
14
+
15
+		$values['fields'] = array();
16
+		if ( empty($fields) ) {
17
+			return apply_filters('frm_setup_new_entry', $values);
18
+		}
19
+
20
+		foreach ( (array) $fields as $field ) {
21
+			$new_value = self::get_field_value_for_new_entry( $field, $reset );
22
+
23
+			$field_array = array(
24
+				'id' => $field->id,
25
+				'value' => $new_value,
26
+				'default_value' => $field->default_value,
27
+				'name' => $field->name,
28
+				'description' => $field->description,
29
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
+				'options' => $field->options,
31
+				'required' => $field->required,
32
+				'field_key' => $field->field_key,
33
+				'field_order' => $field->field_order,
34
+				'form_id' => $field->form_id,
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36
-            );
36
+			);
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
-            $opt_defaults['required_indicator'] = '';
38
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+			$opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
45
-            }
43
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
+				unset($opt, $default_opt);
45
+			}
46 46
 
47
-            unset($opt_defaults);
47
+			unset($opt_defaults);
48 48
 
49
-            if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
-            }
49
+			if ( $field_array['custom_html'] == '' ) {
50
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+			}
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
-            $field_array = array_merge( $field->field_options, $field_array );
53
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
+			$field_array = array_merge( $field->field_options, $field_array );
55 55
 
56
-            $values['fields'][] = $field_array;
56
+			$values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
60
-            }
61
-        }
58
+			if ( ! $form || ! isset($form->id) ) {
59
+				$form = FrmForm::getOne($field->form_id);
60
+			}
61
+		}
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
65
-            foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
68
-            }
69
-        }
63
+		$form->options = maybe_unserialize($form->options);
64
+		if ( is_array($form->options) ) {
65
+			foreach ( $form->options as $opt => $value ) {
66
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
+				unset($opt, $value);
68
+			}
69
+		}
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
78 78
 		return apply_filters( 'frm_setup_new_entry', $values );
79
-    }
79
+	}
80 80
 
81 81
 	/**
82
-	* Set the value for each field
83
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
84
-	*
85
-	* @since 2.0.13
86
-	*
87
-	* @param object $field - this is passed by reference since it is an object
88
-	* @param boolean $reset
89
-	* @return string|array $new_value
90
-	*/
82
+	 * Set the value for each field
83
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
84
+	 *
85
+	 * @since 2.0.13
86
+	 *
87
+	 * @param object $field - this is passed by reference since it is an object
88
+	 * @param boolean $reset
89
+	 * @return string|array $new_value
90
+	 */
91 91
 	private static function get_field_value_for_new_entry( $field, $reset ) {
92 92
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 
119 119
 	public static function setup_edit_vars( $values, $record ) {
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121
-        $values['form_id'] = $record->form_id;
122
-        $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
-    }
121
+		$values['form_id'] = $record->form_id;
122
+		$values['is_draft'] = $record->is_draft;
123
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
+	}
125 125
 
126
-    public static function get_admin_params( $form = null ) {
126
+	public static function get_admin_params( $form = null ) {
127 127
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
128 128
 		return FrmForm::set_current_form( $form );
129
-    }
129
+	}
130 130
 
131 131
 	public static function set_current_form( $form_id ) {
132 132
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -138,280 +138,280 @@  discard block
 block discarded – undo
138 138
 		return FrmForm::get_current_form( $form_id );
139 139
 	}
140 140
 
141
-    public static function get_current_form_id() {
141
+	public static function get_current_form_id() {
142 142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
143 143
 		return FrmForm::get_current_form_id();
144
-    }
144
+	}
145 145
 
146
-    public static function maybe_get_entry( &$entry ) {
146
+	public static function maybe_get_entry( &$entry ) {
147 147
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
148 148
 		FrmEntry::maybe_get_entry( $entry );
149
-    }
149
+	}
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
154
-            ! empty( $message ) ) {
155
-            return $message;
156
-        }
157
-
158
-        if ( empty($message) ) {
159
-            $message = '[default-message]';
160
-        }
161
-
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
-
164
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
-            if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
168
-            } else {
169
-                $this_atts = $atts;
170
-            }
152
+		if ( strpos($message, '[default-message') === false &&
153
+			strpos($message, '[default_message') === false &&
154
+			! empty( $message ) ) {
155
+			return $message;
156
+		}
157
+
158
+		if ( empty($message) ) {
159
+			$message = '[default-message]';
160
+		}
161
+
162
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
+
164
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
165
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
+			if ( $add_atts ) {
167
+				$this_atts = array_merge($atts, $add_atts);
168
+			} else {
169
+				$this_atts = $atts;
170
+			}
171 171
 
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174
-            // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
-        }
174
+			// Add the default message
175
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
+		}
177 177
 
178
-        return $message;
179
-    }
178
+		return $message;
179
+	}
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182 182
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
183
-        if ( FrmAppHelper::pro_is_installed() ) {
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185
-        }
185
+		}
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
189
-        }
187
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
+			return self::display_value($field_value, $field, $atts);
189
+		}
190 190
 
191
-        // this is an embeded form
192
-        $val = '';
191
+		// this is an embeded form
192
+		$val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
-            //this is a repeating section
194
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
+			//this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197
-        } else {
198
-            // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
197
+		} else {
198
+			// get all values for this field
199
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
200 200
 
201
-            if ( $child_values ) {
202
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
-	        }
204
-	    }
201
+			if ( $child_values ) {
202
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
+			}
204
+		}
205 205
 
206
-	    $field_value = array();
206
+		$field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
-            return $val;
210
-        }
208
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
+			return $val;
210
+		}
211 211
 
212
-        foreach ( $child_entries as $child_entry ) {
213
-            $atts['item_id'] = $child_entry->id;
214
-            $atts['post_id'] = $child_entry->post_id;
212
+		foreach ( $child_entries as $child_entry ) {
213
+			$atts['item_id'] = $child_entry->id;
214
+			$atts['post_id'] = $child_entry->post_id;
215 215
 
216
-            // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
216
+			// get the value for this field -- check for post values as well
217
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
218 218
 
219
-            if ( $entry_val ) {
220
-                // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
222
-            }
219
+			if ( $entry_val ) {
220
+				// foreach entry get display_value
221
+				$field_value[] = self::display_value($entry_val, $field, $atts);
222
+			}
223 223
 
224
-            unset($child_entry);
225
-        }
224
+			unset($child_entry);
225
+		}
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+		$val = implode(', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230
-        return $val;
231
-    }
230
+		return $val;
231
+	}
232 232
 
233
-    /**
234
-     * Prepare the saved value for display
235
-     * @return string
236
-     */
233
+	/**
234
+	 * Prepare the saved value for display
235
+	 * @return string
236
+	 */
237 237
 	public static function display_value( $value, $field, $atts = array() ) {
238 238
 
239
-        $defaults = array(
240
-            'type' => '', 'html' => false, 'show_filename' => true,
241
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
239
+		$defaults = array(
240
+			'type' => '', 'html' => false, 'show_filename' => true,
241
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
243 243
 			'return_array' => false,
244
-        );
244
+		);
245 245
 
246
-        $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
246
+		$atts = wp_parse_args( $atts, $defaults );
247
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
250
-            $field->field_options['post_field'] = '';
251
-        }
249
+		if ( ! isset($field->field_options['post_field']) ) {
250
+			$field->field_options['post_field'] = '';
251
+		}
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
254
-            $field->field_options['custom_field'] = '';
255
-        }
253
+		if ( ! isset($field->field_options['custom_field']) ) {
254
+			$field->field_options['custom_field'] = '';
255
+		}
256 256
 
257
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
-            $atts['pre_truncate'] = $atts['truncate'];
259
-            $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
257
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
+			$atts['pre_truncate'] = $atts['truncate'];
259
+			$atts['truncate'] = true;
260
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
-            $atts['truncate'] = $atts['pre_truncate'];
264
-        }
262
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
+			$atts['truncate'] = $atts['pre_truncate'];
264
+		}
265 265
 
266
-        if ( $value == '' ) {
267
-            return $value;
268
-        }
266
+		if ( $value == '' ) {
267
+			return $value;
268
+		}
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
271 271
 
272
-        $new_value = '';
272
+		$new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
275
-            foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
274
+		if ( is_array($value) && $atts['type'] != 'file' ) {
275
+			foreach ( $value as $val ) {
276
+				if ( is_array($val) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
279
-                    if ( $atts['type'] != 'data' ) {
280
-                        $new_value .= '<br/>';
281
-                    }
282
-                }
283
-                unset($val);
284
-            }
285
-        }
286
-
287
-        if ( ! empty($new_value) ) {
288
-            $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
291
-        }
292
-
293
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
295
-        }
278
+					$new_value .= implode($atts['sep'], $val);
279
+					if ( $atts['type'] != 'data' ) {
280
+						$new_value .= '<br/>';
281
+					}
282
+				}
283
+				unset($val);
284
+			}
285
+		}
286
+
287
+		if ( ! empty($new_value) ) {
288
+			$value = $new_value;
289
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+			$value = implode($atts['sep'], $value);
291
+		}
292
+
293
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
+			$value = FrmAppHelper::truncate($value, 50);
295
+		}
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
302
-    }
301
+		return apply_filters('frm_display_value', $value, $field, $atts);
302
+	}
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
305
-        // If validating a field with "other" opt, set back to prev value now
306
-        if ( isset( $args['other'] ) && $args['other'] ) {
307
-            $value = $args['temp_value'];
308
-        }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
311
-        } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
-        }
314
-    }
305
+		// If validating a field with "other" opt, set back to prev value now
306
+		if ( isset( $args['other'] ) && $args['other'] ) {
307
+			$value = $args['temp_value'];
308
+		}
309
+		if ( empty($args['parent_field_id']) ) {
310
+			$_POST['item_meta'][ $field->id ] = $value;
311
+		} else {
312
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
+		}
314
+	}
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
-        } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
-        }
324
-    }
325
-
326
-    /**
327
-    * Check if field has an "Other" option and if any other values are posted
328
-    *
329
-    * @since 2.0
330
-    *
331
-    * @param object $field
332
-    * @param string|array $value
333
-    * @param array $args
334
-    */
335
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
-        $args['other'] = false;
337
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
-            return;
339
-        }
340
-
341
-        // Get other value for fields in repeating section
342
-        self::set_other_repeating_vals( $field, $value, $args );
343
-
344
-        // Check if there are any posted "Other" values
319
+		if ( empty($args['parent_field_id']) ) {
320
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
+		} else {
322
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
+		}
324
+	}
325
+
326
+	/**
327
+	 * Check if field has an "Other" option and if any other values are posted
328
+	 *
329
+	 * @since 2.0
330
+	 *
331
+	 * @param object $field
332
+	 * @param string|array $value
333
+	 * @param array $args
334
+	 */
335
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
+		$args['other'] = false;
337
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
+			return;
339
+		}
340
+
341
+		// Get other value for fields in repeating section
342
+		self::set_other_repeating_vals( $field, $value, $args );
343
+
344
+		// Check if there are any posted "Other" values
345 345
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
346 346
 
347
-            // Save original value
348
-            $args['temp_value'] = $value;
349
-            $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
-
352
-            // Set the validation value now
353
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
354
-        }
355
-    }
356
-
357
-    /**
358
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
-    *
360
-    * @since 2.0
361
-    *
362
-    * @param object $field
363
-    * @param string|array $value
364
-    * @param array $args
365
-    */
366
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
-        if ( ! $args['parent_field_id'] ) {
368
-            return;
369
-        }
370
-
371
-        // Check if there are any other posted "other" values for this field
347
+			// Save original value
348
+			$args['temp_value'] = $value;
349
+			$args['other'] = true;
350
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
+
352
+			// Set the validation value now
353
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
354
+		}
355
+	}
356
+
357
+	/**
358
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
+	 *
360
+	 * @since 2.0
361
+	 *
362
+	 * @param object $field
363
+	 * @param string|array $value
364
+	 * @param array $args
365
+	 */
366
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
+		if ( ! $args['parent_field_id'] ) {
368
+			return;
369
+		}
370
+
371
+		// Check if there are any other posted "other" values for this field
372 372
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
373
-            // Save original value
374
-            $args['temp_value'] = $value;
375
-            $args['other'] = true;
376
-
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
-
379
-            // Set the validation value now
380
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
381
-        }
382
-    }
383
-
384
-    /**
385
-    * Modify value used for validation
386
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
-    * It also adds any text from the free text fields to the value
388
-    *
389
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
-    *
391
-    * @since 2.0
392
-    *
393
-    * @param string|array $value
394
-    * @param string|array $other_vals (usually of posted values)
395
-    * @param object $field
396
-    * @param array $args
397
-    */
398
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
-        // Checkboxes and multi-select dropdowns
400
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
402
-            $value = array_merge( $value, $other_vals );
403
-            $value = array_filter( $value );
404
-            if ( count( $value ) == 0 ) {
405
-                $value = '';
406
-            }
407
-        } else {
373
+			// Save original value
374
+			$args['temp_value'] = $value;
375
+			$args['other'] = true;
376
+
377
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
+
379
+			// Set the validation value now
380
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
381
+		}
382
+	}
383
+
384
+	/**
385
+	 * Modify value used for validation
386
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
+	 * It also adds any text from the free text fields to the value
388
+	 *
389
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
+	 *
391
+	 * @since 2.0
392
+	 *
393
+	 * @param string|array $value
394
+	 * @param string|array $other_vals (usually of posted values)
395
+	 * @param object $field
396
+	 * @param array $args
397
+	 */
398
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
+		// Checkboxes and multi-select dropdowns
400
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
402
+			$value = array_merge( $value, $other_vals );
403
+			$value = array_filter( $value );
404
+			if ( count( $value ) == 0 ) {
405
+				$value = '';
406
+			}
407
+		} else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
410
-            $other_key = reset( $other_key );
409
+			$other_key = array_filter( array_keys($field->options), 'is_string');
410
+			$other_key = reset( $other_key );
411 411
 
412
-            // Multi-select dropdown
413
-            if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
412
+			// Multi-select dropdown
413
+			if ( is_array( $value ) ) {
414
+				$o_key = array_search( $field->options[ $other_key ], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
 					$args['temp_value'] = $value;
427 427
 					$value[ $other_key ] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
430
-                $value = $other_vals;
431
-            }
432
-        }
433
-    }
429
+			} else if ( $field->options[ $other_key ] == $value ) {
430
+				$value = $other_vals;
431
+			}
432
+		}
433
+	}
434 434
 
435 435
 	public static function enqueue_scripts( $params ) {
436 436
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
437 437
 		return FrmFormsController::enqueue_scripts( $params );
438 438
 	}
439 439
 
440
-    // Add submitted values to a string for spam checking
440
+	// Add submitted values to a string for spam checking
441 441
 	public static function entry_array_to_string( $values ) {
442
-        $content = '';
442
+		$content = '';
443 443
 		foreach ( $values['item_meta'] as $val ) {
444 444
 			if ( $content != '' ) {
445 445
 				$content .= "\n\n";
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 
448 448
 			if ( is_array($val) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+				$val = implode(',', $val);
451 451
 			}
452 452
 
453 453
 			$content .= $val;
454 454
 		}
455 455
 
456 456
 		return $content;
457
-    }
457
+	}
458 458
 
459 459
 	public static function fill_entry_values( $atts, $f, array &$values ) {
460 460
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
         global $frm_vars;
10 10
         $values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
12
+            $values[$var] = FrmAppHelper::get_post_param( $var, $default );
13 13
         }
14 14
 
15 15
         $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
16
+        if ( empty( $fields ) ) {
17
+            return apply_filters( 'frm_setup_new_entry', $values );
18 18
         }
19 19
 
20 20
         foreach ( (array) $fields as $field ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 'default_value' => $field->default_value,
27 27
                 'name' => $field->name,
28 28
                 'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
30 30
                 'options' => $field->options,
31 31
                 'required' => $field->required,
32 32
                 'field_key' => $field->field_key,
@@ -35,43 +35,43 @@  discard block
 block discarded – undo
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36 36
             );
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
38
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
39 39
             $opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
43
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
44
+                unset( $opt, $default_opt );
45 45
             }
46 46
 
47
-            unset($opt_defaults);
47
+            unset( $opt_defaults );
48 48
 
49 49
             if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
50
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
51 51
             }
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
53
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field );
54 54
             $field_array = array_merge( $field->field_options, $field_array );
55 55
 
56 56
             $values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
58
+            if ( ! $form || ! isset( $form->id ) ) {
59
+                $form = FrmForm::getOne( $field->form_id );
60 60
             }
61 61
         }
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
63
+        $form->options = maybe_unserialize( $form->options );
64
+        if ( is_array( $form->options ) ) {
65 65
             foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
66
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
67
+                unset( $opt, $value );
68 68
             }
69 69
         }
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
73 73
 		$frm_settings = FrmAppHelper::get_settings();
74
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
74
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
75 75
 
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
94 94
 
95 95
 		// Do any shortcodes in default value and allow customization of default value
96
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
96
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
97 97
 		// Calls FrmProFieldsHelper::get_default_value
98 98
 
99 99
 		$new_value = $field->default_value;
100 100
 
101
-		if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) {
101
+		if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) {
102 102
 			// If value was posted, get it
103 103
 
104
-			$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
104
+			$new_value = stripslashes_deep( $_POST['item_meta'][$field->id] );
105 105
 
106 106
 		} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
107 107
 			// If clear on focus is selected, the value should be blank (unless it was posted, of course)
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		if ( ! is_array( $new_value ) ) {
113
-			$new_value = str_replace('"', '&quot;', $new_value);
113
+			$new_value = str_replace( '"', '&quot;', $new_value );
114 114
 		}
115 115
 
116 116
 		return $new_value;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121 121
         $values['form_id'] = $record->form_id;
122 122
         $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
123
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
124 124
     }
125 125
 
126 126
     public static function get_admin_params( $form = null ) {
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
152
+        if ( strpos( $message, '[default-message' ) === false &&
153
+            strpos( $message, '[default_message' ) === false &&
154 154
             ! empty( $message ) ) {
155 155
             return $message;
156 156
         }
157 157
 
158
-        if ( empty($message) ) {
158
+        if ( empty( $message ) ) {
159 159
             $message = '[default-message]';
160 160
         }
161 161
 
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
162
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
163 163
 
164 164
         foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
165
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
166 166
             if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
167
+                $this_atts = array_merge( $atts, $add_atts );
168 168
             } else {
169 169
                 $this_atts = $atts;
170 170
             }
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174 174
             // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
175
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
176 176
         }
177 177
 
178 178
         return $message;
179 179
     }
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
182
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
183 183
         if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185 185
         }
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
187
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
188
+            return self::display_value( $field_value, $field, $atts );
189 189
         }
190 190
 
191 191
         // this is an embeded form
192 192
         $val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
194
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
195 195
             //this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197 197
         } else {
198 198
             // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
199
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
200 200
 
201 201
             if ( $child_values ) {
202 202
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 	    $field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
208
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 209
             return $val;
210 210
         }
211 211
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
             $atts['post_id'] = $child_entry->post_id;
215 215
 
216 216
             // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
217
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
218 218
 
219 219
             if ( $entry_val ) {
220 220
                 // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
221
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
222 222
             }
223 223
 
224
-            unset($child_entry);
224
+            unset( $child_entry );
225 225
         }
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+        $val = implode( ', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230 230
         return $val;
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
         );
245 245
 
246 246
         $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
247
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
249
+        if ( ! isset( $field->field_options['post_field'] ) ) {
250 250
             $field->field_options['post_field'] = '';
251 251
         }
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
253
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
254 254
             $field->field_options['custom_field'] = '';
255 255
         }
256 256
 
257 257
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258 258
             $atts['pre_truncate'] = $atts['truncate'];
259 259
             $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
260
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
262
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
263 263
             $atts['truncate'] = $atts['pre_truncate'];
264 264
         }
265 265
 
@@ -267,38 +267,38 @@  discard block
 block discarded – undo
267 267
             return $value;
268 268
         }
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
271 271
 
272 272
         $new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
274
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
275 275
             foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
276
+                if ( is_array( $val ) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
278
+                    $new_value .= implode( $atts['sep'], $val );
279 279
                     if ( $atts['type'] != 'data' ) {
280 280
                         $new_value .= '<br/>';
281 281
                     }
282 282
                 }
283
-                unset($val);
283
+                unset( $val );
284 284
             }
285 285
         }
286 286
 
287
-        if ( ! empty($new_value) ) {
287
+        if ( ! empty( $new_value ) ) {
288 288
             $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
289
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+            $value = implode( $atts['sep'], $value );
291 291
         }
292 292
 
293 293
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
294
+            $value = FrmAppHelper::truncate( $value, 50 );
295 295
         }
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
301
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
302 302
     }
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
         if ( isset( $args['other'] ) && $args['other'] ) {
307 307
             $value = $args['temp_value'];
308 308
         }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
309
+        if ( empty( $args['parent_field_id'] ) ) {
310
+            $_POST['item_meta'][$field->id] = $value;
311 311
         } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
312
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
313 313
         }
314 314
     }
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
319
+        if ( empty( $args['parent_field_id'] ) ) {
320
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
321 321
         } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
322
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
323 323
         }
324 324
     }
325 325
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
         self::set_other_repeating_vals( $field, $value, $args );
343 343
 
344 344
         // Check if there are any posted "Other" values
345
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
345
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
346 346
 
347 347
             // Save original value
348 348
             $args['temp_value'] = $value;
349 349
             $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
350
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
351 351
 
352 352
             // Set the validation value now
353 353
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
         }
370 370
 
371 371
         // Check if there are any other posted "other" values for this field
372
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
372
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
373 373
             // Save original value
374 374
             $args['temp_value'] = $value;
375 375
             $args['other'] = true;
376 376
 
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
377
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
378 378
 
379 379
             // Set the validation value now
380 380
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -406,27 +406,27 @@  discard block
 block discarded – undo
406 406
             }
407 407
         } else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
409
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
410 410
             $other_key = reset( $other_key );
411 411
 
412 412
             // Multi-select dropdown
413 413
             if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
414
+                $o_key = array_search( $field->options[$other_key], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
418
-					$value[ $other_key ] = $value[ $o_key ];
418
+					$value[$other_key] = $value[$o_key];
419 419
 
420 420
 					// By default, the array keys will be numeric for multi-select dropdowns
421 421
 					// If going backwards and forwards between pages, the array key will match the other key
422 422
 					if ( $o_key != $other_key ) {
423
-						unset( $value[ $o_key ] );
423
+						unset( $value[$o_key] );
424 424
 					}
425 425
 
426 426
 					$args['temp_value'] = $value;
427
-					$value[ $other_key ] = reset( $other_vals );
427
+					$value[$other_key] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
429
+            } else if ( $field->options[$other_key] == $value ) {
430 430
                 $value = $other_vals;
431 431
             }
432 432
         }
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 				$content .= "\n\n";
446 446
 			}
447 447
 
448
-			if ( is_array($val) ) {
448
+			if ( is_array( $val ) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+			    $val = implode( ',', $val );
451 451
 			}
452 452
 
453 453
 			$content .= $val;
@@ -492,6 +492,6 @@  discard block
 block discarded – undo
492 492
 	}
493 493
 
494 494
 	public static function entries_dropdown() {
495
-		_deprecated_function( __FUNCTION__, '1.07.09');
495
+		_deprecated_function( __FUNCTION__, '1.07.09' );
496 496
 	}
497 497
 }
Please login to merge, or discard this patch.