Completed
Push — master ( 96a26a...ed722f )
by Jamie
03:45
created
classes/views/frm-fields/show-build.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,32 +3,32 @@
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
     <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
5 5
 		echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : '';
6
-    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
6
+	?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
7 7
 
8 8
 <?php
9 9
 
10 10
 } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
11
-    $field['default_value'] = maybe_unserialize($field['default_value']);
12
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
11
+	$field['default_value'] = maybe_unserialize($field['default_value']);
12
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
13 13
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
14
-    } else {
15
-        do_action('frm_add_multiple_opts_labels', $field); ?>
14
+	} else {
15
+		do_action('frm_add_multiple_opts_labels', $field); ?>
16 16
         <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>">
17 17
 			<?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?>
18 18
         </ul>
19 19
     <?php
20
-    }
20
+	}
21 21
 } else if ( $field['type'] == 'select' ) {
22 22
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' );
23 23
 } else if ( $field['type'] == 'captcha' ) {
24 24
 	if ( empty($frm_settings->pubkey) ) { ?>
25 25
     <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
26 26
     <?php
27
-    } ?>
27
+	} ?>
28 28
 	<img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
29 29
     <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" />
30 30
 <?php
31 31
 } else {
32
-    do_action( 'frm_display_added_fields', $field );
32
+	do_action( 'frm_display_added_fields', $field );
33 33
 	do_action( 'frm_display_added_' . $field['type'] . '_field', $field );
34 34
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
     <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
5 5
 		echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : '';
6
-    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
6
+    ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea>
7 7
 
8 8
 <?php
9 9
 
10 10
 } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
11
-    $field['default_value'] = maybe_unserialize($field['default_value']);
12
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
11
+    $field['default_value'] = maybe_unserialize( $field['default_value'] );
12
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
13 13
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
14 14
     } else {
15
-        do_action('frm_add_multiple_opts_labels', $field); ?>
16
-        <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>">
15
+        do_action( 'frm_add_multiple_opts_labels', $field ); ?>
16
+        <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
17 17
 			<?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?>
18 18
         </ul>
19 19
     <?php
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 } else if ( $field['type'] == 'select' ) {
22 22
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' );
23 23
 } else if ( $field['type'] == 'captcha' ) {
24
-	if ( empty($frm_settings->pubkey) ) { ?>
25
-    <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div>
24
+	if ( empty( $frm_settings->pubkey ) ) { ?>
25
+    <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div>
26 26
     <?php
27 27
     } ?>
28 28
 	<img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/>
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        global $wpdb;
4
+	public static function validate( $values, $exclude = false ) {
5
+		global $wpdb;
6 6
 
7
-        FrmEntry::sanitize_entry_post( $values );
8
-        $errors = array();
7
+		FrmEntry::sanitize_entry_post( $values );
8
+		$errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
-            return $errors;
13
-        }
10
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
11
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12
+			return $errors;
13
+		}
14 14
 
15 15
 		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
16
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
-        }
16
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17
+		}
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+		if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21
-        }
21
+		}
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+		$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,42 +28,42 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+		$posted_fields = FrmField::getAll($where, 'field_order');
32 32
 
33
-        // Pass exclude value to validate_field function so it can be used for repeating sections
34
-        $args = array( 'exclude' => $exclude );
33
+		// Pass exclude value to validate_field function so it can be used for repeating sections
34
+		$args = array( 'exclude' => $exclude );
35 35
 
36
-        foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
39
-        }
36
+		foreach ( $posted_fields as $posted_field ) {
37
+			self::validate_field($posted_field, $errors, $values, $args);
38
+			unset($posted_field);
39
+		}
40 40
 
41
-        // check for spam
42
-        self::spam_check( $exclude, $values, $errors );
41
+		// check for spam
42
+		self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+		$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
45 45
 
46
-        return $errors;
47
-    }
46
+		return $errors;
47
+	}
48 48
 
49
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
-        $defaults = array(
51
-            'id'              => $posted_field->id,
52
-            'parent_field_id' => '', // the id of the repeat or embed form
53
-            'key_pointer'     => '', // the pointer in the posted array
54
-            'exclude'         => array(), // exclude these field types from validation
55
-        );
56
-        $args = wp_parse_args( $args, $defaults );
49
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
50
+		$defaults = array(
51
+			'id'              => $posted_field->id,
52
+			'parent_field_id' => '', // the id of the repeat or embed form
53
+			'key_pointer'     => '', // the pointer in the posted array
54
+			'exclude'         => array(), // exclude these field types from validation
55
+		);
56
+		$args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
58
+		if ( empty($args['parent_field_id']) ) {
59 59
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
60
-        } else {
61
-            // value is from a nested form
62
-            $value = $values;
63
-        }
60
+		} else {
61
+			// value is from a nested form
62
+			$value = $values;
63
+		}
64 64
 
65
-        // Check for values in "Other" fields
66
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
65
+		// Check for values in "Other" fields
66
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 			$value = reset($value);
73 73
 		}
74 74
 
75
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
75
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76 76
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78
-            $_POST['item_name'] = $value;
79
-        }
77
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78
+			$_POST['item_name'] = $value;
79
+		}
80 80
 
81 81
 		if ( $value != '' ) {
82 82
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
86 86
 		}
87 87
 
88
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
88
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
89 89
 
90
-        self::validate_recaptcha($errors, $posted_field, $args);
90
+		self::validate_recaptcha($errors, $posted_field, $args);
91 91
 
92 92
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
93 93
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
94
-    }
94
+	}
95 95
 
96 96
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
97 97
 		if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) {
@@ -101,32 +101,32 @@  discard block
 block discarded – undo
101 101
 
102 102
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
103 103
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
104
-            return;
105
-        }
104
+			return;
105
+		}
106 106
 
107
-        if ( trim($value) == 'http://' ) {
108
-            $value = '';
109
-        } else {
110
-            $value = esc_url_raw( $value );
107
+		if ( trim($value) == 'http://' ) {
108
+			$value = '';
109
+		} else {
110
+			$value = esc_url_raw( $value );
111 111
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
112
-        }
112
+		}
113 113
 
114
-        // validate the url format
114
+		// validate the url format
115 115
 		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
116 116
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
117 117
 		}
118
-    }
118
+	}
119 119
 
120 120
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
121
-        if ( $value == '' || $field->type != 'email' ) {
122
-            return;
123
-        }
121
+		if ( $value == '' || $field->type != 'email' ) {
122
+			return;
123
+		}
124 124
 
125
-        //validate the email format
126
-        if ( ! is_email($value) ) {
125
+		//validate the email format
126
+		if ( ! is_email($value) ) {
127 127
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
128
-        }
129
-    }
128
+		}
129
+	}
130 130
 
131 131
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
132 132
 		//validate the number format
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	}
221 221
 
222 222
 	public static function validate_recaptcha( &$errors, $field, $args ) {
223
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
224
-            return;
225
-        }
223
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
224
+			return;
225
+		}
226 226
 
227 227
 		$frm_settings = FrmAppHelper::get_settings();
228 228
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -230,57 +230,57 @@  discard block
 block discarded – undo
230 230
 			return;
231 231
 		}
232 232
 
233
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
234
-            // If captcha is missing, check if it was already verified
233
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
234
+			// If captcha is missing, check if it was already verified
235 235
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
236
-                // There was no captcha submitted
236
+				// There was no captcha submitted
237 237
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
238
-            }
239
-            return;
240
-        }
238
+			}
239
+			return;
240
+		}
241 241
 
242
-        $arg_array = array(
243
-            'body'      => array(
242
+		$arg_array = array(
243
+			'body'      => array(
244 244
 				'secret'   => $frm_settings->privkey,
245 245
 				'response' => $_POST['g-recaptcha-response'],
246 246
 				'remoteip' => FrmAppHelper::get_ip_address(),
247 247
 			),
248 248
 		);
249
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
249
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
251 251
 
252
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
253
-            // What happens when the CAPTCHA was entered incorrectly
252
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
253
+			// What happens when the CAPTCHA was entered incorrectly
254 254
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
255
-        } else if ( is_wp_error( $resp ) ) {
255
+		} else if ( is_wp_error( $resp ) ) {
256 256
 			$error_string = $resp->get_error_message();
257 257
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258 258
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
259
-        }
260
-    }
261
-
262
-    /**
263
-     * check for spam
264
-     * @param boolean $exclude
265
-     * @param array $values
266
-     * @param array $errors by reference
267
-     */
268
-    public static function spam_check( $exclude, $values, &$errors ) {
269
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
270
-            // only check spam if there are no other errors
271
-            return;
272
-        }
273
-
274
-        if ( self::is_akismet_spam( $values ) ) {
259
+		}
260
+	}
261
+
262
+	/**
263
+	 * check for spam
264
+	 * @param boolean $exclude
265
+	 * @param array $values
266
+	 * @param array $errors by reference
267
+	 */
268
+	public static function spam_check( $exclude, $values, &$errors ) {
269
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
270
+			// only check spam if there are no other errors
271
+			return;
272
+		}
273
+
274
+		if ( self::is_akismet_spam( $values ) ) {
275 275
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
276 276
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
277 277
 			}
278
-	    }
278
+		}
279 279
 
280
-    	if ( self::blacklist_check( $values ) ) {
281
-            $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
282
-    	}
283
-    }
280
+		if ( self::blacklist_check( $values ) ) {
281
+			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
282
+		}
283
+	}
284 284
 
285 285
 	private static function is_akismet_spam( $values ) {
286 286
 		global $wpcom_api_key;
@@ -292,54 +292,54 @@  discard block
 block discarded – undo
292 292
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
293 293
 	}
294 294
 
295
-    public static function blacklist_check( $values ) {
296
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
297
-            return false;
298
-        }
295
+	public static function blacklist_check( $values ) {
296
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
297
+			return false;
298
+		}
299 299
 
300
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
300
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
301 301
 
302
-    	if ( empty( $mod_keys ) ) {
303
-    		return false;
304
-    	}
302
+		if ( empty( $mod_keys ) ) {
303
+			return false;
304
+		}
305 305
 
306
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
306
+		$content = FrmEntriesHelper::entry_array_to_string($values);
307 307
 
308 308
 		if ( empty($content) ) {
309
-		    return false;
309
+			return false;
310 310
 		}
311 311
 
312
-    	$words = explode( "\n", $mod_keys );
312
+		$words = explode( "\n", $mod_keys );
313 313
 
314
-    	foreach ( (array) $words as $word ) {
315
-    		$word = trim( $word );
314
+		foreach ( (array) $words as $word ) {
315
+			$word = trim( $word );
316 316
 
317
-    		if ( empty($word) ) {
318
-    			continue;
319
-    		}
317
+			if ( empty($word) ) {
318
+				continue;
319
+			}
320 320
 
321
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
322
-    			return true;
323
-    		}
324
-    	}
321
+			if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
322
+				return true;
323
+			}
324
+		}
325 325
 
326
-    	return false;
327
-    }
326
+		return false;
327
+	}
328 328
 
329
-    /**
330
-     * Check entries for spam
331
-     *
332
-     * @return boolean true if is spam
333
-     */
334
-    public static function akismet( $values ) {
335
-	    $content = FrmEntriesHelper::entry_array_to_string( $values );
329
+	/**
330
+	 * Check entries for spam
331
+	 *
332
+	 * @return boolean true if is spam
333
+	 */
334
+	public static function akismet( $values ) {
335
+		$content = FrmEntriesHelper::entry_array_to_string( $values );
336 336
 
337 337
 		if ( empty( $content ) ) {
338
-		    return false;
338
+			return false;
339 339
 		}
340 340
 
341
-        $datas = array();
342
-        self::parse_akismet_array( $datas, $content );
341
+		$datas = array();
342
+		self::parse_akismet_array( $datas, $content );
343 343
 
344 344
 		$query_string = '';
345 345
 		foreach ( $datas as $key => $data ) {
@@ -347,35 +347,35 @@  discard block
 block discarded – undo
347 347
 			unset( $key, $data );
348 348
 		}
349 349
 
350
-        $response = Akismet::http_post($query_string, 'comment-check');
350
+		$response = Akismet::http_post($query_string, 'comment-check');
351 351
 
352 352
 		return ( is_array( $response ) && $response[1] == 'true' );
353
-    }
354
-
355
-    /**
356
-     * @since 2.0
357
-     * @param string $content
358
-     */
359
-    private  static function parse_akismet_array( &$datas, $content ) {
360
-        $datas['blog'] = FrmAppHelper::site_url();
361
-        $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
353
+	}
354
+
355
+	/**
356
+	 * @since 2.0
357
+	 * @param string $content
358
+	 */
359
+	private  static function parse_akismet_array( &$datas, $content ) {
360
+		$datas['blog'] = FrmAppHelper::site_url();
361
+		$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
362 362
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
363 363
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
364
-        $datas['comment_type'] = 'formidable';
365
-        $datas['comment_content'] = $content;
364
+		$datas['comment_type'] = 'formidable';
365
+		$datas['comment_content'] = $content;
366 366
 
367
-        if ( $permalink = get_permalink() ) {
368
-            $datas['permalink'] = $permalink;
369
-        }
367
+		if ( $permalink = get_permalink() ) {
368
+			$datas['permalink'] = $permalink;
369
+		}
370 370
 
371
-        foreach ( $_SERVER as $key => $value ) {
371
+		foreach ( $_SERVER as $key => $value ) {
372 372
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
373 373
 				$datas[ $key ] = wp_strip_all_tags( $value );
374
-            } else {
374
+			} else {
375 375
 				$datas[ $key ] = '';
376
-            }
376
+			}
377 377
 
378
-            unset($key, $value);
379
-        }
380
-    }
378
+			unset($key, $value);
379
+		}
380
+	}
381 381
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
         FrmEntry::sanitize_entry_post( $values );
8 8
         $errors = array();
9 9
 
10
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
10
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
11 11
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
12 12
             return $errors;
13 13
         }
14 14
 
15
-		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
15
+		if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) {
16 16
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
17 17
         }
18 18
 
19
-        if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
19
+        if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) {
20 20
 			$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' );
21 21
         }
22 22
 
23
-        $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
23
+        $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
24 24
 		// Don't get subfields
25 25
 		$where['fr.parent_form_id'] = array( null, 0 );
26 26
 		// Don't get excluded fields (like file upload fields in the ajax validation)
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 			$where['fi.type not'] = $exclude;
29 29
 		}
30 30
 
31
-        $posted_fields = FrmField::getAll($where, 'field_order');
31
+        $posted_fields = FrmField::getAll( $where, 'field_order' );
32 32
 
33 33
         // Pass exclude value to validate_field function so it can be used for repeating sections
34 34
         $args = array( 'exclude' => $exclude );
35 35
 
36 36
         foreach ( $posted_fields as $posted_field ) {
37
-            self::validate_field($posted_field, $errors, $values, $args);
38
-            unset($posted_field);
37
+            self::validate_field( $posted_field, $errors, $values, $args );
38
+            unset( $posted_field );
39 39
         }
40 40
 
41 41
         // check for spam
42 42
         self::spam_check( $exclude, $values, $errors );
43 43
 
44
-        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
44
+        $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) );
45 45
 
46 46
         return $errors;
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         );
56 56
         $args = wp_parse_args( $args, $defaults );
57 57
 
58
-        if ( empty($args['parent_field_id']) ) {
59
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
58
+        if ( empty( $args['parent_field_id'] ) ) {
59
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
60 60
         } else {
61 61
             // value is from a nested form
62 62
             $value = $values;
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
69 69
 
70 70
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
71
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
72
-			$value = reset($value);
71
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
72
+			$value = reset( $value );
73 73
 		}
74 74
 
75 75
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
76
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
76
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
77 77
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
78 78
             $_POST['item_name'] = $value;
79 79
         }
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
86 86
 		}
87 87
 
88
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
88
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
89 89
 
90
-        self::validate_recaptcha($errors, $posted_field, $args);
90
+        self::validate_recaptcha( $errors, $posted_field, $args );
91 91
 
92 92
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
93 93
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             return;
105 105
         }
106 106
 
107
-        if ( trim($value) == 'http://' ) {
107
+        if ( trim( $value ) == 'http://' ) {
108 108
             $value = '';
109 109
         } else {
110 110
             $value = esc_url_raw( $value );
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         // validate the url format
115
-		if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) {
116
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
115
+		if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
116
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
117 117
 		}
118 118
     }
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         //validate the email format
126
-        if ( ! is_email($value) ) {
127
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
126
+        if ( ! is_email( $value ) ) {
127
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
128 128
         }
129 129
     }
130 130
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 			return;
135 135
 		}
136 136
 
137
-		if ( ! is_numeric( $value) ) {
138
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
137
+		if ( ! is_numeric( $value ) ) {
138
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
139 139
 		}
140 140
 
141 141
 		// validate number settings
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
146 146
 				//minnum maxnum
147 147
 				if ( (float) $value < $field->field_options['minnum'] ) {
148
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
148
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
149 149
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
150
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
150
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
151 151
 				}
152 152
 			}
153 153
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			$pattern = self::phone_format( $field );
160 160
 
161 161
 			if ( ! preg_match( $pattern, $value ) ) {
162
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
162
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
163 163
 			}
164 164
 		}
165 165
 	}
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 			return;
231 231
 		}
232 232
 
233
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
233
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
234 234
             // If captcha is missing, check if it was already verified
235 235
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
236 236
                 // There was no captcha submitted
237
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
237
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
238 238
             }
239 239
             return;
240 240
         }
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 			),
248 248
 		);
249 249
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
250
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
250
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
251 251
 
252 252
         if ( isset( $response['success'] ) && ! $response['success'] ) {
253 253
             // What happens when the CAPTCHA was entered incorrectly
254
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
254
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
255 255
         } else if ( is_wp_error( $resp ) ) {
256 256
 			$error_string = $resp->get_error_message();
257
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
257
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
258
+			$errors['field' . $args['id']] .= ' ' . $error_string;
259 259
         }
260 260
     }
261 261
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 	private static function is_akismet_spam( $values ) {
286 286
 		global $wpcom_api_key;
287
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
287
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
288 288
 	}
289 289
 
290 290
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
     public static function blacklist_check( $values ) {
296
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
296
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
297 297
             return false;
298 298
         }
299 299
 
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
     		return false;
304 304
     	}
305 305
 
306
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
306
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
307 307
 
308
-		if ( empty($content) ) {
308
+		if ( empty( $content ) ) {
309 309
 		    return false;
310 310
 		}
311 311
 
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
     	foreach ( (array) $words as $word ) {
315 315
     		$word = trim( $word );
316 316
 
317
-    		if ( empty($word) ) {
317
+    		if ( empty( $word ) ) {
318 318
     			continue;
319 319
     		}
320 320
 
321
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
321
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
322 322
     			return true;
323 323
     		}
324 324
     	}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			unset( $key, $data );
348 348
 		}
349 349
 
350
-        $response = Akismet::http_post($query_string, 'comment-check');
350
+        $response = Akismet::http_post( $query_string, 'comment-check' );
351 351
 
352 352
 		return ( is_array( $response ) && $response[1] == 'true' );
353 353
     }
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 
371 371
         foreach ( $_SERVER as $key => $value ) {
372 372
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
373
-				$datas[ $key ] = wp_strip_all_tags( $value );
373
+				$datas[$key] = wp_strip_all_tags( $value );
374 374
             } else {
375
-				$datas[ $key ] = '';
375
+				$datas[$key] = '';
376 376
             }
377 377
 
378
-            unset($key, $value);
378
+            unset( $key, $value );
379 379
         }
380 380
     }
381 381
 }
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 3 patches
Doc Comments   +11 added lines, -1 removed lines patch added patch discarded remove patch
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * Sanitize the value, and allow some HTML
357 357
 	 * @since 2.0
358 358
 	 * @param string $value
359
-	 * @param array $allowed
359
+	 * @param string[] $allowed
360 360
 	 * @return string
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
@@ -464,6 +464,7 @@  discard block
 block discarded – undo
464 464
 	/**
465 465
 	 * Keep track of the keys cached in each group so they can be deleted
466 466
 	 * in Redis and Memcache
467
+	 * @param string $group
467 468
 	 */
468 469
 	public static function add_key_to_group_cache( $key, $group ) {
469 470
 		$cached = self::get_group_cached_keys( $group );
@@ -787,6 +788,9 @@  discard block
 block discarded – undo
787 788
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
788 789
     }
789 790
 
791
+	/**
792
+	 * @param string $function
793
+	 */
790 794
 	public static function recursive_function_map( $value, $function ) {
791 795
 		if ( is_array( $value ) ) {
792 796
 			$original_function = $function;
@@ -1206,6 +1210,9 @@  discard block
 block discarded – undo
1206 1210
         return $sub . (($len < $original_len) ? $continue : '');
1207 1211
     }
1208 1212
 
1213
+	/**
1214
+	 * @param string[] $function_names
1215
+	 */
1209 1216
 	public static function mb_function( $function_names, $args ) {
1210 1217
 		$mb_function_name = $function_names[0];
1211 1218
 		$function_name = $function_names[1];
@@ -1239,6 +1246,9 @@  discard block
 block discarded – undo
1239 1246
         return $formatted;
1240 1247
     }
1241 1248
 
1249
+	/**
1250
+	 * @param string $time_format
1251
+	 */
1242 1252
 	private static function add_time_to_date( $time_format, $date ) {
1243 1253
 		if ( empty( $time_format ) ) {
1244 1254
 			$time_format = get_option('time_format');
Please login to merge, or discard this patch.
Indentation   +1034 added lines, -1034 removed lines patch added patch discarded remove patch
@@ -12,50 +12,50 @@  discard block
 block discarded – undo
12 12
 	 */
13 13
 	public static $plug_version = '2.02.06';
14 14
 
15
-    /**
16
-     * @since 1.07.02
17
-     *
18
-     * @param none
19
-     * @return string The version of this plugin
20
-     */
21
-    public static function plugin_version() {
22
-        return self::$plug_version;
23
-    }
24
-
25
-    public static function plugin_folder() {
26
-        return basename(self::plugin_path());
27
-    }
28
-
29
-    public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
31
-    }
32
-
33
-    public static function plugin_url() {
34
-        //prevously FRM_URL constant
15
+	/**
16
+	 * @since 1.07.02
17
+	 *
18
+	 * @param none
19
+	 * @return string The version of this plugin
20
+	 */
21
+	public static function plugin_version() {
22
+		return self::$plug_version;
23
+	}
24
+
25
+	public static function plugin_folder() {
26
+		return basename(self::plugin_path());
27
+	}
28
+
29
+	public static function plugin_path() {
30
+		return dirname(dirname(dirname(__FILE__)));
31
+	}
32
+
33
+	public static function plugin_url() {
34
+		//prevously FRM_URL constant
35 35
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
36
-    }
36
+	}
37 37
 
38 38
 	public static function relative_plugin_url() {
39 39
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
40 40
 	}
41 41
 
42
-    /**
43
-     * @return string Site URL
44
-     */
45
-    public static function site_url() {
46
-        return site_url();
47
-    }
48
-
49
-    /**
50
-     * Get the name of this site
51
-     * Used for [sitename] shortcode
52
-     *
53
-     * @since 2.0
54
-     * @return string
55
-     */
56
-    public static function site_name() {
57
-        return get_option('blogname');
58
-    }
42
+	/**
43
+	 * @return string Site URL
44
+	 */
45
+	public static function site_url() {
46
+		return site_url();
47
+	}
48
+
49
+	/**
50
+	 * Get the name of this site
51
+	 * Used for [sitename] shortcode
52
+	 *
53
+	 * @since 2.0
54
+	 * @return string
55
+	 */
56
+	public static function site_name() {
57
+		return get_option('blogname');
58
+	}
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
61 61
 		$affiliate_id = self::get_affiliate();
@@ -76,83 +76,83 @@  discard block
 block discarded – undo
76 76
 		return $affiliate_id;
77 77
 	}
78 78
 
79
-    /**
80
-     * Get the Formidable settings
81
-     *
82
-     * @since 2.0
83
-     *
84
-     * @param None
85
-     * @return FrmSettings $frm_setings
86
-     */
87
-    public static function get_settings() {
88
-        global $frm_settings;
89
-        if ( empty($frm_settings) ) {
90
-            $frm_settings = new FrmSettings();
91
-        }
92
-        return $frm_settings;
93
-    }
79
+	/**
80
+	 * Get the Formidable settings
81
+	 *
82
+	 * @since 2.0
83
+	 *
84
+	 * @param None
85
+	 * @return FrmSettings $frm_setings
86
+	 */
87
+	public static function get_settings() {
88
+		global $frm_settings;
89
+		if ( empty($frm_settings) ) {
90
+			$frm_settings = new FrmSettings();
91
+		}
92
+		return $frm_settings;
93
+	}
94 94
 
95 95
 	public static function get_menu_name() {
96 96
 		$frm_settings = FrmAppHelper::get_settings();
97 97
 		return $frm_settings->menu;
98 98
 	}
99 99
 
100
-    /**
101
-     * Show a message in place of pro features
102
-     *
103
-     * @since 2.0
104
-     */
100
+	/**
101
+	 * Show a message in place of pro features
102
+	 *
103
+	 * @since 2.0
104
+	 */
105 105
 	public static function update_message() {
106 106
 		_deprecated_function( __FUNCTION__, '2.0.19' );
107
-    }
108
-
109
-    public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
111
-    }
112
-
113
-    /**
114
-     * Check for certain page in Formidable settings
115
-     *
116
-     * @since 2.0
117
-     *
118
-     * @param string $page The name of the page to check
119
-     * @return boolean
120
-     */
107
+	}
108
+
109
+	public static function pro_is_installed() {
110
+		return apply_filters('frm_pro_installed', false);
111
+	}
112
+
113
+	/**
114
+	 * Check for certain page in Formidable settings
115
+	 *
116
+	 * @since 2.0
117
+	 *
118
+	 * @param string $page The name of the page to check
119
+	 * @return boolean
120
+	 */
121 121
 	public static function is_admin_page( $page = 'formidable' ) {
122
-        global $pagenow;
122
+		global $pagenow;
123 123
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
124
-        if ( $pagenow ) {
124
+		if ( $pagenow ) {
125 125
 			return $pagenow == 'admin.php' && $get_page == $page;
126
-        }
126
+		}
127 127
 
128 128
 		return is_admin() && $get_page == $page;
129
-    }
130
-
131
-    /**
132
-     * Check for the form preview page
133
-     *
134
-     * @since 2.0
135
-     *
136
-     * @param None
137
-     * @return boolean
138
-     */
139
-    public static function is_preview_page() {
140
-        global $pagenow;
129
+	}
130
+
131
+	/**
132
+	 * Check for the form preview page
133
+	 *
134
+	 * @since 2.0
135
+	 *
136
+	 * @param None
137
+	 * @return boolean
138
+	 */
139
+	public static function is_preview_page() {
140
+		global $pagenow;
141 141
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
142 142
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
143
-    }
143
+	}
144 144
 
145
-    /**
146
-     * Check for ajax except the form preview page
147
-     *
148
-     * @since 2.0
149
-     *
150
-     * @param None
151
-     * @return boolean
152
-     */
153
-    public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
-    }
145
+	/**
146
+	 * Check for ajax except the form preview page
147
+	 *
148
+	 * @since 2.0
149
+	 *
150
+	 * @param None
151
+	 * @return boolean
152
+	 */
153
+	public static function doing_ajax() {
154
+		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
155
+	}
156 156
 
157 157
 	/**
158 158
 	 * @since 2.0.8
@@ -162,102 +162,102 @@  discard block
 block discarded – undo
162 162
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
163 163
 	}
164 164
 
165
-    /**
166
-     * Check if on an admin page
167
-     *
168
-     * @since 2.0
169
-     *
170
-     * @param None
171
-     * @return boolean
172
-     */
173
-    public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
-    }
176
-
177
-    /**
178
-     * Check if value contains blank value or empty array
179
-     *
180
-     * @since 2.0
181
-     * @param mixed $value - value to check
165
+	/**
166
+	 * Check if on an admin page
167
+	 *
168
+	 * @since 2.0
169
+	 *
170
+	 * @param None
171
+	 * @return boolean
172
+	 */
173
+	public static function is_admin() {
174
+		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
175
+	}
176
+
177
+	/**
178
+	 * Check if value contains blank value or empty array
179
+	 *
180
+	 * @since 2.0
181
+	 * @param mixed $value - value to check
182 182
 	 * @param string
183
-     * @return boolean
184
-     */
185
-    public static function is_empty_value( $value, $empty = '' ) {
186
-        return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
-    }
188
-
189
-    public static function is_not_empty_value( $value, $empty = '' ) {
190
-        return ! self::is_empty_value( $value, $empty );
191
-    }
192
-
193
-    /**
194
-     * Get any value from the $_SERVER
195
-     *
196
-     * @since 2.0
197
-     * @param string $value
198
-     * @return string
199
-     */
183
+	 * @return boolean
184
+	 */
185
+	public static function is_empty_value( $value, $empty = '' ) {
186
+		return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
187
+	}
188
+
189
+	public static function is_not_empty_value( $value, $empty = '' ) {
190
+		return ! self::is_empty_value( $value, $empty );
191
+	}
192
+
193
+	/**
194
+	 * Get any value from the $_SERVER
195
+	 *
196
+	 * @since 2.0
197
+	 * @param string $value
198
+	 * @return string
199
+	 */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
-    }
203
-
204
-    /**
205
-     * Check for the IP address in several places
206
-     * Used by [ip] shortcode
207
-     *
208
-     * @return string The IP address of the current user
209
-     */
210
-    public static function get_ip_address() {
201
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
202
+	}
203
+
204
+	/**
205
+	 * Check for the IP address in several places
206
+	 * Used by [ip] shortcode
207
+	 *
208
+	 * @return string The IP address of the current user
209
+	 */
210
+	public static function get_ip_address() {
211 211
 		$ip = '';
212
-        foreach ( array(
213
-            'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
-            'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
-        ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
217
-                continue;
218
-            }
219
-
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
222
-
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
-                    return $ip;
225
-                }
226
-            }
227
-        }
212
+		foreach ( array(
213
+			'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214
+			'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215
+		) as $key ) {
216
+			if ( ! isset( $_SERVER[ $key ] ) ) {
217
+				continue;
218
+			}
219
+
220
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
+				$ip = trim($ip); // just to be safe
222
+
223
+				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
224
+					return $ip;
225
+				}
226
+			}
227
+		}
228 228
 
229 229
 		return sanitize_text_field( $ip );
230
-    }
230
+	}
231 231
 
232
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
235
-            $param = $params[0];
236
-        }
232
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
+		if ( strpos($param, '[') ) {
234
+			$params = explode('[', $param);
235
+			$param = $params[0];
236
+		}
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
-            }
239
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
+				$value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
242
+			}
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
245
-            $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
-        }
245
+			$value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
246
+		}
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249
-            foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
251
-                    continue;
252
-                }
249
+			foreach ( $params as $k => $p ) {
250
+				if ( ! $k || ! is_array($value) ) {
251
+					continue;
252
+				}
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
-            }
257
-        }
254
+				$p = trim($p, ']');
255
+				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
256
+			}
257
+		}
258 258
 
259
-        return $value;
260
-    }
259
+		return $value;
260
+	}
261 261
 
262 262
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
263 263
 		return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
275 275
 		return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) );
276
-    }
276
+	}
277 277
 
278 278
 	/**
279 279
 	 * Get a GET/POST/REQUEST value and sanitize it
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 
311 311
 	/**
312
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
-	*
314
-	* @since 2.0.8
315
-	* @param string $value
316
-	* @return string $value
317
-	*/
312
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
313
+	 *
314
+	 * @since 2.0.8
315
+	 * @param string $value
316
+	 * @return string $value
317
+	 */
318 318
 	public static function preserve_backslashes( $value ) {
319 319
 		// If backslashes have already been added, don't add them again
320 320
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 	}
338 338
 
339
-    public static function sanitize_request( $sanitize_method, &$values ) {
340
-        $temp_values = $values;
341
-        foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
339
+	public static function sanitize_request( $sanitize_method, &$values ) {
340
+		$temp_values = $values;
341
+		foreach ( $temp_values as $k => $val ) {
342
+			if ( isset( $sanitize_method[ $k ] ) ) {
343 343
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
344
-            }
345
-        }
346
-    }
344
+			}
345
+		}
346
+	}
347 347
 
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public static function kses( $value, $allowed = array() ) {
363 363
 		$html = array(
364
-		    'a' => array(
364
+			'a' => array(
365 365
 				'href'  => array(),
366 366
 				'title' => array(),
367 367
 				'id'    => array(),
368 368
 				'class' => array(),
369
-		    ),
369
+			),
370 370
 		);
371 371
 
372 372
 		$allowed_html = array();
@@ -377,77 +377,77 @@  discard block
 block discarded – undo
377 377
 		return wp_kses( $value, $allowed_html );
378 378
 	}
379 379
 
380
-    /**
381
-     * Used when switching the action for a bulk action
382
-     * @since 2.0
383
-     */
384
-    public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
386
-            return;
387
-        }
380
+	/**
381
+	 * Used when switching the action for a bulk action
382
+	 * @since 2.0
383
+	 */
384
+	public static function remove_get_action() {
385
+		if ( ! isset($_GET) ) {
386
+			return;
387
+		}
388 388
 
389
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
-        if ( ! empty( $new_action ) ) {
389
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
390
+		if ( ! empty( $new_action ) ) {
391 391
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
392
-        }
393
-    }
394
-
395
-    /**
396
-     * Check the WP query for a parameter
397
-     *
398
-     * @since 2.0
399
-     * @return string|array
400
-     */
401
-    public static function get_query_var( $value, $param ) {
402
-        if ( $value != '' ) {
403
-            return $value;
404
-        }
405
-
406
-        global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
409
-        }
410
-
411
-        return $value;
412
-    }
413
-
414
-    /**
415
-     * @param string $type
416
-     */
417
-    public static function trigger_hook_load( $type, $object = null ) {
418
-        // only load the form hooks once
392
+		}
393
+	}
394
+
395
+	/**
396
+	 * Check the WP query for a parameter
397
+	 *
398
+	 * @since 2.0
399
+	 * @return string|array
400
+	 */
401
+	public static function get_query_var( $value, $param ) {
402
+		if ( $value != '' ) {
403
+			return $value;
404
+		}
405
+
406
+		global $wp_query;
407
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
+			$value = $wp_query->query_vars[ $param ];
409
+		}
410
+
411
+		return $value;
412
+	}
413
+
414
+	/**
415
+	 * @param string $type
416
+	 */
417
+	public static function trigger_hook_load( $type, $object = null ) {
418
+		// only load the form hooks once
419 419
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
420
-        if ( ! $hooks_loaded ) {
420
+		if ( ! $hooks_loaded ) {
421 421
 			do_action( 'frm_load_' . $type . '_hooks' );
422
-        }
423
-    }
424
-
425
-    /**
426
-     * Check cache before fetching values and saving to cache
427
-     *
428
-     * @since 2.0
429
-     *
430
-     * @param string $cache_key The unique name for this cache
431
-     * @param string $group The name of the cache group
432
-     * @param string $query If blank, don't run a db call
433
-     * @param string $type The wpdb function to use with this query
434
-     * @return mixed $results The cache or query results
435
-     */
436
-    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
-            return $results;
440
-        }
441
-
442
-        if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
422
+		}
423
+	}
424
+
425
+	/**
426
+	 * Check cache before fetching values and saving to cache
427
+	 *
428
+	 * @since 2.0
429
+	 *
430
+	 * @param string $cache_key The unique name for this cache
431
+	 * @param string $group The name of the cache group
432
+	 * @param string $query If blank, don't run a db call
433
+	 * @param string $type The wpdb function to use with this query
434
+	 * @return mixed $results The cache or query results
435
+	 */
436
+	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
+		$results = wp_cache_get($cache_key, $group);
438
+		if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
439
+			return $results;
440
+		}
441
+
442
+		if ( 'get_posts' == $type ) {
443
+			$results = get_posts($query);
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447
-        } else {
448
-            global $wpdb;
449
-            $results = $wpdb->{$type}($query);
450
-        }
447
+		} else {
448
+			global $wpdb;
449
+			$results = $wpdb->{$type}($query);
450
+		}
451 451
 
452 452
 		self::set_cache( $cache_key, $results, $group, $time );
453 453
 
@@ -479,44 +479,44 @@  discard block
 block discarded – undo
479 479
 		return (array) $cached;
480 480
 	}
481 481
 
482
-    /**
483
-     * Data that should be stored for a long time can be stored in a transient.
484
-     * First check the cache, then check the transient
485
-     * @since 2.0
486
-     * @return mixed The cached value or false
487
-     */
482
+	/**
483
+	 * Data that should be stored for a long time can be stored in a transient.
484
+	 * First check the cache, then check the transient
485
+	 * @since 2.0
486
+	 * @return mixed The cached value or false
487
+	 */
488 488
 	public static function check_cache_and_transient( $cache_key ) {
489
-        // check caching layer first
490
-        $results = self::check_cache( $cache_key );
491
-        if ( $results ) {
492
-            return $results;
493
-        }
494
-
495
-        // then check the transient
496
-        $results = get_transient($cache_key);
497
-        if ( $results ) {
498
-            wp_cache_set($cache_key, $results);
499
-        }
500
-
501
-        return $results;
502
-    }
503
-
504
-    /**
505
-     * @since 2.0
506
-     * @param string $cache_key
507
-     */
489
+		// check caching layer first
490
+		$results = self::check_cache( $cache_key );
491
+		if ( $results ) {
492
+			return $results;
493
+		}
494
+
495
+		// then check the transient
496
+		$results = get_transient($cache_key);
497
+		if ( $results ) {
498
+			wp_cache_set($cache_key, $results);
499
+		}
500
+
501
+		return $results;
502
+	}
503
+
504
+	/**
505
+	 * @since 2.0
506
+	 * @param string $cache_key
507
+	 */
508 508
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
509 509
 		delete_transient($cache_key);
510 510
 		wp_cache_delete( $cache_key, $group );
511 511
 	}
512 512
 
513
-    /**
514
-     * Delete all caching in a single group
515
-     *
516
-     * @since 2.0
517
-     *
518
-     * @param string $group The name of the cache group
519
-     */
513
+	/**
514
+	 * Delete all caching in a single group
515
+	 *
516
+	 * @since 2.0
517
+	 *
518
+	 * @param string $group The name of the cache group
519
+	 */
520 520
 	public static function cache_delete_group( $group ) {
521 521
 		$cached_keys = self::get_group_cached_keys( $group );
522 522
 
@@ -533,34 +533,34 @@  discard block
 block discarded – undo
533 533
 		}
534 534
 	}
535 535
 
536
-    /**
537
-     * Check a value from a shortcode to see if true or false.
538
-     * True when value is 1, true, 'true', 'yes'
539
-     *
540
-     * @since 1.07.10
541
-     *
542
-     * @param string $value The value to compare
543
-     * @return boolean True or False
544
-     */
536
+	/**
537
+	 * Check a value from a shortcode to see if true or false.
538
+	 * True when value is 1, true, 'true', 'yes'
539
+	 *
540
+	 * @since 1.07.10
541
+	 *
542
+	 * @param string $value The value to compare
543
+	 * @return boolean True or False
544
+	 */
545 545
 	public static function is_true( $value ) {
546
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
547
-    }
546
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
547
+	}
548 548
 
549
-    /**
550
-     * Used to filter shortcode in text widgets
551
-     */
552
-    public static function widget_text_filter_callback( $matches ) {
553
-        return do_shortcode( $matches[0] );
554
-    }
549
+	/**
550
+	 * Used to filter shortcode in text widgets
551
+	 */
552
+	public static function widget_text_filter_callback( $matches ) {
553
+		return do_shortcode( $matches[0] );
554
+	}
555 555
 
556
-    public static function get_pages() {
556
+	public static function get_pages() {
557 557
 		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
558
-    }
558
+	}
559 559
 
560
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
561
-        $pages = self::get_pages();
560
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
561
+		$pages = self::get_pages();
562 562
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
563
-    ?>
563
+	?>
564 564
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
565 565
             <option value=""> </option>
566 566
             <?php foreach ( $pages as $page ) { ?>
@@ -570,108 +570,108 @@  discard block
 block discarded – undo
570 570
             <?php } ?>
571 571
         </select>
572 572
     <?php
573
-    }
573
+	}
574 574
 
575 575
 	public static function post_edit_link( $post_id ) {
576
-        $post = get_post($post_id);
577
-        if ( $post ) {
576
+		$post = get_post($post_id);
577
+		if ( $post ) {
578 578
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
579 579
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
580
-        }
581
-        return '';
582
-    }
580
+		}
581
+		return '';
582
+	}
583 583
 
584 584
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
585
-    ?>
585
+	?>
586 586
         <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
587
-            echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
588
-            ?> class="frm_multiselect">
587
+			echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
588
+			?> class="frm_multiselect">
589 589
             <?php self::roles_options($capability); ?>
590 590
         </select>
591 591
     <?php
592
-    }
592
+	}
593 593
 
594 594
 	public static function roles_options( $capability ) {
595
-        global $frm_vars;
596
-        if ( isset($frm_vars['editable_roles']) ) {
597
-            $editable_roles = $frm_vars['editable_roles'];
598
-        } else {
599
-            $editable_roles = get_editable_roles();
600
-            $frm_vars['editable_roles'] = $editable_roles;
601
-        }
602
-
603
-        foreach ( $editable_roles as $role => $details ) {
604
-            $name = translate_user_role($details['name'] ); ?>
595
+		global $frm_vars;
596
+		if ( isset($frm_vars['editable_roles']) ) {
597
+			$editable_roles = $frm_vars['editable_roles'];
598
+		} else {
599
+			$editable_roles = get_editable_roles();
600
+			$frm_vars['editable_roles'] = $editable_roles;
601
+		}
602
+
603
+		foreach ( $editable_roles as $role => $details ) {
604
+			$name = translate_user_role($details['name'] ); ?>
605 605
         <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
606 606
 <?php
607
-            unset($role, $details);
608
-        }
609
-    }
607
+			unset($role, $details);
608
+		}
609
+	}
610 610
 
611 611
 	public static function frm_capabilities( $type = 'auto' ) {
612
-        $cap = array(
613
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
614
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
615
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
616
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
617
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
618
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
619
-        );
612
+		$cap = array(
613
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
614
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
615
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
616
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
617
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
618
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
619
+		);
620 620
 
621 621
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
622
-            return $cap;
623
-        }
622
+			return $cap;
623
+		}
624 624
 
625
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
626
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
627
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
628
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
625
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
626
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
627
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
628
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
629 629
 
630
-        return $cap;
631
-    }
630
+		return $cap;
631
+	}
632 632
 
633 633
 	public static function user_has_permission( $needed_role ) {
634
-        if ( $needed_role == '-1' ) {
635
-            return false;
634
+		if ( $needed_role == '-1' ) {
635
+			return false;
636 636
 		}
637 637
 
638
-        // $needed_role will be equal to blank if "Logged-in users" is selected
639
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
640
-            return true;
641
-        }
638
+		// $needed_role will be equal to blank if "Logged-in users" is selected
639
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
640
+			return true;
641
+		}
642 642
 
643
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
644
-        foreach ( $roles as $role ) {
643
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
644
+		foreach ( $roles as $role ) {
645 645
 			if ( current_user_can( $role ) ) {
646
-        		return true;
646
+				return true;
647 647
 			}
648
-        	if ( $role == $needed_role ) {
649
-        		break;
648
+			if ( $role == $needed_role ) {
649
+				break;
650 650
 			}
651
-        }
652
-        return false;
653
-    }
654
-
655
-    /**
656
-     * Make sure administrators can see Formidable menu
657
-     *
658
-     * @since 2.0
659
-     */
660
-    public static function maybe_add_permissions() {
651
+		}
652
+		return false;
653
+	}
654
+
655
+	/**
656
+	 * Make sure administrators can see Formidable menu
657
+	 *
658
+	 * @since 2.0
659
+	 */
660
+	public static function maybe_add_permissions() {
661 661
 		self::force_capability( 'frm_view_entries' );
662 662
 
663
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
664
-            return;
665
-        }
663
+		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
664
+			return;
665
+		}
666 666
 
667 667
 		$user_id = get_current_user_id();
668 668
 		$user = new WP_User( $user_id );
669
-        $frm_roles = self::frm_capabilities();
670
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
669
+		$frm_roles = self::frm_capabilities();
670
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
671 671
 			$user->add_cap( $frm_role );
672
-            unset($frm_role, $frm_role_description);
673
-        }
674
-    }
672
+			unset($frm_role, $frm_role_description);
673
+		}
674
+	}
675 675
 
676 676
 	/**
677 677
 	 * Make sure admins have permission to see the menu items
@@ -687,28 +687,28 @@  discard block
 block discarded – undo
687 687
 		}
688 688
 	}
689 689
 
690
-    /**
691
-     * Check if the user has permision for action.
692
-     * Return permission message and stop the action if no permission
693
-     * @since 2.0
694
-     * @param string $permission
695
-     */
690
+	/**
691
+	 * Check if the user has permision for action.
692
+	 * Return permission message and stop the action if no permission
693
+	 * @since 2.0
694
+	 * @param string $permission
695
+	 */
696 696
 	public static function permission_check( $permission, $show_message = 'show' ) {
697
-        $permission_error = self::permission_nonce_error($permission);
698
-        if ( $permission_error !== false ) {
699
-            if ( 'hide' == $show_message ) {
700
-                $permission_error = '';
701
-            }
702
-            wp_die($permission_error);
703
-        }
704
-    }
705
-
706
-    /**
707
-     * Check user permission and nonce
708
-     * @since 2.0
709
-     * @param string $permission
710
-     * @return false|string The permission message or false if allowed
711
-     */
697
+		$permission_error = self::permission_nonce_error($permission);
698
+		if ( $permission_error !== false ) {
699
+			if ( 'hide' == $show_message ) {
700
+				$permission_error = '';
701
+			}
702
+			wp_die($permission_error);
703
+		}
704
+	}
705
+
706
+	/**
707
+	 * Check user permission and nonce
708
+	 * @since 2.0
709
+	 * @param string $permission
710
+	 * @return false|string The permission message or false if allowed
711
+	 */
712 712
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
713 713
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
714 714
 			$frm_settings = self::get_settings();
@@ -716,23 +716,23 @@  discard block
 block discarded – undo
716 716
 		}
717 717
 
718 718
 		$error = false;
719
-        if ( empty($nonce_name) ) {
720
-            return $error;
721
-        }
719
+		if ( empty($nonce_name) ) {
720
+			return $error;
721
+		}
722 722
 
723
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
724
-            $frm_settings = self::get_settings();
725
-            $error = $frm_settings->admin_permission;
726
-        }
723
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
724
+			$frm_settings = self::get_settings();
725
+			$error = $frm_settings->admin_permission;
726
+		}
727 727
 
728
-        return $error;
729
-    }
728
+		return $error;
729
+	}
730 730
 
731
-    public static function checked( $values, $current ) {
731
+	public static function checked( $values, $current ) {
732 732
 		if ( self::check_selected( $values, $current ) ) {
733
-            echo ' checked="checked"';
733
+			echo ' checked="checked"';
734 734
 		}
735
-    }
735
+	}
736 736
 
737 737
 	public static function check_selected( $values, $current ) {
738 738
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -742,50 +742,50 @@  discard block
 block discarded – undo
742 742
 		return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
743 743
 	}
744 744
 
745
-    /**
746
-    * Check if current field option is an "other" option
747
-    *
748
-    * @since 2.0
749
-    *
750
-    * @param string $opt_key
751
-    * @return boolean Returns true if current field option is an "Other" option
752
-    */
753
-    public static function is_other_opt( $opt_key ) {
754
-        _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
755
-        return FrmFieldsHelper::is_other_opt( $opt_key );
756
-    }
757
-
758
-    /**
759
-    * Get value that belongs in "Other" text box
760
-    *
761
-    * @since 2.0
762
-    *
763
-    * @param string $opt_key
764
-    * @param array $field
765
-    * @return string $other_val
766
-    */
767
-    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
745
+	/**
746
+	 * Check if current field option is an "other" option
747
+	 *
748
+	 * @since 2.0
749
+	 *
750
+	 * @param string $opt_key
751
+	 * @return boolean Returns true if current field option is an "Other" option
752
+	 */
753
+	public static function is_other_opt( $opt_key ) {
754
+		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' );
755
+		return FrmFieldsHelper::is_other_opt( $opt_key );
756
+	}
757
+
758
+	/**
759
+	 * Get value that belongs in "Other" text box
760
+	 *
761
+	 * @since 2.0
762
+	 *
763
+	 * @param string $opt_key
764
+	 * @param array $field
765
+	 * @return string $other_val
766
+	 */
767
+	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) {
768 768
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' );
769 769
 		return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) );
770
-    }
771
-
772
-    /**
773
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
774
-    * Intended for front-end use
775
-    *
776
-    * @since 2.0
777
-    *
778
-    * @param array $field
779
-    * @param boolean $other_opt
780
-    * @param string $checked
781
-    * @param array $args should include opt_key and field name
782
-    * @return string $other_val
783
-    */
784
-    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
770
+	}
771
+
772
+	/**
773
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
774
+	 * Intended for front-end use
775
+	 *
776
+	 * @since 2.0
777
+	 *
778
+	 * @param array $field
779
+	 * @param boolean $other_opt
780
+	 * @param string $checked
781
+	 * @param array $args should include opt_key and field name
782
+	 * @return string $other_val
783
+	 */
784
+	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) {
785 785
 		_deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' );
786 786
 		$args['field'] = $field;
787 787
 		return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked );
788
-    }
788
+	}
789 789
 
790 790
 	public static function recursive_function_map( $value, $function ) {
791 791
 		if ( is_array( $value ) ) {
@@ -815,24 +815,24 @@  discard block
 block discarded – undo
815 815
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
816 816
 	}
817 817
 
818
-    /**
819
-     * Flatten a multi-dimensional array
820
-     */
818
+	/**
819
+	 * Flatten a multi-dimensional array
820
+	 */
821 821
 	public static function array_flatten( $array, $keys = 'keep' ) {
822
-        $return = array();
823
-        foreach ( $array as $key => $value ) {
824
-            if ( is_array($value) ) {
822
+		$return = array();
823
+		foreach ( $array as $key => $value ) {
824
+			if ( is_array($value) ) {
825 825
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
826
-            } else {
826
+			} else {
827 827
 				if ( $keys == 'keep' ) {
828 828
 					$return[ $key ] = $value;
829 829
 				} else {
830 830
 					$return[] = $value;
831 831
 				}
832
-            }
833
-        }
834
-        return $return;
835
-    }
832
+			}
833
+		}
834
+		return $return;
835
+	}
836 836
 
837 837
 	public static function esc_textarea( $text, $is_rich_text = false ) {
838 838
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -843,308 +843,308 @@  discard block
 block discarded – undo
843 843
 		return apply_filters( 'esc_textarea', $safe_text, $text );
844 844
 	}
845 845
 
846
-    /**
847
-     * Add auto paragraphs to text areas
848
-     * @since 2.0
849
-     */
846
+	/**
847
+	 * Add auto paragraphs to text areas
848
+	 * @since 2.0
849
+	 */
850 850
 	public static function use_wpautop( $content ) {
851
-        if ( apply_filters('frm_use_wpautop', true) ) {
852
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
853
-        }
854
-        return $content;
855
-    }
851
+		if ( apply_filters('frm_use_wpautop', true) ) {
852
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
853
+		}
854
+		return $content;
855
+	}
856 856
 
857 857
 	public static function replace_quotes( $val ) {
858
-        //Replace double quotes
858
+		//Replace double quotes
859 859
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
860
-        //Replace single quotes
861
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
862
-        return $val;
863
-    }
864
-
865
-    /**
866
-     * @since 2.0
867
-     * @return string The base Google APIS url for the current version of jQuery UI
868
-     */
869
-    public static function jquery_ui_base_url() {
860
+		//Replace single quotes
861
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
862
+		return $val;
863
+	}
864
+
865
+	/**
866
+	 * @since 2.0
867
+	 * @return string The base Google APIS url for the current version of jQuery UI
868
+	 */
869
+	public static function jquery_ui_base_url() {
870 870
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
871
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
872
-        return $url;
873
-    }
871
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
872
+		return $url;
873
+	}
874 874
 
875
-    /**
876
-     * @param string $handle
877
-     */
875
+	/**
876
+	 * @param string $handle
877
+	 */
878 878
 	public static function script_version( $handle ) {
879
-        global $wp_scripts;
880
-    	if ( ! $wp_scripts ) {
881
-    	    return false;
882
-    	}
879
+		global $wp_scripts;
880
+		if ( ! $wp_scripts ) {
881
+			return false;
882
+		}
883 883
 
884
-        $ver = 0;
884
+		$ver = 0;
885 885
 
886
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
887
-            return $ver;
888
-        }
886
+		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
887
+			return $ver;
888
+		}
889 889
 
890
-        $query = $wp_scripts->registered[ $handle ];
891
-    	if ( is_object( $query ) ) {
892
-    	    $ver = $query->ver;
893
-    	}
890
+		$query = $wp_scripts->registered[ $handle ];
891
+		if ( is_object( $query ) ) {
892
+			$ver = $query->ver;
893
+		}
894 894
 
895
-    	return $ver;
896
-    }
895
+		return $ver;
896
+	}
897 897
 
898 898
 	public static function js_redirect( $url ) {
899 899
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
900
-    }
900
+	}
901 901
 
902 902
 	public static function get_user_id_param( $user_id ) {
903
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
-            return $user_id;
905
-        }
903
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
904
+			return $user_id;
905
+		}
906 906
 
907 907
 		if ( $user_id == 'current' ) {
908 908
 			$user_id = get_current_user_id();
909 909
 		} else {
910
-            if ( is_email($user_id) ) {
911
-                $user = get_user_by('email', $user_id);
912
-            } else {
913
-                $user = get_user_by('login', $user_id);
914
-            }
910
+			if ( is_email($user_id) ) {
911
+				$user = get_user_by('email', $user_id);
912
+			} else {
913
+				$user = get_user_by('login', $user_id);
914
+			}
915 915
 
916
-            if ( $user ) {
917
-                $user_id = $user->ID;
918
-            }
919
-            unset($user);
920
-        }
916
+			if ( $user ) {
917
+				$user_id = $user->ID;
918
+			}
919
+			unset($user);
920
+		}
921 921
 
922
-        return $user_id;
923
-    }
922
+		return $user_id;
923
+	}
924 924
 
925 925
 	public static function get_file_contents( $filename, $atts = array() ) {
926
-        if ( ! is_file($filename) ) {
927
-            return false;
928
-        }
929
-
930
-        extract($atts);
931
-        ob_start();
932
-        include($filename);
933
-        $contents = ob_get_contents();
934
-        ob_end_clean();
935
-        return $contents;
936
-    }
937
-
938
-    /**
939
-     * @param string $table_name
940
-     * @param string $column
926
+		if ( ! is_file($filename) ) {
927
+			return false;
928
+		}
929
+
930
+		extract($atts);
931
+		ob_start();
932
+		include($filename);
933
+		$contents = ob_get_contents();
934
+		ob_end_clean();
935
+		return $contents;
936
+	}
937
+
938
+	/**
939
+	 * @param string $table_name
940
+	 * @param string $column
941 941
 	 * @param int $id
942 942
 	 * @param int $num_chars
943
-     */
944
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
-        $key = '';
943
+	 */
944
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
945
+		$key = '';
946 946
 
947
-        if ( ! empty( $name ) ) {
948
-            $key = sanitize_key($name);
949
-        }
947
+		if ( ! empty( $name ) ) {
948
+			$key = sanitize_key($name);
949
+		}
950 950
 
951 951
 		if ( empty( $key ) ) {
952
-            $max_slug_value = pow(36, $num_chars);
953
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
954
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
-        }
952
+			$max_slug_value = pow(36, $num_chars);
953
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
954
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
955
+		}
956 956
 
957 957
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
958 958
 			$key = $key . 'a';
959
-        }
959
+		}
960 960
 
961 961
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
962 962
 
963
-        if ( $key_check || is_numeric($key_check) ) {
964
-            $suffix = 2;
963
+		if ( $key_check || is_numeric($key_check) ) {
964
+			$suffix = 2;
965 965
 			do {
966 966
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
967 967
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
968 968
 				$suffix++;
969 969
 			} while ($key_check || is_numeric($key_check));
970 970
 			$key = $alt_post_name;
971
-        }
972
-        return $key;
973
-    }
974
-
975
-    /**
976
-     * Editing a Form or Entry
977
-     * @param string $table
978
-     * @return bool|array
979
-     */
980
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
-        if ( ! $record ) {
982
-            return false;
983
-        }
984
-
985
-        if ( empty($post_values) ) {
986
-            $post_values = stripslashes_deep($_POST);
987
-        }
971
+		}
972
+		return $key;
973
+	}
974
+
975
+	/**
976
+	 * Editing a Form or Entry
977
+	 * @param string $table
978
+	 * @return bool|array
979
+	 */
980
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
981
+		if ( ! $record ) {
982
+			return false;
983
+		}
984
+
985
+		if ( empty($post_values) ) {
986
+			$post_values = stripslashes_deep($_POST);
987
+		}
988 988
 
989 989
 		$values = array( 'id' => $record->id, 'fields' => array() );
990 990
 
991 991
 		foreach ( array( 'name', 'description' ) as $var ) {
992
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
992
+			$default_val = isset($record->{$var}) ? $record->{$var} : '';
993 993
 			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
994
-            unset($var, $default_val);
995
-        }
996
-
997
-        $values['description'] = self::use_wpautop($values['description']);
998
-        $frm_settings = self::get_settings();
999
-        $is_form_builder = self::is_admin_page('formidable' );
1000
-
1001
-        foreach ( (array) $fields as $field ) {
1002
-            // Make sure to filter default values (for placeholder text), but not on the form builder page
1003
-            if ( ! $is_form_builder ) {
1004
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
-            }
994
+			unset($var, $default_val);
995
+		}
996
+
997
+		$values['description'] = self::use_wpautop($values['description']);
998
+		$frm_settings = self::get_settings();
999
+		$is_form_builder = self::is_admin_page('formidable' );
1000
+
1001
+		foreach ( (array) $fields as $field ) {
1002
+			// Make sure to filter default values (for placeholder text), but not on the form builder page
1003
+			if ( ! $is_form_builder ) {
1004
+				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1005
+			}
1006 1006
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1007 1007
 			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1008
-        }
1008
+		}
1009 1009
 
1010
-        self::fill_form_opts($record, $table, $post_values, $values);
1010
+		self::fill_form_opts($record, $table, $post_values, $values);
1011 1011
 
1012
-        if ( $table == 'entries' ) {
1013
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
-        } else if ( $table == 'forms' ) {
1015
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
-        }
1012
+		if ( $table == 'entries' ) {
1013
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1014
+		} else if ( $table == 'forms' ) {
1015
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1016
+		}
1017 1017
 
1018
-        return $values;
1019
-    }
1018
+		return $values;
1019
+	}
1020 1020
 
1021 1021
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1022
-        $post_values = $args['post_values'];
1023
-
1024
-        if ( $args['default'] ) {
1025
-            $meta_value = $field->default_value;
1026
-        } else {
1027
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
-                if ( ! isset($field->field_options['custom_field']) ) {
1029
-                    $field->field_options['custom_field'] = '';
1030
-                }
1022
+		$post_values = $args['post_values'];
1023
+
1024
+		if ( $args['default'] ) {
1025
+			$meta_value = $field->default_value;
1026
+		} else {
1027
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1028
+				if ( ! isset($field->field_options['custom_field']) ) {
1029
+					$field->field_options['custom_field'] = '';
1030
+				}
1031 1031
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
1032
-            } else {
1032
+			} else {
1033 1033
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1034
-            }
1035
-        }
1034
+			}
1035
+		}
1036 1036
 
1037 1037
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1038
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
-
1040
-        $field_array = array(
1041
-            'id'            => $field->id,
1042
-            'value'         => $new_value,
1043
-            'default_value' => $field->default_value,
1044
-            'name'          => $field->name,
1045
-            'description'   => $field->description,
1046
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
-            'options'       => $field->options,
1048
-            'required'      => $field->required,
1049
-            'field_key'     => $field->field_key,
1050
-            'field_order'   => $field->field_order,
1051
-            'form_id'       => $field->form_id,
1038
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1039
+
1040
+		$field_array = array(
1041
+			'id'            => $field->id,
1042
+			'value'         => $new_value,
1043
+			'default_value' => $field->default_value,
1044
+			'name'          => $field->name,
1045
+			'description'   => $field->description,
1046
+			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1047
+			'options'       => $field->options,
1048
+			'required'      => $field->required,
1049
+			'field_key'     => $field->field_key,
1050
+			'field_order'   => $field->field_order,
1051
+			'form_id'       => $field->form_id,
1052 1052
 			'parent_form_id' => $args['parent_form_id'],
1053
-        );
1053
+		);
1054 1054
 
1055
-        $args['field_type'] = $field_type;
1056
-        self::fill_field_opts($field, $field_array, $args);
1055
+		$args['field_type'] = $field_type;
1056
+		self::fill_field_opts($field, $field_array, $args);
1057 1057
 		// Track the original field's type
1058 1058
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1059 1059
 
1060
-        $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1060
+		$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1061 1061
 
1062
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
-            $field_array['unique_msg'] = '';
1064
-        }
1062
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1063
+			$field_array['unique_msg'] = '';
1064
+		}
1065 1065
 
1066
-        $field_array = array_merge( $field->field_options, $field_array );
1066
+		$field_array = array_merge( $field->field_options, $field_array );
1067 1067
 
1068
-        $values['fields'][ $field->id ] = $field_array;
1069
-    }
1068
+		$values['fields'][ $field->id ] = $field_array;
1069
+	}
1070 1070
 
1071 1071
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1072
-        $post_values = $args['post_values'];
1073
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1072
+		$post_values = $args['post_values'];
1073
+		$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1074 1074
 
1075
-        foreach ( $opt_defaults as $opt => $default_opt ) {
1075
+		foreach ( $opt_defaults as $opt => $default_opt ) {
1076 1076
 			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1077
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
-                if ( $args['field_type'] == 'captcha' ) {
1081
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
-                } else {
1083
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
-                }
1085
-            }
1086
-        }
1087
-
1088
-        if ( $field_array['custom_html'] == '' ) {
1089
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
-        }
1091
-    }
1092
-
1093
-    /**
1094
-     * @param string $table
1095
-     */
1077
+			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1078
+				$field_array[ $opt ] = $args['frm_settings']->blank_msg;
1079
+			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1080
+				if ( $args['field_type'] == 'captcha' ) {
1081
+					$field_array[ $opt ] = $args['frm_settings']->re_msg;
1082
+				} else {
1083
+					$field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1084
+				}
1085
+			}
1086
+		}
1087
+
1088
+		if ( $field_array['custom_html'] == '' ) {
1089
+			$field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1090
+		}
1091
+	}
1092
+
1093
+	/**
1094
+	 * @param string $table
1095
+	 */
1096 1096
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1097
-        if ( $table == 'entries' ) {
1098
-            $form = $record->form_id;
1097
+		if ( $table == 'entries' ) {
1098
+			$form = $record->form_id;
1099 1099
 			FrmForm::maybe_get_form( $form );
1100
-        } else {
1101
-            $form = $record;
1102
-        }
1100
+		} else {
1101
+			$form = $record;
1102
+		}
1103 1103
 
1104
-        if ( ! $form ) {
1105
-            return;
1106
-        }
1104
+		if ( ! $form ) {
1105
+			return;
1106
+		}
1107 1107
 
1108
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1108
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1109 1109
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1110 1110
 
1111
-        if ( ! is_array($form->options) ) {
1112
-            return;
1113
-        }
1111
+		if ( ! is_array($form->options) ) {
1112
+			return;
1113
+		}
1114 1114
 
1115
-        foreach ( $form->options as $opt => $value ) {
1116
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
-        }
1115
+		foreach ( $form->options as $opt => $value ) {
1116
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1117
+		}
1118 1118
 
1119
-        self::fill_form_defaults($post_values, $values);
1120
-    }
1119
+		self::fill_form_defaults($post_values, $values);
1120
+	}
1121 1121
 
1122
-    /**
1123
-     * Set to POST value or default
1124
-     */
1122
+	/**
1123
+	 * Set to POST value or default
1124
+	 */
1125 1125
 	private static function fill_form_defaults( $post_values, array &$values ) {
1126
-        $form_defaults = FrmFormsHelper::get_default_opts();
1126
+		$form_defaults = FrmFormsHelper::get_default_opts();
1127 1127
 
1128
-        foreach ( $form_defaults as $opt => $default ) {
1129
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1128
+		foreach ( $form_defaults as $opt => $default ) {
1129
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1130 1130
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1131
-            }
1131
+			}
1132 1132
 
1133
-            unset($opt, $defaut);
1134
-        }
1133
+			unset($opt, $defaut);
1134
+		}
1135 1135
 
1136
-        if ( ! isset($values['custom_style']) ) {
1137
-            $frm_settings = self::get_settings();
1136
+		if ( ! isset($values['custom_style']) ) {
1137
+			$frm_settings = self::get_settings();
1138 1138
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1139
-        }
1139
+		}
1140 1140
 
1141 1141
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1142 1142
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1143 1143
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1144
-            }
1145
-            unset($h);
1146
-        }
1147
-    }
1144
+			}
1145
+			unset($h);
1146
+		}
1147
+	}
1148 1148
 
1149 1149
 	public static function get_meta_value( $field_id, $entry ) {
1150 1150
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' );
@@ -1152,59 +1152,59 @@  discard block
 block discarded – undo
1152 1152
 	}
1153 1153
 
1154 1154
 	public static function insert_opt_html( $args ) {
1155
-        $class = '';
1156
-        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1157
-            $class .= 'show_frm_not_email_to';
1158
-        }
1159
-    ?>
1155
+		$class = '';
1156
+		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) {
1157
+			$class .= 'show_frm_not_email_to';
1158
+		}
1159
+	?>
1160 1160
 <li>
1161 1161
     <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1162 1162
     <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1163 1163
     <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1164 1164
 </li>
1165 1165
     <?php
1166
-    }
1166
+	}
1167 1167
 
1168 1168
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1169
-        if ( is_array( $str ) ) {
1170
-            return '';
1169
+		if ( is_array( $str ) ) {
1170
+			return '';
1171 1171
 		}
1172 1172
 
1173
-        $length = (int) $length;
1173
+		$length = (int) $length;
1174 1174
 		$str = wp_strip_all_tags( $str );
1175 1175
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1176 1176
 
1177 1177
 		if ( $length == 0 ) {
1178
-            return '';
1179
-        } else if ( $length <= 10 ) {
1178
+			return '';
1179
+		} else if ( $length <= 10 ) {
1180 1180
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1181
-            return $sub . (($length < $original_len) ? $continue : '');
1182
-        }
1181
+			return $sub . (($length < $original_len) ? $continue : '');
1182
+		}
1183 1183
 
1184
-        $sub = '';
1185
-        $len = 0;
1184
+		$sub = '';
1185
+		$len = 0;
1186 1186
 
1187 1187
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1188 1188
 
1189 1189
 		foreach ( $words as $word ) {
1190
-            $part = (($sub != '') ? ' ' : '') . $word;
1190
+			$part = (($sub != '') ? ' ' : '') . $word;
1191 1191
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1192
-            if ( $total_len > $length && str_word_count($sub) ) {
1193
-                break;
1194
-            }
1192
+			if ( $total_len > $length && str_word_count($sub) ) {
1193
+				break;
1194
+			}
1195 1195
 
1196
-            $sub .= $part;
1196
+			$sub .= $part;
1197 1197
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1198 1198
 
1199
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1200
-                break;
1201
-            }
1199
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1200
+				break;
1201
+			}
1202 1202
 
1203
-            unset($total_len, $word);
1204
-        }
1203
+			unset($total_len, $word);
1204
+		}
1205 1205
 
1206
-        return $sub . (($len < $original_len) ? $continue : '');
1207
-    }
1206
+		return $sub . (($len < $original_len) ? $continue : '');
1207
+	}
1208 1208
 
1209 1209
 	public static function mb_function( $function_names, $args ) {
1210 1210
 		$mb_function_name = $function_names[0];
@@ -1216,18 +1216,18 @@  discard block
 block discarded – undo
1216 1216
 	}
1217 1217
 
1218 1218
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1219
-        if ( empty($date) ) {
1220
-            return $date;
1221
-        }
1219
+		if ( empty($date) ) {
1220
+			return $date;
1221
+		}
1222 1222
 
1223
-        if ( empty($date_format) ) {
1224
-            $date_format = get_option('date_format');
1225
-        }
1223
+		if ( empty($date_format) ) {
1224
+			$date_format = get_option('date_format');
1225
+		}
1226 1226
 
1227
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1228
-            $frmpro_settings = new FrmProSettings();
1229
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1230
-        }
1227
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1228
+			$frmpro_settings = new FrmProSettings();
1229
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1230
+		}
1231 1231
 
1232 1232
 		$formatted = self::get_localized_date( $date_format, $date );
1233 1233
 
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
 			$formatted .= self::add_time_to_date( $time_format, $date );
1237 1237
 		}
1238 1238
 
1239
-        return $formatted;
1240
-    }
1239
+		return $formatted;
1240
+	}
1241 1241
 
1242 1242
 	private static function add_time_to_date( $time_format, $date ) {
1243 1243
 		if ( empty( $time_format ) ) {
@@ -1318,61 +1318,61 @@  discard block
 block discarded – undo
1318 1318
 		);
1319 1319
 	}
1320 1320
 
1321
-    /**
1322
-     * Added for < WP 4.0 compatability
1323
-     *
1324
-     * @since 1.07.10
1325
-     *
1326
-     * @param string $term The value to escape
1327
-     * @return string The escaped value
1328
-     */
1321
+	/**
1322
+	 * Added for < WP 4.0 compatability
1323
+	 *
1324
+	 * @since 1.07.10
1325
+	 *
1326
+	 * @param string $term The value to escape
1327
+	 * @return string The escaped value
1328
+	 */
1329 1329
 	public static function esc_like( $term ) {
1330
-        global $wpdb;
1331
-        if ( method_exists($wpdb, 'esc_like') ) {
1330
+		global $wpdb;
1331
+		if ( method_exists($wpdb, 'esc_like') ) {
1332 1332
 			// WP 4.0
1333
-            $term = $wpdb->esc_like( $term );
1334
-        } else {
1335
-            $term = like_escape( $term );
1336
-        }
1333
+			$term = $wpdb->esc_like( $term );
1334
+		} else {
1335
+			$term = like_escape( $term );
1336
+		}
1337 1337
 
1338
-        return $term;
1339
-    }
1338
+		return $term;
1339
+	}
1340 1340
 
1341
-    /**
1342
-     * @param string $order_query
1343
-     */
1341
+	/**
1342
+	 * @param string $order_query
1343
+	 */
1344 1344
 	public static function esc_order( $order_query ) {
1345
-        if ( empty($order_query) ) {
1346
-            return '';
1347
-        }
1348
-
1349
-        // remove ORDER BY before santizing
1350
-        $order_query = strtolower($order_query);
1351
-        if ( strpos($order_query, 'order by') !== false ) {
1352
-            $order_query = str_replace('order by', '', $order_query);
1353
-        }
1354
-
1355
-        $order_query = explode(' ', trim($order_query));
1356
-
1357
-        $order_fields = array(
1358
-            'id', 'form_key', 'name', 'description',
1359
-            'parent_form_id', 'logged_in', 'is_template',
1360
-            'default_template', 'status', 'created_at',
1361
-        );
1362
-
1363
-        $order = trim(trim(reset($order_query), ','));
1364
-        if ( ! in_array($order, $order_fields) ) {
1365
-            return '';
1366
-        }
1367
-
1368
-        $order_by = '';
1369
-        if ( count($order_query) > 1 ) {
1345
+		if ( empty($order_query) ) {
1346
+			return '';
1347
+		}
1348
+
1349
+		// remove ORDER BY before santizing
1350
+		$order_query = strtolower($order_query);
1351
+		if ( strpos($order_query, 'order by') !== false ) {
1352
+			$order_query = str_replace('order by', '', $order_query);
1353
+		}
1354
+
1355
+		$order_query = explode(' ', trim($order_query));
1356
+
1357
+		$order_fields = array(
1358
+			'id', 'form_key', 'name', 'description',
1359
+			'parent_form_id', 'logged_in', 'is_template',
1360
+			'default_template', 'status', 'created_at',
1361
+		);
1362
+
1363
+		$order = trim(trim(reset($order_query), ','));
1364
+		if ( ! in_array($order, $order_fields) ) {
1365
+			return '';
1366
+		}
1367
+
1368
+		$order_by = '';
1369
+		if ( count($order_query) > 1 ) {
1370 1370
 			$order_by = end( $order_query );
1371 1371
 			self::esc_order_by( $order_by );
1372
-        }
1372
+		}
1373 1373
 
1374 1374
 		return ' ORDER BY ' . $order . ' ' . $order_by;
1375
-    }
1375
+	}
1376 1376
 
1377 1377
 	/**
1378 1378
 	 * Make sure this is ordering by either ASC or DESC
@@ -1384,169 +1384,169 @@  discard block
 block discarded – undo
1384 1384
 		}
1385 1385
 	}
1386 1386
 
1387
-    /**
1388
-     * @param string $limit
1389
-     */
1387
+	/**
1388
+	 * @param string $limit
1389
+	 */
1390 1390
 	public static function esc_limit( $limit ) {
1391
-        if ( empty($limit) ) {
1392
-            return '';
1393
-        }
1391
+		if ( empty($limit) ) {
1392
+			return '';
1393
+		}
1394 1394
 
1395
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1396
-        if ( is_numeric($limit) ) {
1395
+		$limit = trim(str_replace(' limit', '', strtolower($limit)));
1396
+		if ( is_numeric($limit) ) {
1397 1397
 			return ' LIMIT ' . $limit;
1398
-        }
1398
+		}
1399 1399
 
1400
-        $limit = explode(',', trim($limit));
1401
-        foreach ( $limit as $k => $l ) {
1402
-            if ( is_numeric( $l ) ) {
1403
-                $limit[ $k ] = $l;
1404
-            }
1405
-        }
1400
+		$limit = explode(',', trim($limit));
1401
+		foreach ( $limit as $k => $l ) {
1402
+			if ( is_numeric( $l ) ) {
1403
+				$limit[ $k ] = $l;
1404
+			}
1405
+		}
1406 1406
 
1407
-        $limit = implode(',', $limit);
1407
+		$limit = implode(',', $limit);
1408 1408
 		return ' LIMIT ' . $limit;
1409
-    }
1410
-
1411
-    /**
1412
-     * Get an array of values ready to go through $wpdb->prepare
1413
-     * @since 2.0
1414
-     */
1415
-    public static function prepare_array_values( $array, $type = '%s' ) {
1416
-        $placeholders = array_fill(0, count($array), $type);
1417
-        return implode(', ', $placeholders);
1418
-    }
1419
-
1420
-    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1421
-        if ( empty($where) ) {
1422
-            return '';
1423
-        }
1409
+	}
1410
+
1411
+	/**
1412
+	 * Get an array of values ready to go through $wpdb->prepare
1413
+	 * @since 2.0
1414
+	 */
1415
+	public static function prepare_array_values( $array, $type = '%s' ) {
1416
+		$placeholders = array_fill(0, count($array), $type);
1417
+		return implode(', ', $placeholders);
1418
+	}
1419
+
1420
+	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1421
+		if ( empty($where) ) {
1422
+			return '';
1423
+		}
1424 1424
 
1425 1425
 		if ( is_array( $where ) ) {
1426
-            global $wpdb;
1427
-            FrmDb::get_where_clause_and_values( $where, $starts_with );
1426
+			global $wpdb;
1427
+			FrmDb::get_where_clause_and_values( $where, $starts_with );
1428 1428
 			$where = $wpdb->prepare( $where['where'], $where['values'] );
1429 1429
 		} else {
1430
-            $where = $starts_with . $where;
1431
-        }
1430
+			$where = $starts_with . $where;
1431
+		}
1432 1432
 
1433
-        return $where;
1434
-    }
1433
+		return $where;
1434
+	}
1435 1435
 
1436
-    // Pagination Methods
1436
+	// Pagination Methods
1437 1437
 
1438
-    /**
1439
-     * @param integer $current_p
1440
-     */
1438
+	/**
1439
+	 * @param integer $current_p
1440
+	 */
1441 1441
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1442 1442
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1443 1443
 	}
1444 1444
 
1445
-    /**
1446
-     * @param integer $current_p
1447
-     */
1448
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1449
-        if ( $current_p == 1 ) {
1450
-            return 1;
1451
-        } else {
1452
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1453
-        }
1454
-    }
1445
+	/**
1446
+	 * @param integer $current_p
1447
+	 */
1448
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1449
+		if ( $current_p == 1 ) {
1450
+			return 1;
1451
+		} else {
1452
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1453
+		}
1454
+	}
1455 1455
 
1456 1456
 	/**
1457 1457
 	 * @return array
1458 1458
 	 */
1459 1459
 	public static function json_to_array( $json_vars ) {
1460
-        $vars = array();
1461
-        foreach ( $json_vars as $jv ) {
1462
-            $jv_name = explode('[', $jv['name']);
1463
-            $last = count($jv_name) - 1;
1464
-            foreach ( $jv_name as $p => $n ) {
1465
-                $name = trim($n, ']');
1466
-                if ( ! isset($l1) ) {
1467
-                    $l1 = $name;
1468
-                }
1469
-
1470
-                if ( ! isset($l2) ) {
1471
-                    $l2 = $name;
1472
-                }
1473
-
1474
-                if ( ! isset($l3) ) {
1475
-                    $l3 = $name;
1476
-                }
1477
-
1478
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1479
-
1480
-                switch ( $p ) {
1481
-                    case 0:
1482
-                        $l1 = $name;
1483
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1484
-                    break;
1485
-
1486
-                    case 1:
1487
-                        $l2 = $name;
1488
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1489
-                    break;
1490
-
1491
-                    case 2:
1492
-                        $l3 = $name;
1493
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1494
-                    break;
1495
-
1496
-                    case 3:
1497
-                        $l4 = $name;
1498
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1499
-                    break;
1500
-                }
1501
-
1502
-                unset($this_val, $n);
1503
-            }
1504
-
1505
-            unset($last, $jv);
1506
-        }
1507
-
1508
-        return $vars;
1509
-    }
1510
-
1511
-    /**
1512
-     * @param string $name
1513
-     * @param string $l1
1514
-     */
1515
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1516
-        if ( $name == '' ) {
1517
-            $vars[] = $val;
1518
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1519
-            $vars[ $l1 ] = $val;
1520
-        }
1521
-    }
1460
+		$vars = array();
1461
+		foreach ( $json_vars as $jv ) {
1462
+			$jv_name = explode('[', $jv['name']);
1463
+			$last = count($jv_name) - 1;
1464
+			foreach ( $jv_name as $p => $n ) {
1465
+				$name = trim($n, ']');
1466
+				if ( ! isset($l1) ) {
1467
+					$l1 = $name;
1468
+				}
1469
+
1470
+				if ( ! isset($l2) ) {
1471
+					$l2 = $name;
1472
+				}
1473
+
1474
+				if ( ! isset($l3) ) {
1475
+					$l3 = $name;
1476
+				}
1477
+
1478
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1479
+
1480
+				switch ( $p ) {
1481
+					case 0:
1482
+						$l1 = $name;
1483
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1484
+					break;
1485
+
1486
+					case 1:
1487
+						$l2 = $name;
1488
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1489
+					break;
1490
+
1491
+					case 2:
1492
+						$l3 = $name;
1493
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1494
+					break;
1495
+
1496
+					case 3:
1497
+						$l4 = $name;
1498
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1499
+					break;
1500
+				}
1501
+
1502
+				unset($this_val, $n);
1503
+			}
1504
+
1505
+			unset($last, $jv);
1506
+		}
1507
+
1508
+		return $vars;
1509
+	}
1510
+
1511
+	/**
1512
+	 * @param string $name
1513
+	 * @param string $l1
1514
+	 */
1515
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1516
+		if ( $name == '' ) {
1517
+			$vars[] = $val;
1518
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1519
+			$vars[ $l1 ] = $val;
1520
+		}
1521
+	}
1522 1522
 
1523 1523
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1524
-        $tooltips = array(
1525
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1526
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1527
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1528
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1529
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1530
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1531
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1532
-        );
1533
-
1534
-        if ( ! isset( $tooltips[ $name ] ) ) {
1535
-            return;
1536
-        }
1537
-
1538
-        if ( 'open' == $class ) {
1539
-            echo ' frm_help"';
1540
-        } else {
1541
-            echo ' class="frm_help"';
1542
-        }
1524
+		$tooltips = array(
1525
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1526
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1527
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1528
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1529
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1530
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1531
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1532
+		);
1533
+
1534
+		if ( ! isset( $tooltips[ $name ] ) ) {
1535
+			return;
1536
+		}
1537
+
1538
+		if ( 'open' == $class ) {
1539
+			echo ' frm_help"';
1540
+		} else {
1541
+			echo ' class="frm_help"';
1542
+		}
1543 1543
 
1544 1544
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1545 1545
 
1546
-        if ( 'open' != $class ) {
1547
-            echo '"';
1548
-        }
1549
-    }
1546
+		if ( 'open' != $class ) {
1547
+			echo '"';
1548
+		}
1549
+	}
1550 1550
 
1551 1551
 	/**
1552 1552
 	 * Add the current_page class to that page in the form nav
@@ -1562,35 +1562,35 @@  discard block
 block discarded – undo
1562 1562
 		}
1563 1563
 	}
1564 1564
 
1565
-    /**
1566
-     * Prepare and json_encode post content
1567
-     *
1568
-     * @since 2.0
1569
-     *
1570
-     * @param array $post_content
1571
-     * @return string $post_content ( json encoded array )
1572
-     */
1573
-    public static function prepare_and_encode( $post_content ) {
1574
-        //Loop through array to strip slashes and add only the needed ones
1565
+	/**
1566
+	 * Prepare and json_encode post content
1567
+	 *
1568
+	 * @since 2.0
1569
+	 *
1570
+	 * @param array $post_content
1571
+	 * @return string $post_content ( json encoded array )
1572
+	 */
1573
+	public static function prepare_and_encode( $post_content ) {
1574
+		//Loop through array to strip slashes and add only the needed ones
1575 1575
 		foreach ( $post_content as $key => $val ) {
1576 1576
 			// Replace problematic characters (like &quot;)
1577 1577
 			$val = str_replace( '&quot;', '"', $val );
1578 1578
 
1579 1579
 			self::prepare_action_slashes( $val, $key, $post_content );
1580
-            unset( $key, $val );
1581
-        }
1580
+			unset( $key, $val );
1581
+		}
1582 1582
 
1583
-        // json_encode the array
1584
-        $post_content = json_encode( $post_content );
1583
+		// json_encode the array
1584
+		$post_content = json_encode( $post_content );
1585 1585
 
1586
-	    // add extra slashes for \r\n since WP strips them
1586
+		// add extra slashes for \r\n since WP strips them
1587 1587
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1588 1588
 
1589
-        // allow for &quot
1590
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1589
+		// allow for &quot
1590
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1591 1591
 
1592
-        return $post_content;
1593
-    }
1592
+		return $post_content;
1593
+	}
1594 1594
 
1595 1595
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1596 1596
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1658,64 +1658,64 @@  discard block
 block discarded – undo
1658 1658
 	}
1659 1659
 
1660 1660
 	public static function maybe_json_decode( $string ) {
1661
-        if ( is_array($string) ) {
1662
-            return $string;
1663
-        }
1661
+		if ( is_array($string) ) {
1662
+			return $string;
1663
+		}
1664 1664
 
1665
-        $new_string = json_decode($string, true);
1666
-        if ( function_exists('json_last_error') ) {
1665
+		$new_string = json_decode($string, true);
1666
+		if ( function_exists('json_last_error') ) {
1667 1667
 			// php 5.3+
1668
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1669
-                $string = $new_string;
1670
-            }
1671
-        } else if ( isset($new_string) ) {
1668
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1669
+				$string = $new_string;
1670
+			}
1671
+		} else if ( isset($new_string) ) {
1672 1672
 			// php < 5.3 fallback
1673
-            $string = $new_string;
1674
-        }
1675
-        return $string;
1676
-    }
1677
-
1678
-    /**
1679
-     * @since 1.07.10
1680
-     *
1681
-     * @param string $post_type The name of the post type that may need to be highlighted
1682
-     * echo The javascript to open and highlight the Formidable menu
1683
-     */
1673
+			$string = $new_string;
1674
+		}
1675
+		return $string;
1676
+	}
1677
+
1678
+	/**
1679
+	 * @since 1.07.10
1680
+	 *
1681
+	 * @param string $post_type The name of the post type that may need to be highlighted
1682
+	 * echo The javascript to open and highlight the Formidable menu
1683
+	 */
1684 1684
 	public static function maybe_highlight_menu( $post_type ) {
1685
-        global $post;
1685
+		global $post;
1686 1686
 
1687
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1688
-            return;
1689
-        }
1687
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1688
+			return;
1689
+		}
1690 1690
 
1691
-        if ( is_object($post) && $post->post_type != $post_type ) {
1692
-            return;
1693
-        }
1691
+		if ( is_object($post) && $post->post_type != $post_type ) {
1692
+			return;
1693
+		}
1694 1694
 
1695
-        self::load_admin_wide_js();
1696
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1697
-    }
1695
+		self::load_admin_wide_js();
1696
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1697
+	}
1698 1698
 
1699
-    /**
1700
-     * Load the JS file on non-Formidable pages in the admin area
1701
-     * @since 2.0
1702
-     */
1699
+	/**
1700
+	 * Load the JS file on non-Formidable pages in the admin area
1701
+	 * @since 2.0
1702
+	 */
1703 1703
 	public static function load_admin_wide_js( $load = true ) {
1704
-        $version = FrmAppHelper::plugin_version();
1704
+		$version = FrmAppHelper::plugin_version();
1705 1705
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1706 1706
 
1707
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1707
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1708 1708
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1709
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1709
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1710 1710
 			'url'          => FrmAppHelper::plugin_url(),
1711 1711
 			'loading'      => __( 'Loading&hellip;' ),
1712 1712
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1713
-        ) );
1713
+		) );
1714 1714
 
1715 1715
 		if ( $load ) {
1716 1716
 			wp_enqueue_script( 'formidable_admin_global' );
1717 1717
 		}
1718
-    }
1718
+	}
1719 1719
 
1720 1720
 	/**
1721 1721
 	 * @since 2.0.9
@@ -1724,9 +1724,9 @@  discard block
 block discarded – undo
1724 1724
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1725 1725
 	}
1726 1726
 
1727
-    /**
1728
-     * @param string $location
1729
-     */
1727
+	/**
1728
+	 * @param string $location
1729
+	 */
1730 1730
 	public static function localize_script( $location ) {
1731 1731
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1732 1732
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1779,81 +1779,81 @@  discard block
 block discarded – undo
1779 1779
 		}
1780 1780
 	}
1781 1781
 
1782
-    /**
1782
+	/**
1783 1783
 	 * echo the message on the plugins listing page
1784
-     * @since 1.07.10
1785
-     *
1786
-     * @param float $min_version The version the add-on requires
1787
-     */
1784
+	 * @since 1.07.10
1785
+	 *
1786
+	 * @param float $min_version The version the add-on requires
1787
+	 */
1788 1788
 	public static function min_version_notice( $min_version ) {
1789
-        $frm_version = self::plugin_version();
1789
+		$frm_version = self::plugin_version();
1790 1790
 
1791
-        // check if Formidable meets minimum requirements
1792
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1793
-            return;
1794
-        }
1791
+		// check if Formidable meets minimum requirements
1792
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1793
+			return;
1794
+		}
1795 1795
 
1796
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1796
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1797 1797
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1798
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1799
-        '</div></td></tr>';
1800
-    }
1801
-
1802
-    public static function locales( $type = 'date' ) {
1803
-        $locales = array(
1804
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1805
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1806
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1807
-            'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1808
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1809
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1810
-            'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1811
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1812
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1813
-            'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1814
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1815
-            'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1816
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1817
-            'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1818
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1819
-            'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1820
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1821
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1822
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1823
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1824
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1825
-            'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1826
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1827
-            'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1828
-            'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1829
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1830
-            'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1831
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1832
-            'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1833
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1834
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1835
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1836
-        );
1837
-
1838
-        if ( $type == 'captcha' ) {
1839
-            // remove the languages unavailable for the captcha
1840
-            $unset = array(
1841
-                '', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1842
-                'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1843
-                'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1844
-            );
1845
-        } else {
1846
-            // remove the languages unavailable for the datepicker
1847
-            $unset = array(
1848
-                'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1849
-                'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1850
-                'es-419', 'tr',
1851
-            );
1852
-        }
1853
-
1854
-        $locales = array_diff_key($locales, array_flip($unset));
1855
-        $locales = apply_filters('frm_locales', $locales);
1856
-
1857
-        return $locales;
1858
-    }
1798
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1799
+		'</div></td></tr>';
1800
+	}
1801
+
1802
+	public static function locales( $type = 'date' ) {
1803
+		$locales = array(
1804
+			'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1805
+			'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1806
+			'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1807
+			'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1808
+			'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1809
+			'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1810
+			'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1811
+			'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1812
+			'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1813
+			'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1814
+			'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1815
+			'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1816
+			'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1817
+			'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1818
+			'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1819
+			'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1820
+			'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1821
+			'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1822
+			'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1823
+			'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1824
+			'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1825
+			'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1826
+			'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1827
+			'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1828
+			'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1829
+			'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1830
+			'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1831
+			'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1832
+			'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1833
+			'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1834
+			'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1835
+			'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1836
+		);
1837
+
1838
+		if ( $type == 'captcha' ) {
1839
+			// remove the languages unavailable for the captcha
1840
+			$unset = array(
1841
+				'', 'af', 'sq', 'hy', 'az', 'eu', 'bs',
1842
+				'zh-HK', 'eo', 'et', 'fo', 'fr-CH',
1843
+				'he', 'is', 'ms', 'sr-SR', 'ta', 'tu',
1844
+			);
1845
+		} else {
1846
+			// remove the languages unavailable for the datepicker
1847
+			$unset = array(
1848
+				'en', 'fil', 'fr-CA', 'de-AT', 'de-AT',
1849
+				'de-CH', 'iw', 'hi', 'pt', 'pt-PT',
1850
+				'es-419', 'tr',
1851
+			);
1852
+		}
1853
+
1854
+		$locales = array_diff_key($locales, array_flip($unset));
1855
+		$locales = apply_filters('frm_locales', $locales);
1856
+
1857
+		return $locales;
1858
+	}
1859 1859
 }
Please login to merge, or discard this patch.
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     public static function plugin_folder() {
26
-        return basename(self::plugin_path());
26
+        return basename( self::plugin_path() );
27 27
     }
28 28
 
29 29
     public static function plugin_path() {
30
-        return dirname(dirname(dirname(__FILE__)));
30
+        return dirname( dirname( dirname( __FILE__ ) ) );
31 31
     }
32 32
 
33 33
     public static function plugin_url() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @return string
55 55
      */
56 56
     public static function site_name() {
57
-        return get_option('blogname');
57
+        return get_option( 'blogname' );
58 58
     }
59 59
 
60 60
 	public static function make_affiliate_url( $url ) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 	public static function get_affiliate() {
69 69
 		return '';
70
-		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') );
70
+		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) );
71 71
 		$affiliate_id = strtolower( $affiliate_id );
72 72
 		$allowed_affiliates = array();
73 73
 		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function get_settings() {
88 88
         global $frm_settings;
89
-        if ( empty($frm_settings) ) {
89
+        if ( empty( $frm_settings ) ) {
90 90
             $frm_settings = new FrmSettings();
91 91
         }
92 92
         return $frm_settings;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     }
108 108
 
109 109
     public static function pro_is_installed() {
110
-        return apply_filters('frm_pro_installed', false);
110
+        return apply_filters( 'frm_pro_installed', false );
111 111
     }
112 112
 
113 113
     /**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @return boolean
152 152
      */
153 153
     public static function doing_ajax() {
154
-        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page();
154
+        return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page();
155 155
     }
156 156
 
157 157
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return boolean
172 172
      */
173 173
     public static function is_admin() {
174
-        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX );
174
+        return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
175 175
     }
176 176
 
177 177
     /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return string
199 199
      */
200 200
 	public static function get_server_value( $value ) {
201
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
201
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
202 202
     }
203 203
 
204 204
     /**
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP',
214 214
             'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR',
215 215
         ) as $key ) {
216
-            if ( ! isset( $_SERVER[ $key ] ) ) {
216
+            if ( ! isset( $_SERVER[$key] ) ) {
217 217
                 continue;
218 218
             }
219 219
 
220
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
221
-                $ip = trim($ip); // just to be safe
220
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
221
+                $ip = trim( $ip ); // just to be safe
222 222
 
223
-                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) {
223
+                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
224 224
                     return $ip;
225 225
                 }
226 226
             }
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
     }
231 231
 
232 232
     public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
233
-        if ( strpos($param, '[') ) {
234
-            $params = explode('[', $param);
233
+        if ( strpos( $param, '[' ) ) {
234
+            $params = explode( '[', $param );
235 235
             $param = $params[0];
236 236
         }
237 237
 
238 238
 		if ( $src == 'get' ) {
239
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
240
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
241
-                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) );
239
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
240
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
241
+                $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) );
242 242
             }
243 243
 			self::sanitize_value( $sanitize, $value );
244 244
 		} else {
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 
248 248
 		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
249 249
             foreach ( $params as $k => $p ) {
250
-                if ( ! $k || ! is_array($value) ) {
250
+                if ( ! $k || ! is_array( $value ) ) {
251 251
                     continue;
252 252
                 }
253 253
 
254
-                $p = trim($p, ']');
255
-                $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
254
+                $p = trim( $p, ']' );
255
+                $value = isset( $value[$p] ) ? $value[$p] : $default;
256 256
             }
257 257
         }
258 258
 
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$value = $args['default'];
293 293
 		if ( $args['type'] == 'get' ) {
294
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
295
-				$value = $_GET[ $args['param'] ];
294
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
295
+				$value = $_GET[$args['param']];
296 296
 			}
297 297
 		} else if ( $args['type'] == 'post' ) {
298
-			if ( isset( $_POST[ $args['param'] ] ) ) {
299
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
298
+			if ( isset( $_POST[$args['param']] ) ) {
299
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
300 300
 			}
301 301
 		} else {
302
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
303
-				$value = $_REQUEST[ $args['param'] ];
302
+			if ( isset( $_REQUEST[$args['param']] ) ) {
303
+				$value = $_REQUEST[$args['param']];
304 304
 			}
305 305
 		}
306 306
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			if ( is_array( $value ) ) {
329 329
 				$temp_values = $value;
330 330
 				foreach ( $temp_values as $k => $v ) {
331
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
331
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
332 332
 				}
333 333
 			} else {
334 334
 				$value = call_user_func( $sanitize, $value );
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     public static function sanitize_request( $sanitize_method, &$values ) {
340 340
         $temp_values = $values;
341 341
         foreach ( $temp_values as $k => $val ) {
342
-            if ( isset( $sanitize_method[ $k ] ) ) {
343
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
342
+            if ( isset( $sanitize_method[$k] ) ) {
343
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
344 344
             }
345 345
         }
346 346
     }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	public static function sanitize_array( &$values ) {
349 349
 		$temp_values = $values;
350 350
 		foreach ( $temp_values as $k => $val ) {
351
-			$values[ $k ] = wp_kses_post( $val );
351
+			$values[$k] = wp_kses_post( $val );
352 352
 		}
353 353
 	}
354 354
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 		$allowed_html = array();
373 373
 		foreach ( $allowed as $a ) {
374
-			$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
374
+			$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
375 375
 		}
376 376
 
377 377
 		return wp_kses( $value, $allowed_html );
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      * @since 2.0
383 383
      */
384 384
     public static function remove_get_action() {
385
-        if ( ! isset($_GET) ) {
385
+        if ( ! isset( $_GET ) ) {
386 386
             return;
387 387
         }
388 388
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
         }
405 405
 
406 406
         global $wp_query;
407
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
408
-            $value = $wp_query->query_vars[ $param ];
407
+        if ( isset( $wp_query->query_vars[$param] ) ) {
408
+            $value = $wp_query->query_vars[$param];
409 409
         }
410 410
 
411 411
         return $value;
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
      * @return mixed $results The cache or query results
435 435
      */
436 436
     public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
437
-        $results = wp_cache_get($cache_key, $group);
438
-        if ( ! self::is_empty_value( $results, false ) || empty($query) ) {
437
+        $results = wp_cache_get( $cache_key, $group );
438
+        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) {
439 439
             return $results;
440 440
         }
441 441
 
442 442
         if ( 'get_posts' == $type ) {
443
-            $results = get_posts($query);
443
+            $results = get_posts( $query );
444 444
 		} else if ( 'get_associative_results' == $type ) {
445 445
 			global $wpdb;
446 446
 			$results = $wpdb->get_results( $query, OBJECT_K );
447 447
         } else {
448 448
             global $wpdb;
449
-            $results = $wpdb->{$type}($query);
449
+            $results = $wpdb->{$type}( $query );
450 450
         }
451 451
 
452 452
 		self::set_cache( $cache_key, $results, $group, $time );
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public static function add_key_to_group_cache( $key, $group ) {
469 469
 		$cached = self::get_group_cached_keys( $group );
470
-		$cached[ $key ] = $key;
470
+		$cached[$key] = $key;
471 471
 		wp_cache_set( 'cached_keys', $cached, $group, 300 );
472 472
 	}
473 473
 
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
         }
494 494
 
495 495
         // then check the transient
496
-        $results = get_transient($cache_key);
496
+        $results = get_transient( $cache_key );
497 497
         if ( $results ) {
498
-            wp_cache_set($cache_key, $results);
498
+            wp_cache_set( $cache_key, $results );
499 499
         }
500 500
 
501 501
         return $results;
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param string $cache_key
507 507
      */
508 508
 	public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
509
-		delete_transient($cache_key);
509
+		delete_transient( $cache_key );
510 510
 		wp_cache_delete( $cache_key, $group );
511 511
 	}
512 512
 
@@ -548,17 +548,17 @@  discard block
 block discarded – undo
548 548
     }
549 549
 
550 550
     public static function get_pages() {
551
-		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
551
+		return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) );
552 552
     }
553 553
 
554 554
     public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
555 555
         $pages = self::get_pages();
556 556
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
557 557
     ?>
558
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown">
558
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
559 559
             <option value=""> </option>
560 560
             <?php foreach ( $pages as $page ) { ?>
561
-				<option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>>
561
+				<option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>>
562 562
 					<?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?>
563 563
 				</option>
564 564
             <?php } ?>
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     }
568 568
 
569 569
 	public static function post_edit_link( $post_id ) {
570
-        $post = get_post($post_id);
570
+        $post = get_post( $post_id );
571 571
         if ( $post ) {
572 572
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
573 573
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -577,17 +577,17 @@  discard block
 block discarded – undo
577 577
 
578 578
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
579 579
     ?>
580
-        <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php
580
+        <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php
581 581
             echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : '';
582 582
             ?> class="frm_multiselect">
583
-            <?php self::roles_options($capability); ?>
583
+            <?php self::roles_options( $capability ); ?>
584 584
         </select>
585 585
     <?php
586 586
     }
587 587
 
588 588
 	public static function roles_options( $capability ) {
589 589
         global $frm_vars;
590
-        if ( isset($frm_vars['editable_roles']) ) {
590
+        if ( isset( $frm_vars['editable_roles'] ) ) {
591 591
             $editable_roles = $frm_vars['editable_roles'];
592 592
         } else {
593 593
             $editable_roles = get_editable_roles();
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
         }
596 596
 
597 597
         foreach ( $editable_roles as $role => $details ) {
598
-            $name = translate_user_role($details['name'] ); ?>
599
-        <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option>
598
+            $name = translate_user_role( $details['name'] ); ?>
599
+        <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option>
600 600
 <?php
601
-            unset($role, $details);
601
+            unset( $role, $details );
602 602
         }
603 603
     }
604 604
 
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     public static function maybe_add_permissions() {
655 655
 		self::force_capability( 'frm_view_entries' );
656 656
 
657
-        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) {
657
+        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
658 658
             return;
659 659
         }
660 660
 
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
         $frm_roles = self::frm_capabilities();
664 664
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
665 665
 			$user->add_cap( $frm_role );
666
-            unset($frm_role, $frm_role_description);
666
+            unset( $frm_role, $frm_role_description );
667 667
         }
668 668
     }
669 669
 
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
      * @param string $permission
689 689
      */
690 690
 	public static function permission_check( $permission, $show_message = 'show' ) {
691
-        $permission_error = self::permission_nonce_error($permission);
691
+        $permission_error = self::permission_nonce_error( $permission );
692 692
         if ( $permission_error !== false ) {
693 693
             if ( 'hide' == $show_message ) {
694 694
                 $permission_error = '';
695 695
             }
696
-            wp_die($permission_error);
696
+            wp_die( $permission_error );
697 697
         }
698 698
     }
699 699
 
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 		}
711 711
 
712 712
 		$error = false;
713
-        if ( empty($nonce_name) ) {
713
+        if ( empty( $nonce_name ) ) {
714 714
             return $error;
715 715
         }
716 716
 
717
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
717
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
718 718
             $frm_settings = self::get_settings();
719 719
             $error = $frm_settings->admin_permission;
720 720
         }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 			} else {
795 795
 				foreach ( $value as $k => $v ) {
796 796
 					if ( ! is_array( $v ) ) {
797
-						$value[ $k ] = call_user_func( $original_function, $v );
797
+						$value[$k] = call_user_func( $original_function, $v );
798 798
 					}
799 799
 				}
800 800
 			}
@@ -815,11 +815,11 @@  discard block
 block discarded – undo
815 815
 	public static function array_flatten( $array, $keys = 'keep' ) {
816 816
         $return = array();
817 817
         foreach ( $array as $key => $value ) {
818
-            if ( is_array($value) ) {
818
+            if ( is_array( $value ) ) {
819 819
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
820 820
             } else {
821 821
 				if ( $keys == 'keep' ) {
822
-					$return[ $key ] = $value;
822
+					$return[$key] = $value;
823 823
 				} else {
824 824
 					$return[] = $value;
825 825
 				}
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
      * @since 2.0
843 843
      */
844 844
 	public static function use_wpautop( $content ) {
845
-        if ( apply_filters('frm_use_wpautop', true) ) {
846
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
845
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
846
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
847 847
         }
848 848
         return $content;
849 849
     }
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
      * @return string The base Google APIS url for the current version of jQuery UI
862 862
      */
863 863
     public static function jquery_ui_base_url() {
864
-		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core');
865
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
864
+		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' );
865
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
866 866
         return $url;
867 867
     }
868 868
 
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
 
878 878
         $ver = 0;
879 879
 
880
-        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
880
+        if ( ! isset( $wp_scripts->registered[$handle] ) ) {
881 881
             return $ver;
882 882
         }
883 883
 
884
-        $query = $wp_scripts->registered[ $handle ];
884
+        $query = $wp_scripts->registered[$handle];
885 885
     	if ( is_object( $query ) ) {
886 886
     	    $ver = $query->ver;
887 887
     	}
@@ -894,36 +894,36 @@  discard block
 block discarded – undo
894 894
     }
895 895
 
896 896
 	public static function get_user_id_param( $user_id ) {
897
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
897
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
898 898
             return $user_id;
899 899
         }
900 900
 
901 901
 		if ( $user_id == 'current' ) {
902 902
 			$user_id = get_current_user_id();
903 903
 		} else {
904
-            if ( is_email($user_id) ) {
905
-                $user = get_user_by('email', $user_id);
904
+            if ( is_email( $user_id ) ) {
905
+                $user = get_user_by( 'email', $user_id );
906 906
             } else {
907
-                $user = get_user_by('login', $user_id);
907
+                $user = get_user_by( 'login', $user_id );
908 908
             }
909 909
 
910 910
             if ( $user ) {
911 911
                 $user_id = $user->ID;
912 912
             }
913
-            unset($user);
913
+            unset( $user );
914 914
         }
915 915
 
916 916
         return $user_id;
917 917
     }
918 918
 
919 919
 	public static function get_file_contents( $filename, $atts = array() ) {
920
-        if ( ! is_file($filename) ) {
920
+        if ( ! is_file( $filename ) ) {
921 921
             return false;
922 922
         }
923 923
 
924
-        extract($atts);
924
+        extract( $atts );
925 925
         ob_start();
926
-        include($filename);
926
+        include( $filename );
927 927
         $contents = ob_get_contents();
928 928
         ob_end_clean();
929 929
         return $contents;
@@ -939,28 +939,28 @@  discard block
 block discarded – undo
939 939
         $key = '';
940 940
 
941 941
         if ( ! empty( $name ) ) {
942
-            $key = sanitize_key($name);
942
+            $key = sanitize_key( $name );
943 943
         }
944 944
 
945 945
 		if ( empty( $key ) ) {
946
-            $max_slug_value = pow(36, $num_chars);
946
+            $max_slug_value = pow( 36, $num_chars );
947 947
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
948
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
948
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
949 949
         }
950 950
 
951
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
951
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
952 952
 			$key = $key . 'a';
953 953
         }
954 954
 
955 955
 		$key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column );
956 956
 
957
-        if ( $key_check || is_numeric($key_check) ) {
957
+        if ( $key_check || is_numeric( $key_check ) ) {
958 958
             $suffix = 2;
959 959
 			do {
960 960
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
961 961
 				$key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column );
962
-				$suffix++;
963
-			} while ($key_check || is_numeric($key_check));
962
+				$suffix ++;
963
+			} while ( $key_check || is_numeric( $key_check ) );
964 964
 			$key = $alt_post_name;
965 965
         }
966 966
         return $key;
@@ -976,32 +976,32 @@  discard block
 block discarded – undo
976 976
             return false;
977 977
         }
978 978
 
979
-        if ( empty($post_values) ) {
980
-            $post_values = stripslashes_deep($_POST);
979
+        if ( empty( $post_values ) ) {
980
+            $post_values = stripslashes_deep( $_POST );
981 981
         }
982 982
 
983 983
 		$values = array( 'id' => $record->id, 'fields' => array() );
984 984
 
985 985
 		foreach ( array( 'name', 'description' ) as $var ) {
986
-            $default_val = isset($record->{$var}) ? $record->{$var} : '';
987
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
988
-            unset($var, $default_val);
986
+            $default_val = isset( $record->{$var}) ? $record->{$var} : '';
987
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
988
+            unset( $var, $default_val );
989 989
         }
990 990
 
991
-        $values['description'] = self::use_wpautop($values['description']);
991
+        $values['description'] = self::use_wpautop( $values['description'] );
992 992
         $frm_settings = self::get_settings();
993
-        $is_form_builder = self::is_admin_page('formidable' );
993
+        $is_form_builder = self::is_admin_page( 'formidable' );
994 994
 
995 995
         foreach ( (array) $fields as $field ) {
996 996
             // Make sure to filter default values (for placeholder text), but not on the form builder page
997 997
             if ( ! $is_form_builder ) {
998
-                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
998
+                $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
999 999
             }
1000 1000
 			$parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1001
-			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1001
+			self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) );
1002 1002
         }
1003 1003
 
1004
-        self::fill_form_opts($record, $table, $post_values, $values);
1004
+        self::fill_form_opts( $record, $table, $post_values, $values );
1005 1005
 
1006 1006
         if ( $table == 'entries' ) {
1007 1007
             $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
@@ -1018,8 +1018,8 @@  discard block
 block discarded – undo
1018 1018
         if ( $args['default'] ) {
1019 1019
             $meta_value = $field->default_value;
1020 1020
         } else {
1021
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1022
-                if ( ! isset($field->field_options['custom_field']) ) {
1021
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1022
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1023 1023
                     $field->field_options['custom_field'] = '';
1024 1024
                 }
1025 1025
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) );
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
             }
1029 1029
         }
1030 1030
 
1031
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1032
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1031
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1032
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1033 1033
 
1034 1034
         $field_array = array(
1035 1035
             'id'            => $field->id,
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
             'default_value' => $field->default_value,
1038 1038
             'name'          => $field->name,
1039 1039
             'description'   => $field->description,
1040
-            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value),
1040
+            'type'          => apply_filters( 'frm_field_type', $field_type, $field, $new_value ),
1041 1041
             'options'       => $field->options,
1042 1042
             'required'      => $field->required,
1043 1043
             'field_key'     => $field->field_key,
@@ -1047,40 +1047,40 @@  discard block
 block discarded – undo
1047 1047
         );
1048 1048
 
1049 1049
         $args['field_type'] = $field_type;
1050
-        self::fill_field_opts($field, $field_array, $args);
1050
+        self::fill_field_opts( $field, $field_array, $args );
1051 1051
 		// Track the original field's type
1052 1052
 		$field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type;
1053 1053
 
1054 1054
         $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() );
1055 1055
 
1056
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1056
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1057 1057
             $field_array['unique_msg'] = '';
1058 1058
         }
1059 1059
 
1060 1060
         $field_array = array_merge( $field->field_options, $field_array );
1061 1061
 
1062
-        $values['fields'][ $field->id ] = $field_array;
1062
+        $values['fields'][$field->id] = $field_array;
1063 1063
     }
1064 1064
 
1065 1065
 	private static function fill_field_opts( $field, array &$field_array, $args ) {
1066 1066
         $post_values = $args['post_values'];
1067
-        $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
1067
+        $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
1068 1068
 
1069 1069
         foreach ( $opt_defaults as $opt => $default_opt ) {
1070
-			$field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt );
1071
-            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) {
1072
-                $field_array[ $opt ] = $args['frm_settings']->blank_msg;
1073
-            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) {
1070
+			$field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt );
1071
+            if ( $opt == 'blank' && $field_array[$opt] == '' ) {
1072
+                $field_array[$opt] = $args['frm_settings']->blank_msg;
1073
+            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) {
1074 1074
                 if ( $args['field_type'] == 'captcha' ) {
1075
-                    $field_array[ $opt ] = $args['frm_settings']->re_msg;
1075
+                    $field_array[$opt] = $args['frm_settings']->re_msg;
1076 1076
                 } else {
1077
-                    $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1077
+                    $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] );
1078 1078
                 }
1079 1079
             }
1080 1080
         }
1081 1081
 
1082 1082
         if ( $field_array['custom_html'] == '' ) {
1083
-            $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
1083
+            $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] );
1084 1084
         }
1085 1085
     }
1086 1086
 
@@ -1099,18 +1099,18 @@  discard block
 block discarded – undo
1099 1099
             return;
1100 1100
         }
1101 1101
 
1102
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1102
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1103 1103
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1104 1104
 
1105
-        if ( ! is_array($form->options) ) {
1105
+        if ( ! is_array( $form->options ) ) {
1106 1106
             return;
1107 1107
         }
1108 1108
 
1109 1109
         foreach ( $form->options as $opt => $value ) {
1110
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1110
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1111 1111
         }
1112 1112
 
1113
-        self::fill_form_defaults($post_values, $values);
1113
+        self::fill_form_defaults( $post_values, $values );
1114 1114
     }
1115 1115
 
1116 1116
     /**
@@ -1120,23 +1120,23 @@  discard block
 block discarded – undo
1120 1120
         $form_defaults = FrmFormsHelper::get_default_opts();
1121 1121
 
1122 1122
         foreach ( $form_defaults as $opt => $default ) {
1123
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1124
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1123
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1124
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1125 1125
             }
1126 1126
 
1127
-            unset($opt, $defaut);
1127
+            unset( $opt, $defaut );
1128 1128
         }
1129 1129
 
1130
-        if ( ! isset($values['custom_style']) ) {
1130
+        if ( ! isset( $values['custom_style'] ) ) {
1131 1131
             $frm_settings = self::get_settings();
1132 1132
 			$values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' );
1133 1133
         }
1134 1134
 
1135 1135
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1136
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1137
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1136
+			if ( ! isset( $values[$h . '_html'] ) ) {
1137
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1138 1138
             }
1139
-            unset($h);
1139
+            unset( $h );
1140 1140
         }
1141 1141
     }
1142 1142
 
@@ -1152,9 +1152,9 @@  discard block
 block discarded – undo
1152 1152
         }
1153 1153
     ?>
1154 1154
 <li>
1155
-    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1156
-    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a>
1157
-    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a>
1155
+    <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a>
1156
+    <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a>
1157
+    <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a>
1158 1158
 </li>
1159 1159
     <?php
1160 1160
     }
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
             return '';
1173 1173
         } else if ( $length <= 10 ) {
1174 1174
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1175
-            return $sub . (($length < $original_len) ? $continue : '');
1175
+            return $sub . ( ( $length < $original_len ) ? $continue : '' );
1176 1176
         }
1177 1177
 
1178 1178
         $sub = '';
@@ -1181,23 +1181,23 @@  discard block
 block discarded – undo
1181 1181
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1182 1182
 
1183 1183
 		foreach ( $words as $word ) {
1184
-            $part = (($sub != '') ? ' ' : '') . $word;
1184
+            $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1185 1185
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1186
-            if ( $total_len > $length && str_word_count($sub) ) {
1186
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1187 1187
                 break;
1188 1188
             }
1189 1189
 
1190 1190
             $sub .= $part;
1191 1191
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1192 1192
 
1193
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1193
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1194 1194
                 break;
1195 1195
             }
1196 1196
 
1197
-            unset($total_len, $word);
1197
+            unset( $total_len, $word );
1198 1198
         }
1199 1199
 
1200
-        return $sub . (($len < $original_len) ? $continue : '');
1200
+        return $sub . ( ( $len < $original_len ) ? $continue : '' );
1201 1201
     }
1202 1202
 
1203 1203
 	public static function mb_function( $function_names, $args ) {
@@ -1210,17 +1210,17 @@  discard block
 block discarded – undo
1210 1210
 	}
1211 1211
 
1212 1212
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1213
-        if ( empty($date) ) {
1213
+        if ( empty( $date ) ) {
1214 1214
             return $date;
1215 1215
         }
1216 1216
 
1217
-        if ( empty($date_format) ) {
1218
-            $date_format = get_option('date_format');
1217
+        if ( empty( $date_format ) ) {
1218
+            $date_format = get_option( 'date_format' );
1219 1219
         }
1220 1220
 
1221
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1221
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1222 1222
             $frmpro_settings = new FrmProSettings();
1223
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1223
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1224 1224
         }
1225 1225
 
1226 1226
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 
1236 1236
 	private static function add_time_to_date( $time_format, $date ) {
1237 1237
 		if ( empty( $time_format ) ) {
1238
-			$time_format = get_option('time_format');
1238
+			$time_format = get_option( 'time_format' );
1239 1239
 		}
1240 1240
 
1241 1241
 		$trimmed_format = trim( $time_format );
@@ -1281,10 +1281,10 @@  discard block
 block discarded – undo
1281 1281
 		$time_strings = self::get_time_strings();
1282 1282
 
1283 1283
 		foreach ( $time_strings as $k => $v ) {
1284
-			if ( $diff[ $k ] ) {
1285
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1284
+			if ( $diff[$k] ) {
1285
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1286 1286
 			} else {
1287
-				unset( $time_strings[ $k ] );
1287
+				unset( $time_strings[$k] );
1288 1288
 			}
1289 1289
 		}
1290 1290
 
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
      */
1323 1323
 	public static function esc_like( $term ) {
1324 1324
         global $wpdb;
1325
-        if ( method_exists($wpdb, 'esc_like') ) {
1325
+        if ( method_exists( $wpdb, 'esc_like' ) ) {
1326 1326
 			// WP 4.0
1327 1327
             $term = $wpdb->esc_like( $term );
1328 1328
         } else {
@@ -1336,17 +1336,17 @@  discard block
 block discarded – undo
1336 1336
      * @param string $order_query
1337 1337
      */
1338 1338
 	public static function esc_order( $order_query ) {
1339
-        if ( empty($order_query) ) {
1339
+        if ( empty( $order_query ) ) {
1340 1340
             return '';
1341 1341
         }
1342 1342
 
1343 1343
         // remove ORDER BY before santizing
1344
-        $order_query = strtolower($order_query);
1345
-        if ( strpos($order_query, 'order by') !== false ) {
1346
-            $order_query = str_replace('order by', '', $order_query);
1344
+        $order_query = strtolower( $order_query );
1345
+        if ( strpos( $order_query, 'order by' ) !== false ) {
1346
+            $order_query = str_replace( 'order by', '', $order_query );
1347 1347
         }
1348 1348
 
1349
-        $order_query = explode(' ', trim($order_query));
1349
+        $order_query = explode( ' ', trim( $order_query ) );
1350 1350
 
1351 1351
         $order_fields = array(
1352 1352
             'id', 'form_key', 'name', 'description',
@@ -1354,13 +1354,13 @@  discard block
 block discarded – undo
1354 1354
             'default_template', 'status', 'created_at',
1355 1355
         );
1356 1356
 
1357
-        $order = trim(trim(reset($order_query), ','));
1358
-        if ( ! in_array($order, $order_fields) ) {
1357
+        $order = trim( trim( reset( $order_query ), ',' ) );
1358
+        if ( ! in_array( $order, $order_fields ) ) {
1359 1359
             return '';
1360 1360
         }
1361 1361
 
1362 1362
         $order_by = '';
1363
-        if ( count($order_query) > 1 ) {
1363
+        if ( count( $order_query ) > 1 ) {
1364 1364
 			$order_by = end( $order_query );
1365 1365
 			self::esc_order_by( $order_by );
1366 1366
         }
@@ -1382,23 +1382,23 @@  discard block
 block discarded – undo
1382 1382
      * @param string $limit
1383 1383
      */
1384 1384
 	public static function esc_limit( $limit ) {
1385
-        if ( empty($limit) ) {
1385
+        if ( empty( $limit ) ) {
1386 1386
             return '';
1387 1387
         }
1388 1388
 
1389
-        $limit = trim(str_replace(' limit', '', strtolower($limit)));
1390
-        if ( is_numeric($limit) ) {
1389
+        $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) );
1390
+        if ( is_numeric( $limit ) ) {
1391 1391
 			return ' LIMIT ' . $limit;
1392 1392
         }
1393 1393
 
1394
-        $limit = explode(',', trim($limit));
1394
+        $limit = explode( ',', trim( $limit ) );
1395 1395
         foreach ( $limit as $k => $l ) {
1396 1396
             if ( is_numeric( $l ) ) {
1397
-                $limit[ $k ] = $l;
1397
+                $limit[$k] = $l;
1398 1398
             }
1399 1399
         }
1400 1400
 
1401
-        $limit = implode(',', $limit);
1401
+        $limit = implode( ',', $limit );
1402 1402
 		return ' LIMIT ' . $limit;
1403 1403
     }
1404 1404
 
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
      * @since 2.0
1408 1408
      */
1409 1409
     public static function prepare_array_values( $array, $type = '%s' ) {
1410
-        $placeholders = array_fill(0, count($array), $type);
1411
-        return implode(', ', $placeholders);
1410
+        $placeholders = array_fill( 0, count( $array ), $type );
1411
+        return implode( ', ', $placeholders );
1412 1412
     }
1413 1413
 
1414 1414
     public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
1415
-        if ( empty($where) ) {
1415
+        if ( empty( $where ) ) {
1416 1416
             return '';
1417 1417
         }
1418 1418
 
@@ -1453,19 +1453,19 @@  discard block
 block discarded – undo
1453 1453
 	public static function json_to_array( $json_vars ) {
1454 1454
         $vars = array();
1455 1455
         foreach ( $json_vars as $jv ) {
1456
-            $jv_name = explode('[', $jv['name']);
1457
-            $last = count($jv_name) - 1;
1456
+            $jv_name = explode( '[', $jv['name'] );
1457
+            $last = count( $jv_name ) - 1;
1458 1458
             foreach ( $jv_name as $p => $n ) {
1459
-                $name = trim($n, ']');
1460
-                if ( ! isset($l1) ) {
1459
+                $name = trim( $n, ']' );
1460
+                if ( ! isset( $l1 ) ) {
1461 1461
                     $l1 = $name;
1462 1462
                 }
1463 1463
 
1464
-                if ( ! isset($l2) ) {
1464
+                if ( ! isset( $l2 ) ) {
1465 1465
                     $l2 = $name;
1466 1466
                 }
1467 1467
 
1468
-                if ( ! isset($l3) ) {
1468
+                if ( ! isset( $l3 ) ) {
1469 1469
                     $l3 = $name;
1470 1470
                 }
1471 1471
 
@@ -1479,24 +1479,24 @@  discard block
 block discarded – undo
1479 1479
 
1480 1480
                     case 1:
1481 1481
                         $l2 = $name;
1482
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1482
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1483 1483
                     break;
1484 1484
 
1485 1485
                     case 2:
1486 1486
                         $l3 = $name;
1487
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1487
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1488 1488
                     break;
1489 1489
 
1490 1490
                     case 3:
1491 1491
                         $l4 = $name;
1492
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1492
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1493 1493
                     break;
1494 1494
                 }
1495 1495
 
1496
-                unset($this_val, $n);
1496
+                unset( $this_val, $n );
1497 1497
             }
1498 1498
 
1499
-            unset($last, $jv);
1499
+            unset( $last, $jv );
1500 1500
         }
1501 1501
 
1502 1502
         return $vars;
@@ -1509,8 +1509,8 @@  discard block
 block discarded – undo
1509 1509
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1510 1510
         if ( $name == '' ) {
1511 1511
             $vars[] = $val;
1512
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1513
-            $vars[ $l1 ] = $val;
1512
+        } else if ( ! isset( $vars[$l1] ) ) {
1513
+            $vars[$l1] = $val;
1514 1514
         }
1515 1515
     }
1516 1516
 
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
             'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1526 1526
         );
1527 1527
 
1528
-        if ( ! isset( $tooltips[ $name ] ) ) {
1528
+        if ( ! isset( $tooltips[$name] ) ) {
1529 1529
             return;
1530 1530
         }
1531 1531
 
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
             echo ' class="frm_help"';
1536 1536
         }
1537 1537
 
1538
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1538
+		echo ' title="' . esc_attr( $tooltips[$name] );
1539 1539
 
1540 1540
         if ( 'open' != $class ) {
1541 1541
             echo '"';
@@ -1587,13 +1587,13 @@  discard block
 block discarded – undo
1587 1587
     }
1588 1588
 
1589 1589
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1590
-		if ( ! isset( $post_content[ $key ] ) ) {
1590
+		if ( ! isset( $post_content[$key] ) ) {
1591 1591
 			return;
1592 1592
 		}
1593 1593
 
1594 1594
 		if ( is_array( $val ) ) {
1595 1595
 			foreach ( $val as $k1 => $v1 ) {
1596
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1596
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1597 1597
 				unset( $k1, $v1 );
1598 1598
 			}
1599 1599
 		} else {
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 			$val = stripslashes( $val );
1602 1602
 
1603 1603
 			// Add backslashes before double quotes and forward slashes only
1604
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1604
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1605 1605
 		}
1606 1606
 	}
1607 1607
 
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 		$settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] );
1619 1619
 
1620 1620
 		if ( empty( $settings['ID'] ) ) {
1621
-			unset( $settings['ID']);
1621
+			unset( $settings['ID'] );
1622 1622
 		}
1623 1623
 
1624 1624
 		// delete all caches for this group
@@ -1652,17 +1652,17 @@  discard block
 block discarded – undo
1652 1652
 	}
1653 1653
 
1654 1654
 	public static function maybe_json_decode( $string ) {
1655
-        if ( is_array($string) ) {
1655
+        if ( is_array( $string ) ) {
1656 1656
             return $string;
1657 1657
         }
1658 1658
 
1659
-        $new_string = json_decode($string, true);
1660
-        if ( function_exists('json_last_error') ) {
1659
+        $new_string = json_decode( $string, true );
1660
+        if ( function_exists( 'json_last_error' ) ) {
1661 1661
 			// php 5.3+
1662 1662
             if ( json_last_error() == JSON_ERROR_NONE ) {
1663 1663
                 $string = $new_string;
1664 1664
             }
1665
-        } else if ( isset($new_string) ) {
1665
+        } else if ( isset( $new_string ) ) {
1666 1666
 			// php < 5.3 fallback
1667 1667
             $string = $new_string;
1668 1668
         }
@@ -1678,11 +1678,11 @@  discard block
 block discarded – undo
1678 1678
 	public static function maybe_highlight_menu( $post_type ) {
1679 1679
         global $post;
1680 1680
 
1681
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1681
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1682 1682
             return;
1683 1683
         }
1684 1684
 
1685
-        if ( is_object($post) && $post->post_type != $post_type ) {
1685
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1686 1686
             return;
1687 1687
         }
1688 1688
 
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
         $frm_version = self::plugin_version();
1784 1784
 
1785 1785
         // check if Formidable meets minimum requirements
1786
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1786
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1787 1787
             return;
1788 1788
         }
1789 1789
 
1790
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1790
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1791 1791
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1792 1792
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1793 1793
         '</div></td></tr>';
@@ -1795,38 +1795,38 @@  discard block
 block discarded – undo
1795 1795
 
1796 1796
     public static function locales( $type = 'date' ) {
1797 1797
         $locales = array(
1798
-            'en' => __( 'English', 'formidable' ),    '' => __( 'English/Western', 'formidable' ),
1799
-            'af' => __( 'Afrikaans', 'formidable' ),  'sq' => __( 'Albanian', 'formidable' ),
1800
-            'ar' => __( 'Arabic', 'formidable' ),     'hy' => __( 'Armenian', 'formidable' ),
1798
+            'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ),
1799
+            'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ),
1800
+            'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ),
1801 1801
             'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ),
1802
-            'bs' => __( 'Bosnian', 'formidable' ),    'bg' => __( 'Bulgarian', 'formidable' ),
1803
-            'ca' => __( 'Catalan', 'formidable' ),    'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1802
+            'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ),
1803
+            'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
1804 1804
             'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ),
1805
-            'hr' => __( 'Croatian', 'formidable' ),   'cs' => __( 'Czech', 'formidable' ),
1806
-            'da' => __( 'Danish', 'formidable' ),     'nl' => __( 'Dutch', 'formidable' ),
1805
+            'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ),
1806
+            'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ),
1807 1807
             'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ),
1808
-            'et' => __( 'Estonian', 'formidable' ),   'fo' => __( 'Faroese', 'formidable' ),
1808
+            'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ),
1809 1809
             'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ),
1810
-            'fi' => __( 'Finnish', 'formidable' ),    'fr' => __( 'French', 'formidable' ),
1810
+            'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ),
1811 1811
             'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ),
1812
-            'de' => __( 'German', 'formidable' ),     'de-AT' => __( 'German/Austria', 'formidable' ),
1812
+            'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ),
1813 1813
             'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ),
1814
-            'he' => __( 'Hebrew', 'formidable' ),     'iw' => __( 'Hebrew', 'formidable' ),
1815
-            'hi' => __( 'Hindi', 'formidable' ),      'hu' => __( 'Hungarian', 'formidable' ),
1816
-            'is' => __( 'Icelandic', 'formidable' ),  'id' => __( 'Indonesian', 'formidable' ),
1817
-            'it' => __( 'Italian', 'formidable' ),    'ja' => __( 'Japanese', 'formidable' ),
1818
-            'ko' => __( 'Korean', 'formidable' ),     'lv' => __( 'Latvian', 'formidable' ),
1814
+            'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ),
1815
+            'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ),
1816
+            'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ),
1817
+            'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ),
1818
+            'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ),
1819 1819
             'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ),
1820
-            'no' => __( 'Norwegian', 'formidable' ),  'pl' => __( 'Polish', 'formidable' ),
1820
+            'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ),
1821 1821
             'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
1822 1822
             'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ),
1823
-            'ru' => __( 'Russian', 'formidable' ),    'sr' => __( 'Serbian', 'formidable' ),
1823
+            'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ),
1824 1824
             'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ),
1825
-            'sl' => __( 'Slovenian', 'formidable' ),  'es' => __( 'Spanish', 'formidable' ),
1825
+            'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ),
1826 1826
             'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ),
1827
-            'ta' => __( 'Tamil', 'formidable' ),      'th' => __( 'Thai', 'formidable' ),
1828
-            'tu' => __( 'Turkish', 'formidable' ),    'tr' => __( 'Turkish', 'formidable' ),
1829
-            'uk' => __( 'Ukranian', 'formidable' ),   'vi' => __( 'Vietnamese', 'formidable' ),
1827
+            'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ),
1828
+            'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ),
1829
+            'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ),
1830 1830
         );
1831 1831
 
1832 1832
         if ( $type == 'captcha' ) {
@@ -1845,8 +1845,8 @@  discard block
 block discarded – undo
1845 1845
             );
1846 1846
         }
1847 1847
 
1848
-        $locales = array_diff_key($locales, array_flip($unset));
1849
-        $locales = apply_filters('frm_locales', $locales);
1848
+        $locales = array_diff_key( $locales, array_flip( $unset ) );
1849
+        $locales = apply_filters( 'frm_locales', $locales );
1850 1850
 
1851 1851
         return $locales;
1852 1852
     }
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
         $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
140
-				$new_values[ $value_key ] = $value;
139
+            if ( in_array( $value_key, $form_fields ) ) {
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,54 +191,54 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
228
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
229 229
 			if ( $is_settings_page ) {
230 230
                 //updating the settings page
231
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
231
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
232
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235 235
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236 236
                     $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
238 238
                     if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240 240
                     }
241
-                    unset($prev_opts);
241
+                    unset( $prev_opts );
242 242
                 }
243 243
             }
244 244
 
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
255
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
256 256
             }
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260
-			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
261
-			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
262
-			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
263
-			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
258
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
259
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
260
+			$field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
261
+			$required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false;
262
+			$field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type;
263
+			$field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description;
264 264
 
265
-            FrmField::update($field_id, array(
265
+            FrmField::update( $field_id, array(
266 266
                 'field_key' => $field_key, 'type' => $field_type,
267 267
                 'default_value' => $default_value, 'field_options' => $field->field_options,
268 268
                 'description' => $field_description, 'required' => $required,
269 269
             ) );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
271
+            FrmField::delete_form_transient( $field->form_id );
272 272
         }
273 273
 		self::clear_form_cache();
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
      */
282 282
 	public static function set_status( $id, $status ) {
283 283
         if ( 'trash' == $status ) {
284
-            return self::trash($id);
284
+            return self::trash( $id );
285 285
         }
286 286
 
287
-		$statuses  = array( 'published', 'draft', 'trash' );
287
+		$statuses = array( 'published', 'draft', 'trash' );
288 288
         if ( ! in_array( $status, $statuses ) ) {
289 289
             return false;
290 290
         }
291 291
 
292 292
         global $wpdb;
293 293
 
294
-        if ( is_array($id) ) {
294
+        if ( is_array( $id ) ) {
295 295
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
296 296
 			FrmDb::get_where_clause_and_values( $where );
297 297
 			array_unshift( $where['values'], $status );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             return self::destroy( $id );
318 318
         }
319 319
 
320
-        $form = self::getOne($id);
320
+        $form = self::getOne( $id );
321 321
         if ( ! $form ) {
322 322
             return false;
323 323
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	public static function destroy( $id ) {
352 352
         global $wpdb;
353 353
 
354
-        $form = self::getOne($id);
354
+        $form = self::getOne( $id );
355 355
         if ( ! $form ) {
356 356
             return false;
357 357
         }
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
         // Disconnect the entries from this form
361 361
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
362 362
         foreach ( $entries as $entry_id ) {
363
-            FrmEntry::destroy($entry_id);
364
-            unset($entry_id);
363
+            FrmEntry::destroy( $entry_id );
364
+            unset( $entry_id );
365 365
         }
366 366
 
367 367
         // Disconnect the fields from this form
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         if ( $query_results ) {
372 372
             // Delete all form actions linked to this form
373 373
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
374
-            $action_control->destroy($id, 'all');
374
+            $action_control->destroy( $id, 'all' );
375 375
 
376 376
 			// Clear form caching
377 377
 			self::clear_form_cache();
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			$form->options = maybe_unserialize( $form->options );
406 406
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
407 407
 				self::destroy( $form->id );
408
-				$count++;
408
+				$count ++;
409 409
 			}
410 410
 
411 411
 			unset( $form );
@@ -419,15 +419,15 @@  discard block
 block discarded – undo
419 419
     public static function &getName( $id ) {
420 420
         global $wpdb;
421 421
 
422
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
422
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
423 423
         if ( $form ) {
424
-            $r = stripslashes($form->name);
424
+            $r = stripslashes( $form->name );
425 425
             return $r;
426 426
         }
427 427
 
428 428
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
429 429
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
430
-        $r = stripslashes($r);
430
+        $r = stripslashes( $r );
431 431
 
432 432
         return $r;
433 433
     }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
      */
448 448
 	public static function &getKeyById( $id ) {
449 449
         $id = (int) $id;
450
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
450
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
451 451
         if ( $cache ) {
452 452
             return $cache->form_key;
453 453
         }
@@ -481,17 +481,17 @@  discard block
 block discarded – undo
481 481
 			$table_name = $prefix . 'frm_forms';
482 482
         } else {
483 483
 			$table_name = $wpdb->prefix . 'frm_forms';
484
-            $cache = wp_cache_get($id, 'frm_form');
484
+            $cache = wp_cache_get( $id, 'frm_form' );
485 485
             if ( $cache ) {
486
-                if ( isset($cache->options) ) {
487
-                    $cache->options = maybe_unserialize($cache->options);
486
+                if ( isset( $cache->options ) ) {
487
+                    $cache->options = maybe_unserialize( $cache->options );
488 488
                 }
489 489
 
490
-                return stripslashes_deep($cache);
490
+                return stripslashes_deep( $cache );
491 491
             }
492 492
         }
493 493
 
494
-        if ( is_numeric($id) ) {
494
+        if ( is_numeric( $id ) ) {
495 495
             $where = array( 'id' => $id );
496 496
         } else {
497 497
             $where = array( 'form_key' => $id );
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 
500 500
         $results = FrmDb::get_row( $table_name, $where );
501 501
 
502
-        if ( isset($results->options) ) {
502
+        if ( isset( $results->options ) ) {
503 503
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
504
-            $results->options = maybe_unserialize($results->options);
504
+            $results->options = maybe_unserialize( $results->options );
505 505
         }
506
-        return stripslashes_deep($results);
506
+        return stripslashes_deep( $results );
507 507
     }
508 508
 
509 509
     /**
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 			$results = reset( $results );
533 533
 		}
534 534
 
535
-        return stripslashes_deep($results);
535
+        return stripslashes_deep( $results );
536 536
     }
537 537
 
538 538
 	/**
@@ -572,19 +572,19 @@  discard block
 block discarded – undo
572 572
     	foreach ( $results as $row ) {
573 573
             if ( 'trash' != $row->status ) {
574 574
     	        if ( $row->is_template ) {
575
-					$counts['template']++;
575
+					$counts['template'] ++;
576 576
     	        } else {
577
-					$counts['published']++;
577
+					$counts['published'] ++;
578 578
     	        }
579 579
     	    } else {
580
-				$counts['trash']++;
580
+				$counts['trash'] ++;
581 581
         	}
582 582
 
583 583
     	    if ( 'draft' == $row->status ) {
584
-				$counts['draft']++;
584
+				$counts['draft'] ++;
585 585
     	    }
586 586
 
587
-    		unset($row);
587
+    		unset( $row );
588 588
     	}
589 589
 
590 590
     	$counts = (object) $counts;
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	public static function validate( $values ) {
611 611
         $errors = array();
612 612
 
613
-        return apply_filters('frm_validate_form', $errors, $values);
613
+        return apply_filters( 'frm_validate_form', $errors, $values );
614 614
     }
615 615
 
616 616
 	public static function get_params( $form = null ) {
@@ -622,11 +622,11 @@  discard block
 block discarded – undo
622 622
 			self::maybe_get_form( $form );
623 623
 		}
624 624
 
625
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
626
-			return $frm_vars['form_params'][ $form->id ];
625
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
626
+			return $frm_vars['form_params'][$form->id];
627 627
 		}
628 628
 
629
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
629
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
630 630
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
631 631
 
632 632
 		$default_values = array(
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 			//if there are two forms on the same page, make sure not to submit both
645 645
 			foreach ( $default_values as $var => $default ) {
646 646
 				if ( $var == 'action' ) {
647
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
647
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
648 648
 				} else {
649
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
649
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
650 650
 				}
651 651
 				unset( $var, $default );
652 652
 			}
653 653
 		} else {
654 654
 			foreach ( $default_values as $var => $default ) {
655
-				$values[ $var ] = $default;
655
+				$values[$var] = $default;
656 656
 				unset( $var, $default );
657 657
 			}
658 658
 		}
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	public static function list_page_params() {
668 668
 		$values = array();
669 669
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
670
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
670
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
671 671
 		}
672 672
 
673 673
 		return $values;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
688 688
 			'keep_post' => '',
689 689
 		) as $var => $default ) {
690
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
690
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
691 691
 		}
692 692
 
693 693
 		return $values;
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
 		$small_form = new stdClass();
730 730
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
731 731
 			$small_form->{$var} = $form->{$var};
732
-			unset($var);
732
+			unset( $var );
733 733
 		}
734 734
 
735 735
 		$frm_vars['forms_loaded'][] = $small_form;
736 736
 
737
-		if ( $this_load && empty($global_load) ) {
737
+		if ( $this_load && empty( $global_load ) ) {
738 738
 			$global_load = $frm_vars['load_css'] = true;
739 739
 		}
740 740
 
741
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
741
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
742 742
 	}
743 743
 
744 744
 	public static function show_submit( $form ) {
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -1,387 +1,387 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
3
+	die('You are not allowed to call this page directly.');
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
35
+		$new_values['options'] = serialize($options);
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
77
+			$new_options['email_to'] = get_option('admin_email');
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
95
+			FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+		$new_opts = $values['options'] = maybe_unserialize($values['options']);
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
-        }
108
+		if ( isset($new_opts['success_msg']) ) {
109
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
+		}
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+		if ( isset($values['form_key']) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134
-        $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
134
+		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+		$new_values = self::set_update_options( array(), $values);
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
139
-            if ( in_array($value_key, $form_fields) ) {
138
+		foreach ( $values as $value_key => $value ) {
139
+			if ( in_array($value_key, $form_fields) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
156
-        unset($new_values);
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156
+		unset($new_values);
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+		$values = self::update_fields($id, $values);
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
171
-            return $new_values;
172
-        }
170
+		if ( ! isset($values['options']) ) {
171
+			return $new_values;
172
+		}
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
183
+		$new_values['options'] = serialize($options);
184 184
 
185
-        return $new_values;
186
-    }
185
+		return $new_values;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
-            return $values;
196
-        }
194
+		if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+			return $values;
196
+		}
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
200
-            return $values;
201
-        }
198
+		$all_fields = FrmField::get_all_for_form($id);
199
+		if ( empty($all_fields) ) {
200
+			return $values;
201
+		}
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
204
-            $values['item_meta'] = array();
205
-        }
203
+		if ( ! isset($values['item_meta']) ) {
204
+			$values['item_meta'] = array();
205
+		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
209
-        foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys($values['item_meta']);
209
+		foreach ( $all_fields as $fid ) {
210
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
215
-        unset($all_fields);
214
+		}
215
+		unset($all_fields);
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
221
-                $field = FrmField::getOne($field_id);
222
-            }
220
+			} else {
221
+				$field = FrmField::getOne($field_id);
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229 229
 			if ( $is_settings_page ) {
230
-                //updating the settings page
230
+				//updating the settings page
231 231
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232 232
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
233
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
-                    $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
-                    if ( $prev_opts != $field->field_options ) {
235
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
+					$prev_opts = $field->field_options;
237
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+					if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240
-                    }
241
-                    unset($prev_opts);
242
-                }
243
-            }
240
+					}
241
+					unset($prev_opts);
242
+				}
243
+			}
244 244
 
245 245
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
246
-                continue;
247
-            }
246
+				continue;
247
+			}
248 248
 
249
-            //updating the form
249
+			//updating the form
250 250
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
251 251
 			unset( $update_options['custom_html'] ); // don't check for POST html
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255 255
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
-            }
256
+			}
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259 259
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260 260
 			$field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key;
261 261
 			$required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false;
262 262
 			$field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type;
263 263
 			$field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description;
264 264
 
265
-            FrmField::update($field_id, array(
266
-                'field_key' => $field_key, 'type' => $field_type,
267
-                'default_value' => $default_value, 'field_options' => $field->field_options,
268
-                'description' => $field_description, 'required' => $required,
269
-            ) );
265
+			FrmField::update($field_id, array(
266
+				'field_key' => $field_key, 'type' => $field_type,
267
+				'default_value' => $default_value, 'field_options' => $field->field_options,
268
+				'description' => $field_description, 'required' => $required,
269
+			) );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
272
-        }
271
+			FrmField::delete_form_transient($field->form_id);
272
+		}
273 273
 		self::clear_form_cache();
274 274
 
275
-        return $values;
276
-    }
275
+		return $values;
276
+	}
277 277
 
278
-    /**
279
-     * @param string $status
280
-     * @return int|boolean
281
-     */
278
+	/**
279
+	 * @param string $status
280
+	 * @return int|boolean
281
+	 */
282 282
 	public static function set_status( $id, $status ) {
283
-        if ( 'trash' == $status ) {
284
-            return self::trash($id);
285
-        }
283
+		if ( 'trash' == $status ) {
284
+			return self::trash($id);
285
+		}
286 286
 
287 287
 		$statuses  = array( 'published', 'draft', 'trash' );
288
-        if ( ! in_array( $status, $statuses ) ) {
289
-            return false;
290
-        }
288
+		if ( ! in_array( $status, $statuses ) ) {
289
+			return false;
290
+		}
291 291
 
292
-        global $wpdb;
292
+		global $wpdb;
293 293
 
294
-        if ( is_array($id) ) {
294
+		if ( is_array($id) ) {
295 295
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
296 296
 			FrmDb::get_where_clause_and_values( $where );
297 297
 			array_unshift( $where['values'], $status );
298 298
 
299 299
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
300
-        } else {
300
+		} else {
301 301
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
302 302
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
303
-        }
303
+		}
304 304
 
305
-        if ( $query_results ) {
305
+		if ( $query_results ) {
306 306
 			self::clear_form_cache();
307
-        }
307
+		}
308 308
 
309
-        return $query_results;
310
-    }
309
+		return $query_results;
310
+	}
311 311
 
312
-    /**
313
-     * @return int|boolean
314
-     */
312
+	/**
313
+	 * @return int|boolean
314
+	 */
315 315
 	public static function trash( $id ) {
316
-        if ( ! EMPTY_TRASH_DAYS ) {
317
-            return self::destroy( $id );
318
-        }
316
+		if ( ! EMPTY_TRASH_DAYS ) {
317
+			return self::destroy( $id );
318
+		}
319 319
 
320
-        $form = self::getOne($id);
321
-        if ( ! $form ) {
322
-            return false;
323
-        }
320
+		$form = self::getOne($id);
321
+		if ( ! $form ) {
322
+			return false;
323
+		}
324 324
 
325
-        $options = $form->options;
326
-        $options['trash_time'] = time();
325
+		$options = $form->options;
326
+		$options['trash_time'] = time();
327 327
 
328
-        global $wpdb;
329
-        $query_results = $wpdb->update(
328
+		global $wpdb;
329
+		$query_results = $wpdb->update(
330 330
 			$wpdb->prefix . 'frm_forms',
331 331
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
332 332
 			array( 'id' => $id )
333
-        );
333
+		);
334 334
 
335
-        $wpdb->update(
335
+		$wpdb->update(
336 336
 			$wpdb->prefix . 'frm_forms',
337 337
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
338 338
 			array( 'parent_form_id' => $id )
339
-        );
339
+		);
340 340
 
341
-        if ( $query_results ) {
341
+		if ( $query_results ) {
342 342
 			self::clear_form_cache();
343
-        }
343
+		}
344 344
 
345
-        return $query_results;
346
-    }
345
+		return $query_results;
346
+	}
347 347
 
348
-    /**
349
-     * @return int|boolean
350
-     */
348
+	/**
349
+	 * @return int|boolean
350
+	 */
351 351
 	public static function destroy( $id ) {
352
-        global $wpdb;
352
+		global $wpdb;
353 353
 
354
-        $form = self::getOne($id);
355
-        if ( ! $form ) {
356
-            return false;
357
-        }
354
+		$form = self::getOne($id);
355
+		if ( ! $form ) {
356
+			return false;
357
+		}
358 358
 		$id = $form->id;
359 359
 
360
-        // Disconnect the entries from this form
360
+		// Disconnect the entries from this form
361 361
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
362
-        foreach ( $entries as $entry_id ) {
363
-            FrmEntry::destroy($entry_id);
364
-            unset($entry_id);
365
-        }
362
+		foreach ( $entries as $entry_id ) {
363
+			FrmEntry::destroy($entry_id);
364
+			unset($entry_id);
365
+		}
366 366
 
367
-        // Disconnect the fields from this form
367
+		// Disconnect the fields from this form
368 368
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
369 369
 
370 370
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
371
-        if ( $query_results ) {
372
-            // Delete all form actions linked to this form
373
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
374
-            $action_control->destroy($id, 'all');
371
+		if ( $query_results ) {
372
+			// Delete all form actions linked to this form
373
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
374
+			$action_control->destroy($id, 'all');
375 375
 
376 376
 			// Clear form caching
377 377
 			self::clear_form_cache();
378 378
 
379 379
 			do_action( 'frm_destroy_form', $id );
380 380
 			do_action( 'frm_destroy_form_' . $id );
381
-        }
381
+		}
382 382
 
383
-        return $query_results;
384
-    }
383
+		return $query_results;
384
+	}
385 385
 
386 386
 	/**
387 387
 	 * Delete trashed forms based on how long they have been trashed
@@ -413,49 +413,49 @@  discard block
 block discarded – undo
413 413
 		return $count;
414 414
 	}
415 415
 
416
-    /**
417
-     * @return string form name
418
-     */
419
-    public static function &getName( $id ) {
420
-        global $wpdb;
421
-
422
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
423
-        if ( $form ) {
424
-            $r = stripslashes($form->name);
425
-            return $r;
426
-        }
427
-
428
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
429
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
430
-        $r = stripslashes($r);
431
-
432
-        return $r;
433
-    }
434
-
435
-    /**
436
-     * @param string $key
437
-     * @return int form id
438
-     */
416
+	/**
417
+	 * @return string form name
418
+	 */
419
+	public static function &getName( $id ) {
420
+		global $wpdb;
421
+
422
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
423
+		if ( $form ) {
424
+			$r = stripslashes($form->name);
425
+			return $r;
426
+		}
427
+
428
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
429
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
430
+		$r = stripslashes($r);
431
+
432
+		return $r;
433
+	}
434
+
435
+	/**
436
+	 * @param string $key
437
+	 * @return int form id
438
+	 */
439 439
 	public static function &getIdByKey( $key ) {
440
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
441
-        return $id;
442
-    }
443
-
444
-    /**
445
-     * @param int $id
446
-     * @return string form key
447
-     */
440
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
441
+		return $id;
442
+	}
443
+
444
+	/**
445
+	 * @param int $id
446
+	 * @return string form key
447
+	 */
448 448
 	public static function &getKeyById( $id ) {
449
-        $id = (int) $id;
450
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
451
-        if ( $cache ) {
452
-            return $cache->form_key;
453
-        }
449
+		$id = (int) $id;
450
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
451
+		if ( $cache ) {
452
+			return $cache->form_key;
453
+		}
454 454
 
455
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
455
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
456 456
 
457
-        return $key;
458
-    }
457
+		return $key;
458
+	}
459 459
 
460 460
 	/**
461 461
 	 * If $form is numeric, get the form object
@@ -468,47 +468,47 @@  discard block
 block discarded – undo
468 468
 		}
469 469
 	}
470 470
 
471
-    /**
472
-     * @return object form
473
-     */
474
-    public static function getOne( $id, $blog_id = false ) {
475
-        global $wpdb;
471
+	/**
472
+	 * @return object form
473
+	 */
474
+	public static function getOne( $id, $blog_id = false ) {
475
+		global $wpdb;
476 476
 
477
-        if ( $blog_id && is_multisite() ) {
478
-            global $wpmuBaseTablePrefix;
477
+		if ( $blog_id && is_multisite() ) {
478
+			global $wpmuBaseTablePrefix;
479 479
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
480 480
 
481 481
 			$table_name = $prefix . 'frm_forms';
482
-        } else {
482
+		} else {
483 483
 			$table_name = $wpdb->prefix . 'frm_forms';
484
-            $cache = wp_cache_get($id, 'frm_form');
485
-            if ( $cache ) {
486
-                if ( isset($cache->options) ) {
487
-                    $cache->options = maybe_unserialize($cache->options);
488
-                }
484
+			$cache = wp_cache_get($id, 'frm_form');
485
+			if ( $cache ) {
486
+				if ( isset($cache->options) ) {
487
+					$cache->options = maybe_unserialize($cache->options);
488
+				}
489 489
 
490
-                return stripslashes_deep($cache);
491
-            }
492
-        }
490
+				return stripslashes_deep($cache);
491
+			}
492
+		}
493 493
 
494
-        if ( is_numeric($id) ) {
495
-            $where = array( 'id' => $id );
496
-        } else {
497
-            $where = array( 'form_key' => $id );
498
-        }
494
+		if ( is_numeric($id) ) {
495
+			$where = array( 'id' => $id );
496
+		} else {
497
+			$where = array( 'form_key' => $id );
498
+		}
499 499
 
500
-        $results = FrmDb::get_row( $table_name, $where );
500
+		$results = FrmDb::get_row( $table_name, $where );
501 501
 
502
-        if ( isset($results->options) ) {
502
+		if ( isset($results->options) ) {
503 503
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
504
-            $results->options = maybe_unserialize($results->options);
505
-        }
506
-        return stripslashes_deep($results);
507
-    }
508
-
509
-    /**
510
-     * @return object|array of objects
511
-     */
504
+			$results->options = maybe_unserialize($results->options);
505
+		}
506
+		return stripslashes_deep($results);
507
+	}
508
+
509
+	/**
510
+	 * @return object|array of objects
511
+	 */
512 512
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
513 513
 		if ( is_array( $where ) && ! empty( $where ) ) {
514 514
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
 			$results = reset( $results );
533 533
 		}
534 534
 
535
-        return stripslashes_deep($results);
536
-    }
535
+		return stripslashes_deep($results);
536
+	}
537 537
 
538 538
 	/**
539 539
 	 * Get all published forms
@@ -551,47 +551,47 @@  discard block
 block discarded – undo
551 551
 		return $forms;
552 552
 	}
553 553
 
554
-    /**
555
-     * @return int count of forms
556
-     */
557
-    public static function &get_count() {
558
-    	global $wpdb;
554
+	/**
555
+	 * @return int count of forms
556
+	 */
557
+	public static function &get_count() {
558
+		global $wpdb;
559 559
 
560
-    	$cache_key = 'frm_form_counts';
560
+		$cache_key = 'frm_form_counts';
561 561
 
562
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
563
-    	if ( false !== $counts ) {
564
-    	    return $counts;
565
-    	}
562
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
563
+		if ( false !== $counts ) {
564
+			return $counts;
565
+		}
566 566
 
567
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
567
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
568 568
 
569 569
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
570
-    	$counts = array_fill_keys( $statuses, 0 );
570
+		$counts = array_fill_keys( $statuses, 0 );
571 571
 
572
-    	foreach ( $results as $row ) {
573
-            if ( 'trash' != $row->status ) {
574
-    	        if ( $row->is_template ) {
572
+		foreach ( $results as $row ) {
573
+			if ( 'trash' != $row->status ) {
574
+				if ( $row->is_template ) {
575 575
 					$counts['template']++;
576
-    	        } else {
576
+				} else {
577 577
 					$counts['published']++;
578
-    	        }
579
-    	    } else {
578
+				}
579
+			} else {
580 580
 				$counts['trash']++;
581
-        	}
581
+			}
582 582
 
583
-    	    if ( 'draft' == $row->status ) {
583
+			if ( 'draft' == $row->status ) {
584 584
 				$counts['draft']++;
585
-    	    }
585
+			}
586 586
 
587
-    		unset($row);
588
-    	}
587
+			unset($row);
588
+		}
589 589
 
590
-    	$counts = (object) $counts;
590
+		$counts = (object) $counts;
591 591
 		FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' );
592 592
 
593
-    	return $counts;
594
-    }
593
+		return $counts;
594
+	}
595 595
 
596 596
 	/**
597 597
 	 * Clear form caching
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 		FrmAppHelper::cache_delete_group( 'frm_form' );
605 605
 	}
606 606
 
607
-    /**
608
-     * @return array of errors
609
-     */
607
+	/**
608
+	 * @return array of errors
609
+	 */
610 610
 	public static function validate( $values ) {
611
-        $errors = array();
611
+		$errors = array();
612 612
 
613
-        return apply_filters('frm_validate_form', $errors, $values);
614
-    }
613
+		return apply_filters('frm_validate_form', $errors, $values);
614
+	}
615 615
 
616 616
 	public static function get_params( $form = null ) {
617 617
 		global $frm_vars;
Please login to merge, or discard this patch.
classes/models/FrmField.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmField {
7
-    static $use_cache = true;
7
+	static $use_cache = true;
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
@@ -51,39 +51,39 @@  discard block
 block discarded – undo
51 51
 		));
52 52
 	}
53 53
 
54
-    public static function create( $values, $return = true ) {
55
-        global $wpdb, $frm_duplicate_ids;
54
+	public static function create( $values, $return = true ) {
55
+		global $wpdb, $frm_duplicate_ids;
56 56
 
57
-        $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
57
+		$new_values = array();
58
+		$key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62 62
 			$new_values[ $col ] = $values[ $col ];
63
-        }
63
+		}
64 64
 
65
-        $new_values['options'] = $values['options'];
65
+		$new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
-        $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
67
+		$new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
+		$new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
+		$new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
70
+		$new_values['field_options'] = $values['field_options'];
71
+		$new_values['created_at'] = current_time('mysql', 1);
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74 74
 			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
76
-        }
75
+			$new_values = apply_filters('frm_duplicated_field', $new_values);
76
+		}
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79
-            if ( is_array( $v ) ) {
79
+			if ( is_array( $v ) ) {
80 80
 				$new_values[ $k ] = serialize( $v );
81 81
 			}
82
-            unset( $k, $v );
83
-        }
82
+			unset( $k, $v );
83
+		}
84 84
 
85
-        //if(isset($values['id']) and is_numeric($values['id']))
86
-        //    $new_values['id'] = $values['id'];
85
+		//if(isset($values['id']) and is_numeric($values['id']))
86
+		//    $new_values['id'] = $values['id'];
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values );
89 89
 		$new_id = 0;
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 		} else {
105 105
 			return false;
106 106
 		}
107
-    }
107
+	}
108 108
 
109
-    public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
-        global $frm_duplicate_ids;
109
+	public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
110
+		global $frm_duplicate_ids;
111 111
 
112 112
 		$where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) );
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115
-        foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
119
-            }
115
+		foreach ( (array) $fields as $field ) {
116
+			$new_key = ($copy_keys) ? $field->field_key : '';
117
+			if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
+				$new_key = rtrim($new_key, 2);
119
+			}
120 120
 
121
-            $values = array();
122
-            FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
121
+			$values = array();
122
+			FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
123 123
 
124 124
 			// If this is a repeating section, create new form
125 125
 			if ( self::is_repeating_field( $field ) ) {
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
146
-        }
147
-    }
141
+			$values = apply_filters('frm_duplicated_field', $values);
142
+			$new_id = self::create($values);
143
+			$frm_duplicate_ids[ $field->id ] = $new_id;
144
+			$frm_duplicate_ids[ $field->field_key ] = $new_id;
145
+			unset($field);
146
+		}
147
+	}
148 148
 
149 149
 	public static function update( $id, $values ) {
150
-        global $wpdb;
150
+		global $wpdb;
151 151
 
152 152
 		$id = absint( $id );
153 153
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
159
-            $values['required'] = (int) $values['required'];
160
-        }
158
+		if ( isset($values['required']) ) {
159
+			$values['required'] = (int) $values['required'];
160
+		}
161 161
 
162 162
 		self::preserve_format_option_backslashes( $values );
163 163
 
@@ -174,41 +174,41 @@  discard block
 block discarded – undo
174 174
 
175 175
 		$query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
176 176
 
177
-        $form_id = 0;
177
+		$form_id = 0;
178 178
 		if ( isset( $values['form_id'] ) ) {
179
-            $form_id = absint( $values['form_id'] );
179
+			$form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
182
-            if ( $field ) {
183
-                $form_id = $field->form_id;
184
-            }
185
-            unset($field);
186
-        }
187
-        unset($values);
181
+			$field = self::getOne($id);
182
+			if ( $field ) {
183
+				$form_id = $field->form_id;
184
+			}
185
+			unset($field);
186
+		}
187
+		unset($values);
188 188
 
189 189
 		if ( $query_results ) {
190
-            wp_cache_delete( $id, 'frm_field' );
191
-            if ( $form_id ) {
192
-                self::delete_form_transient( $form_id );
193
-            }
194
-        }
190
+			wp_cache_delete( $id, 'frm_field' );
191
+			if ( $form_id ) {
192
+				self::delete_form_transient( $form_id );
193
+			}
194
+		}
195 195
 
196
-        return $query_results;
197
-    }
196
+		return $query_results;
197
+	}
198 198
 
199 199
 	/**
200
-	* Keep backslashes in the phone format option
201
-	*
202
-	* @since 2.0.8
203
-	* @param $values array - pass by reference
204
-	*/
200
+	 * Keep backslashes in the phone format option
201
+	 *
202
+	 * @since 2.0.8
203
+	 * @param $values array - pass by reference
204
+	 */
205 205
 	private static function preserve_format_option_backslashes( &$values ) {
206 206
 		if ( isset( $values['field_options']['format'] ) ) {
207 207
 			$values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
208 208
 		}
209 209
 	}
210 210
 
211
-    public static function destroy( $id ) {
211
+	public static function destroy( $id ) {
212 212
 		global $wpdb;
213 213
 
214 214
 		do_action( 'frm_before_destroy_field', $id );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
225 225
 		return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
226
-    }
226
+	}
227 227
 
228 228
 	public static function delete_form_transient( $form_id ) {
229 229
 		$form_id = absint( $form_id );
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 
238 238
 		FrmAppHelper::cache_delete_group( 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
241
-        if ( $form && $form->parent_form_id ) {
242
-            self::delete_form_transient( $form->parent_form_id );
243
-        }
244
-    }
240
+		$form = FrmForm::getOne($form_id);
241
+		if ( $form && $form->parent_form_id ) {
242
+			self::delete_form_transient( $form->parent_form_id );
243
+		}
244
+	}
245 245
 
246 246
 	/**
247 247
 	 * If $field is numeric, get the field object
@@ -257,131 +257,131 @@  discard block
 block discarded – undo
257 257
 			return;
258 258
 		}
259 259
 
260
-        global $wpdb;
260
+		global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+		$where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265
-        $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
265
+		$results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
268
-            return $results;
269
-        }
267
+		if ( empty($results) ) {
268
+			return $results;
269
+		}
270 270
 
271
-        if ( is_numeric($id) ) {
271
+		if ( is_numeric($id) ) {
272 272
 			FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' );
273
-        } else if ( $results ) {
273
+		} else if ( $results ) {
274 274
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_field' );
275
-        }
275
+		}
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
280
-    }
279
+		return stripslashes_deep($results);
280
+	}
281 281
 
282
-    /**
283
-     * Get the field type by key or id
284
-     * @param int|string The field id or key
282
+	/**
283
+	 * Get the field type by key or id
284
+	 * @param int|string The field id or key
285 285
 	 * @param mixed $col The name of the column in the fields database table
286
-     */
287
-    public static function &get_type( $id, $col = 'type' ) {
288
-        $field = FrmAppHelper::check_cache( $id, 'frm_field' );
289
-        if ( $field ) {
290
-            $type = $field->{$col};
291
-        } else {
292
-            $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
293
-        }
294
-
295
-        return $type;
296
-    }
286
+	 */
287
+	public static function &get_type( $id, $col = 'type' ) {
288
+		$field = FrmAppHelper::check_cache( $id, 'frm_field' );
289
+		if ( $field ) {
290
+			$type = $field->{$col};
291
+		} else {
292
+			$type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col );
293
+		}
294
+
295
+		return $type;
296
+	}
297 297
 
298 298
 	public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
299
-        if ( ! $form_id ) {
300
-            return array();
301
-        }
299
+		if ( ! $form_id ) {
300
+			return array();
301
+		}
302 302
 
303 303
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) );
304 304
 		if ( ! empty( $results ) ) {
305
-            $fields = array();
306
-            $count = 0;
307
-            foreach ( $results as $result ) {
308
-                if ( $type != $result->type ) {
309
-                    continue;
310
-                }
305
+			$fields = array();
306
+			$count = 0;
307
+			foreach ( $results as $result ) {
308
+				if ( $type != $result->type ) {
309
+					continue;
310
+				}
311 311
 
312 312
 				$fields[ $result->id ] = $result;
313
-                $count++;
314
-                if ( $limit == 1 ) {
315
-                    $fields = $result;
316
-                    break;
317
-                }
313
+				$count++;
314
+				if ( $limit == 1 ) {
315
+					$fields = $result;
316
+					break;
317
+				}
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
320
-                    break;
321
-                }
319
+				if ( ! empty($limit) && $count >= $limit ) {
320
+					break;
321
+				}
322 322
 
323
-                unset($result);
324
-            }
325
-            return stripslashes_deep($fields);
326
-        }
323
+				unset($result);
324
+			}
325
+			return stripslashes_deep($fields);
326
+		}
327 327
 
328
-        self::$use_cache = false;
328
+		self::$use_cache = false;
329 329
 
330 330
 		$where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type );
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333
-        self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
333
+		self::$use_cache = true;
334
+		self::include_sub_fields($results, $inc_sub, $type);
335 335
 
336
-        return $results;
337
-    }
336
+		return $results;
337
+	}
338 338
 
339 339
 	public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
340
-        if ( ! (int) $form_id ) {
341
-            return array();
342
-        }
340
+		if ( ! (int) $form_id ) {
341
+			return array();
342
+		}
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+			if ( empty($limit) ) {
347 347
 				return $results;
348
-            }
348
+			}
349 349
 
350
-            $fields = array();
351
-            $count = 0;
352
-            foreach ( $results as $result ) {
350
+			$fields = array();
351
+			$count = 0;
352
+			foreach ( $results as $result ) {
353 353
 				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
355
-                    break;
356
-                }
357
-            }
354
+				if ( ! empty($limit) && $count >= $limit ) {
355
+					break;
356
+				}
357
+			}
358 358
 
359 359
 			return $fields;
360
-        }
360
+		}
361 361
 
362
-        self::$use_cache = false;
362
+		self::$use_cache = false;
363 363
 
364 364
 		$where = array( 'fi.form_id' => absint( $form_id ) );
365 365
 		self::maybe_include_repeating_fields( $inc_repeat, $where );
366 366
 		$results = self::getAll( $where, 'field_order', $limit );
367 367
 
368
-        self::$use_cache = true;
368
+		self::$use_cache = true;
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+		if ( empty($limit) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374
-        }
374
+		}
375 375
 
376 376
 		return $results;
377
-    }
377
+	}
378 378
 
379 379
 	/**
380
-	* If repeating fields should be included, adjust $where accordingly
381
-	*
382
-	* @param string $inc_repeat
383
-	* @param array $where - pass by reference
384
-	*/
380
+	 * If repeating fields should be included, adjust $where accordingly
381
+	 *
382
+	 * @param string $inc_repeat
383
+	 * @param array $where - pass by reference
384
+	 */
385 385
 	private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
386 386
 		if ( $inc_repeat == 'include' ) {
387 387
 			$form_id = $where['fi.form_id'];
@@ -392,77 +392,77 @@  discard block
 block discarded – undo
392 392
 
393 393
 	public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) {
394 394
 		if ( 'include' != $inc_embed || empty( $results ) ) {
395
-            return;
396
-        }
395
+			return;
396
+		}
397 397
 
398
-        $form_fields = $results;
398
+		$form_fields = $results;
399 399
 		$index_offset = 1;
400
-        foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
402
-                continue;
403
-            }
404
-
405
-            if ( $type == 'all' ) {
406
-                $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407
-            } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
409
-            }
410
-
411
-            if ( ! empty($sub_fields) ) {
400
+		foreach ( $form_fields as $k => $field ) {
401
+			if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
402
+				continue;
403
+			}
404
+
405
+			if ( $type == 'all' ) {
406
+				$sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407
+			} else {
408
+				$sub_fields = self::get_all_types_in_form($field->form_id, $type);
409
+			}
410
+
411
+			if ( ! empty($sub_fields) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414 414
 				array_splice($results, $index, 0, $sub_fields);
415
-            }
416
-            unset($field, $sub_fields);
417
-        }
418
-    }
415
+			}
416
+			unset($field, $sub_fields);
417
+		}
418
+	}
419 419
 
420 420
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422
-        if ( self::$use_cache ) {
423
-            // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
425
-            if ( false !== $results ) {
426
-                return stripslashes_deep($results);
427
-            }
428
-        }
429
-
430
-        global $wpdb;
431
-
432
-        if ( $blog_id && is_multisite() ) {
433
-            global $wpmuBaseTablePrefix;
434
-            if ( $wpmuBaseTablePrefix ) {
422
+		if ( self::$use_cache ) {
423
+			// make sure old cache doesn't get saved as a transient
424
+			$results = wp_cache_get($cache_key, 'frm_field');
425
+			if ( false !== $results ) {
426
+				return stripslashes_deep($results);
427
+			}
428
+		}
429
+
430
+		global $wpdb;
431
+
432
+		if ( $blog_id && is_multisite() ) {
433
+			global $wpmuBaseTablePrefix;
434
+			if ( $wpmuBaseTablePrefix ) {
435 435
 				$prefix = $wpmuBaseTablePrefix . $blog_id . '_';
436
-            } else {
437
-                $prefix = $wpdb->get_blog_prefix( $blog_id );
438
-            }
436
+			} else {
437
+				$prefix = $wpdb->get_blog_prefix( $blog_id );
438
+			}
439 439
 
440 440
 			$table_name = $prefix . 'frm_fields';
441 441
 			$form_table_name = $prefix . 'frm_forms';
442 442
 		} else {
443 443
 			$table_name = $wpdb->prefix . 'frm_fields';
444 444
 			$form_table_name = $wpdb->prefix . 'frm_forms';
445
-        }
445
+		}
446 446
 
447 447
 		if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+		$limit = FrmAppHelper::esc_limit($limit);
452 452
 
453
-        $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454
-        $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
453
+		$query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454
+		$query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
457
-            $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
456
+		if ( is_array($where) ) {
457
+			$results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+			$query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
464
-        }
465
-        unset( $where );
464
+		}
465
+		unset( $where );
466 466
 
467 467
 		self::format_field_results( $results );
468 468
 
@@ -561,21 +561,21 @@  discard block
 block discarded – undo
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564
-        global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
564
+		global $wpdb;
565
+		if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567
-        }
567
+		}
568 568
 
569 569
 		$query = 'SELECT fi.id  FROM ' . $wpdb->prefix . 'frm_fields fi ' .
570 570
 			'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' .
571 571
 			FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
572 572
 
573
-        $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
573
+		$method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
576 576
 
577
-        return $results;
578
-    }
577
+		return $results;
578
+	}
579 579
 
580 580
 	public static function is_no_save_field( $type ) {
581 581
 		return in_array( $type, self::no_save_fields() );
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
 	}
719 719
 
720 720
 	/**
721
-	* @since 2.0.09
722
-	*/
721
+	 * @since 2.0.09
722
+	 */
723 723
 	public static function is_repeating_field( $field ) {
724 724
 		if ( is_array( $field ) ) {
725 725
 			$is_repeating_field = ( 'divider' == $field['type'] );
@@ -729,14 +729,14 @@  discard block
 block discarded – undo
729 729
 		return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
730 730
 	}
731 731
 
732
-    /**
733
-     * @param string $key
734
-     * @return int field id
735
-     */
732
+	/**
733
+	 * @param string $key
734
+	 * @return int field id
735
+	 */
736 736
 	public static function get_id_by_key( $key ) {
737
-        $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
738
-        return $id;
739
-    }
737
+		$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
738
+		return $id;
739
+	}
740 740
 
741 741
 	/**
742 742
 	 * @param string $id
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
 
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	static $transient_size = 200;
9 9
 
10 10
 	public static function field_selection() {
11
-		$fields = apply_filters('frm_available_fields', array(
11
+		$fields = apply_filters( 'frm_available_fields', array(
12 12
 			'text'      => __( 'Single Line Text', 'formidable' ),
13 13
 			'textarea'  => __( 'Paragraph Text', 'formidable' ),
14 14
 			'checkbox'  => __( 'Checkboxes', 'formidable' ),
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 			'email'     => __( 'Email Address', 'formidable' ),
18 18
 			'url'       => __( 'Website/URL', 'formidable' ),
19 19
 			'captcha'   => __( 'reCAPTCHA', 'formidable' ),
20
-		));
20
+		) );
21 21
 
22 22
 		return $fields;
23 23
 	}
24 24
 
25 25
 	public static function pro_field_selection() {
26
-		return apply_filters('frm_pro_available_fields', array(
26
+		return apply_filters( 'frm_pro_available_fields', array(
27 27
 			'end_divider' => array(
28 28
 				'name'  => __( 'End Section', 'formidable' ),
29 29
 				'switch_from' => 'divider',
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 			'tag'       => __( 'Tags', 'formidable' ),
49 49
 			'credit_card' => __( 'Credit Card', 'formidable' ),
50 50
 			'address'   => __( 'Address', 'formidable' ),
51
-		));
51
+		) );
52 52
 	}
53 53
 
54 54
     public static function create( $values, $return = true ) {
55 55
         global $wpdb, $frm_duplicate_ids;
56 56
 
57 57
         $new_values = array();
58
-        $key = isset($values['field_key']) ? $values['field_key'] : $values['name'];
58
+        $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
59 59
 		$new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
60 60
 
61 61
 		foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
62
-			$new_values[ $col ] = $values[ $col ];
62
+			$new_values[$col] = $values[$col];
63 63
         }
64 64
 
65 65
         $new_values['options'] = $values['options'];
66 66
 
67
-        $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null;
68
-        $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0;
69
-        $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null;
67
+        $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
68
+        $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
69
+        $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
70 70
         $new_values['field_options'] = $values['field_options'];
71
-        $new_values['created_at'] = current_time('mysql', 1);
71
+        $new_values['created_at'] = current_time( 'mysql', 1 );
72 72
 
73 73
 		if ( isset( $values['id'] ) ) {
74
-			$frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
75
-            $new_values = apply_filters('frm_duplicated_field', $new_values);
74
+			$frm_duplicate_ids[$values['field_key']] = $new_values['field_key'];
75
+            $new_values = apply_filters( 'frm_duplicated_field', $new_values );
76 76
         }
77 77
 
78 78
 		foreach ( $new_values as $k => $v ) {
79 79
             if ( is_array( $v ) ) {
80
-				$new_values[ $k ] = serialize( $v );
80
+				$new_values[$k] = serialize( $v );
81 81
 			}
82 82
             unset( $k, $v );
83 83
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 		if ( $query_results ) {
100 100
 			if ( isset( $values['id'] ) ) {
101
-				$frm_duplicate_ids[ $values['id'] ] = $new_id;
101
+				$frm_duplicate_ids[$values['id']] = $new_id;
102 102
 			}
103 103
 			return $new_id;
104 104
 		} else {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$fields = self::getAll( $where, 'field_order', '', $blog_id );
114 114
 
115 115
         foreach ( (array) $fields as $field ) {
116
-            $new_key = ($copy_keys) ? $field->field_key : '';
117
-            if ( $copy_keys && substr($field->field_key, -1) == 2 ) {
118
-                $new_key = rtrim($new_key, 2);
116
+            $new_key = ( $copy_keys ) ? $field->field_key : '';
117
+            if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) {
118
+                $new_key = rtrim( $new_key, 2 );
119 119
             }
120 120
 
121 121
             $values = array();
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 				$values['form_id'] = $new_repeat_form_id;
139 139
 			}
140 140
 
141
-            $values = apply_filters('frm_duplicated_field', $values);
142
-            $new_id = self::create($values);
143
-            $frm_duplicate_ids[ $field->id ] = $new_id;
144
-            $frm_duplicate_ids[ $field->field_key ] = $new_id;
145
-            unset($field);
141
+            $values = apply_filters( 'frm_duplicated_field', $values );
142
+            $new_id = self::create( $values );
143
+            $frm_duplicate_ids[$field->id] = $new_id;
144
+            $frm_duplicate_ids[$field->field_key] = $new_id;
145
+            unset( $field );
146 146
         }
147 147
     }
148 148
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id );
156 156
 		}
157 157
 
158
-        if ( isset($values['required']) ) {
158
+        if ( isset( $values['required'] ) ) {
159 159
             $values['required'] = (int) $values['required'];
160 160
         }
161 161
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 
168 168
 		// serialize array values
169 169
 		foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) {
170
-			if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
171
-				$values[ $opt ] = serialize( $values[ $opt ] );
170
+			if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) {
171
+				$values[$opt] = serialize( $values[$opt] );
172 172
 			}
173 173
 		}
174 174
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 		if ( isset( $values['form_id'] ) ) {
179 179
             $form_id = absint( $values['form_id'] );
180 180
 		} else {
181
-            $field = self::getOne($id);
181
+            $field = self::getOne( $id );
182 182
             if ( $field ) {
183 183
                 $form_id = $field->form_id;
184 184
             }
185
-            unset($field);
185
+            unset( $field );
186 186
         }
187
-        unset($values);
187
+        unset( $values );
188 188
 
189 189
 		if ( $query_results ) {
190 190
             wp_cache_delete( $id, 'frm_field' );
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		FrmAppHelper::cache_delete_group( 'frm_field' );
239 239
 
240
-        $form = FrmForm::getOne($form_id);
240
+        $form = FrmForm::getOne( $form_id );
241 241
         if ( $form && $form->parent_form_id ) {
242 242
             self::delete_form_transient( $form->parent_form_id );
243 243
         }
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 
260 260
         global $wpdb;
261 261
 
262
-        $where = is_numeric($id) ? 'id=%d' : 'field_key=%s';
262
+        $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
263 263
 		$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id );
264 264
 
265 265
         $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
266 266
 
267
-        if ( empty($results) ) {
267
+        if ( empty( $results ) ) {
268 268
             return $results;
269 269
         }
270 270
 
271
-        if ( is_numeric($id) ) {
271
+        if ( is_numeric( $id ) ) {
272 272
 			FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' );
273 273
         } else if ( $results ) {
274 274
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_field' );
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		self::prepare_options( $results );
278 278
 
279
-        return stripslashes_deep($results);
279
+        return stripslashes_deep( $results );
280 280
     }
281 281
 
282 282
     /**
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
                     continue;
310 310
                 }
311 311
 
312
-				$fields[ $result->id ] = $result;
313
-                $count++;
312
+				$fields[$result->id] = $result;
313
+                $count ++;
314 314
                 if ( $limit == 1 ) {
315 315
                     $fields = $result;
316 316
                     break;
317 317
                 }
318 318
 
319
-                if ( ! empty($limit) && $count >= $limit ) {
319
+                if ( ! empty( $limit ) && $count >= $limit ) {
320 320
                     break;
321 321
                 }
322 322
 
323
-                unset($result);
323
+                unset( $result );
324 324
             }
325
-            return stripslashes_deep($fields);
325
+            return stripslashes_deep( $fields );
326 326
         }
327 327
 
328 328
         self::$use_cache = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		self::maybe_include_repeating_fields( $inc_sub, $where );
332 332
 		$results = self::getAll( $where, 'field_order', $limit );
333 333
         self::$use_cache = true;
334
-        self::include_sub_fields($results, $inc_sub, $type);
334
+        self::include_sub_fields( $results, $inc_sub, $type );
335 335
 
336 336
         return $results;
337 337
     }
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
345 345
 		if ( ! empty( $results ) ) {
346
-            if ( empty($limit) ) {
346
+            if ( empty( $limit ) ) {
347 347
 				return $results;
348 348
             }
349 349
 
350 350
             $fields = array();
351 351
             $count = 0;
352 352
             foreach ( $results as $result ) {
353
-				$fields[ $result->id ] = $result;
354
-                if ( ! empty($limit) && $count >= $limit ) {
353
+				$fields[$result->id] = $result;
354
+                if ( ! empty( $limit ) && $count >= $limit ) {
355 355
                     break;
356 356
                 }
357 357
             }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 		self::include_sub_fields( $results, $inc_embed, 'all' );
371 371
 
372
-        if ( empty($limit) ) {
372
+        if ( empty( $limit ) ) {
373 373
 			self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) );
374 374
         }
375 375
 
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
         $form_fields = $results;
399 399
 		$index_offset = 1;
400 400
         foreach ( $form_fields as $k => $field ) {
401
-            if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
401
+            if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
402 402
                 continue;
403 403
             }
404 404
 
405 405
             if ( $type == 'all' ) {
406 406
                 $sub_fields = self::get_all_for_form( $field->field_options['form_select'] );
407 407
             } else {
408
-                $sub_fields = self::get_all_types_in_form($field->form_id, $type);
408
+                $sub_fields = self::get_all_types_in_form( $field->form_id, $type );
409 409
             }
410 410
 
411
-            if ( ! empty($sub_fields) ) {
411
+            if ( ! empty( $sub_fields ) ) {
412 412
 				$index = $k + $index_offset;
413 413
 				$index_offset += count( $sub_fields );
414
-				array_splice($results, $index, 0, $sub_fields);
414
+				array_splice( $results, $index, 0, $sub_fields );
415 415
             }
416
-            unset($field, $sub_fields);
416
+            unset( $field, $sub_fields );
417 417
         }
418 418
     }
419 419
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 		$cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
422 422
         if ( self::$use_cache ) {
423 423
             // make sure old cache doesn't get saved as a transient
424
-            $results = wp_cache_get($cache_key, 'frm_field');
424
+            $results = wp_cache_get( $cache_key, 'frm_field' );
425 425
             if ( false !== $results ) {
426
-                return stripslashes_deep($results);
426
+                return stripslashes_deep( $results );
427 427
             }
428 428
         }
429 429
 
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 			$order_by = ' ORDER BY ' . $order_by;
449 449
 		}
450 450
 
451
-        $limit = FrmAppHelper::esc_limit($limit);
451
+        $limit = FrmAppHelper::esc_limit( $limit );
452 452
 
453 453
         $query = "SELECT fi.*, fr.name as form_name  FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id";
454 454
         $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results';
455 455
 
456
-        if ( is_array($where) ) {
456
+        if ( is_array( $where ) ) {
457 457
             $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type );
458 458
 		} else {
459 459
 			// if the query is not an array, then it has already been prepared
460
-            $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
460
+            $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
461 461
 
462 462
 			$function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results';
463 463
 			$results = $wpdb->$function_name( $query );
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 				FrmAppHelper::set_cache( $result->id, $result, 'frm_field' );
481 481
 				FrmAppHelper::set_cache( $result->field_key, $result, 'frm_field' );
482 482
 
483
-				$results[ $r_key ]->field_options = maybe_unserialize( $result->field_options );
484
-				$results[ $r_key ]->options = maybe_unserialize( $result->options );
485
-				$results[ $r_key ]->default_value = maybe_unserialize( $result->default_value );
483
+				$results[$r_key]->field_options = maybe_unserialize( $result->field_options );
484
+				$results[$r_key]->options = maybe_unserialize( $result->options );
485
+				$results[$r_key]->default_value = maybe_unserialize( $result->default_value );
486 486
 
487 487
 				unset( $r_key, $result );
488 488
 			}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	private static function prepare_options( &$results ) {
502 502
 		$results->field_options = maybe_unserialize( $results->field_options );
503 503
 
504
-		$results->options = maybe_unserialize($results->options);
505
-		$results->default_value = maybe_unserialize($results->default_value);
504
+		$results->options = maybe_unserialize( $results->options );
505
+		$results->default_value = maybe_unserialize( $results->default_value );
506 506
 	}
507 507
 
508 508
 	/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 			if ( count( $next_fields ) >= self::$transient_size ) {
531 531
 				// if this transient is full, check for another
532
-				$next++;
532
+				$next ++;
533 533
 				self::get_next_transient( $fields, $base_name, $next );
534 534
 			}
535 535
 		}
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 				return;
556 556
 			}
557 557
 
558
-			$next++;
558
+			$next ++;
559 559
 		}
560 560
 	}
561 561
 
562 562
 	public static function getIds( $where = '', $order_by = '', $limit = '' ) {
563 563
 		_deprecated_function( __FUNCTION__, '2.0' );
564 564
         global $wpdb;
565
-        if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) {
565
+        if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) {
566 566
 			$order_by = ' ORDER BY ' . $order_by;
567 567
         }
568 568
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
         $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col';
574 574
 		$cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit;
575
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method);
575
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method );
576 576
 
577 577
         return $results;
578 578
     }
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
 			$is_multi_value_field = (
604 604
 				$field['type'] == 'checkbox' ||
605 605
 				$field['type'] == 'address' ||
606
-				( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
607
-				( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) ||
606
+				( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
607
+				( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) ||
608 608
 				self::is_multiple_select( $field )
609 609
 			);
610 610
 
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 	 */
630 630
 	public static function is_multiple_select( $field ) {
631 631
 		if ( is_array( $field ) ) {
632
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
632
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) );
633 633
 		} else {
634
-			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
634
+			return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) );
635 635
 		}
636 636
 	}
637 637
 
@@ -678,23 +678,23 @@  discard block
 block discarded – undo
678 678
 	}
679 679
 
680 680
 	public static function is_option_true_in_array( $field, $option ) {
681
-		return isset( $field[ $option ] ) && $field[ $option ];
681
+		return isset( $field[$option] ) && $field[$option];
682 682
 	}
683 683
 
684 684
 	public static function is_option_true_in_object( $field, $option ) {
685
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
685
+		return isset( $field->field_options[$option] ) && $field->field_options[$option];
686 686
 	}
687 687
 
688 688
 	public static function is_option_empty_in_array( $field, $option ) {
689
-		return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
689
+		return ! isset( $field[$option] ) || empty( $field[$option] );
690 690
 	}
691 691
 
692 692
 	public static function is_option_empty_in_object( $field, $option ) {
693
-		return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
693
+		return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] );
694 694
 	}
695 695
 
696 696
 	public static function is_option_value_in_object( $field, $option ) {
697
-		return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
697
+		return isset( $field->field_options[$option] ) && $field->field_options[$option] != '';
698 698
 	}
699 699
 
700 700
 	/**
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 	}
711 711
 
712 712
 	public static function get_option_in_array( $field, $option ) {
713
-		return $field[ $option ];
713
+		return $field[$option];
714 714
 	}
715 715
 
716 716
 	public static function get_option_in_object( $field, $option ) {
717
-		return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
717
+		return isset( $field->field_options[$option] ) ? $field->field_options[$option] : '';
718 718
 	}
719 719
 
720 720
 	/**
Please login to merge, or discard this patch.
classes/views/addons/upgrade_to_pro.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 			<tr>
59 59
 				<th>Included AddOns</th>
60 60
 				<td>None</td>
61
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td>
62
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td>
63
-				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td>
61
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td>
62
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td>
63
+				<td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td>
64 64
 			</tr>
65 65
 		</tbody>
66 66
 	</table>
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$keyed_addons = array();
44 44
 		foreach ( $addons as $addon ) {
45
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
45
+			$keyed_addons[$addon['info']['slug']] = $addon;
46 46
 		}
47 47
 
48 48
 		$plugin_order = array(
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 		);
54 54
 		$ordered_addons = array();
55 55
 		foreach ( $plugin_order as $plugin ) {
56
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
57
-				$ordered_addons[] = $keyed_addons[ $plugin ];
58
-				unset( $keyed_addons[ $plugin ] );
56
+			if ( isset( $keyed_addons[$plugin] ) ) {
57
+				$ordered_addons[] = $keyed_addons[$plugin];
58
+				unset( $keyed_addons[$plugin] );
59 59
 			}
60 60
 		}
61 61
 		$addons = $ordered_addons + $keyed_addons;
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	public static function get_licenses() {
93
-		FrmAppHelper::permission_check('frm_change_settings');
93
+		FrmAppHelper::permission_check( 'frm_change_settings' );
94 94
 		check_ajax_referer( 'frm_ajax', 'nonce' );
95 95
 
96
-		$license = get_option('frmpro-credentials');
96
+		$license = get_option( 'frmpro-credentials' );
97 97
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
98 98
 			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
99 99
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		);
147 147
 
148 148
 		foreach ( $pro['pricing'] as $name => $price ) {
149
-			if ( isset( $pro_pricing[ $name ] ) ) {
150
-				$pro_pricing[ $name ]['price'] = $price;
149
+			if ( isset( $pro_pricing[$name] ) ) {
150
+				$pro_pricing[$name]['price'] = $price;
151 151
 			}
152 152
 		}
153 153
 	}
Please login to merge, or discard this patch.
classes/models/FrmSettings.php 3 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,243 +1,243 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmSettings{
4
-    public $option_name = 'frm_options';
5
-    public $menu;
6
-    public $mu_menu;
7
-    public $preview_page_id;
8
-    public $use_html;
9
-    public $jquery_css;
10
-    public $accordion_js;
11
-
12
-    public $success_msg;
13
-    public $blank_msg;
14
-    public $unique_msg;
15
-    public $invalid_msg;
16
-    public $failed_msg;
17
-    public $submit_value;
18
-    public $login_msg;
19
-    public $admin_permission;
20
-
21
-    public $email_to;
22
-    public $load_style;
23
-    public $custom_style;
24
-
25
-    public $pubkey;
26
-    public $privkey;
27
-    public $re_lang;
28
-    public $re_msg;
4
+	public $option_name = 'frm_options';
5
+	public $menu;
6
+	public $mu_menu;
7
+	public $preview_page_id;
8
+	public $use_html;
9
+	public $jquery_css;
10
+	public $accordion_js;
11
+
12
+	public $success_msg;
13
+	public $blank_msg;
14
+	public $unique_msg;
15
+	public $invalid_msg;
16
+	public $failed_msg;
17
+	public $submit_value;
18
+	public $login_msg;
19
+	public $admin_permission;
20
+
21
+	public $email_to;
22
+	public $load_style;
23
+	public $custom_style;
24
+
25
+	public $pubkey;
26
+	public $privkey;
27
+	public $re_lang;
28
+	public $re_msg;
29 29
 	public $re_multi;
30 30
 
31
-    public function __construct() {
32
-        if ( ! defined('ABSPATH') ) {
33
-            die('You are not allowed to call this page directly.');
34
-        }
31
+	public function __construct() {
32
+		if ( ! defined('ABSPATH') ) {
33
+			die('You are not allowed to call this page directly.');
34
+		}
35 35
 
36
-        $settings = get_transient($this->option_name);
36
+		$settings = get_transient($this->option_name);
37 37
 
38
-        if ( ! is_object($settings) ) {
39
-            $settings = $this->translate_settings($settings);
40
-        }
38
+		if ( ! is_object($settings) ) {
39
+			$settings = $this->translate_settings($settings);
40
+		}
41 41
 
42
-        foreach ( $settings as $setting_name => $setting ) {
43
-            $this->{$setting_name} = $setting;
44
-            unset($setting_name, $setting);
45
-        }
42
+		foreach ( $settings as $setting_name => $setting ) {
43
+			$this->{$setting_name} = $setting;
44
+			unset($setting_name, $setting);
45
+		}
46 46
 
47
-        $this->set_default_options();
48
-    }
47
+		$this->set_default_options();
48
+	}
49 49
 
50 50
 	private function translate_settings( $settings ) {
51
-        if ( $settings ) { //workaround for W3 total cache conflict
52
-            return unserialize(serialize($settings));
53
-        }
54
-
55
-        $settings = get_option($this->option_name);
56
-        if ( is_object($settings) ) {
57
-            set_transient($this->option_name, $settings);
58
-            return $settings;
59
-        }
60
-
61
-        // If unserializing didn't work
62
-        if ( $settings ) { //workaround for W3 total cache conflict
63
-            $settings = unserialize(serialize($settings));
64
-        } else {
65
-            $settings = $this;
66
-        }
67
-
68
-        update_option($this->option_name, $settings);
69
-        set_transient($this->option_name, $settings);
70
-
71
-        return $settings;
72
-    }
73
-
74
-    /**
75
-     * @return array
76
-     */
51
+		if ( $settings ) { //workaround for W3 total cache conflict
52
+			return unserialize(serialize($settings));
53
+		}
54
+
55
+		$settings = get_option($this->option_name);
56
+		if ( is_object($settings) ) {
57
+			set_transient($this->option_name, $settings);
58
+			return $settings;
59
+		}
60
+
61
+		// If unserializing didn't work
62
+		if ( $settings ) { //workaround for W3 total cache conflict
63
+			$settings = unserialize(serialize($settings));
64
+		} else {
65
+			$settings = $this;
66
+		}
67
+
68
+		update_option($this->option_name, $settings);
69
+		set_transient($this->option_name, $settings);
70
+
71
+		return $settings;
72
+	}
73
+
74
+	/**
75
+	 * @return array
76
+	 */
77 77
 	public function default_options() {
78
-        return array(
79
-            'menu'      => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ),
80
-            'mu_menu'   => 0,
81
-            'preview_page_id' => 0,
82
-            'use_html'  => true,
83
-            'jquery_css' => false,
84
-            'accordion_js' => false,
78
+		return array(
79
+			'menu'      => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ),
80
+			'mu_menu'   => 0,
81
+			'preview_page_id' => 0,
82
+			'use_html'  => true,
83
+			'jquery_css' => false,
84
+			'accordion_js' => false,
85 85
 
86 86
 			're_multi'  => 0,
87 87
 
88
-            'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
89
-            'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
90
-            'unique_msg' => __( 'This value must be unique.', 'formidable' ),
91
-            'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
92
-            'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
93
-            'submit_value' => __( 'Submit', 'formidable' ),
94
-            'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
95
-            'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
88
+			'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
89
+			'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
90
+			'unique_msg' => __( 'This value must be unique.', 'formidable' ),
91
+			'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
92
+			'failed_msg' => __( 'We\'re sorry. It looks like you\'ve  already submitted that.', 'formidable' ),
93
+			'submit_value' => __( 'Submit', 'formidable' ),
94
+			'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
95
+			'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
96 96
 
97
-            'email_to' => '[admin_email]',
98
-        );
99
-    }
97
+			'email_to' => '[admin_email]',
98
+		);
99
+	}
100 100
 
101 101
 	private function set_default_options() {
102
-        $this->fill_recaptcha_settings();
103
-
104
-        if ( ! isset($this->load_style) ) {
105
-            if ( ! isset($this->custom_style) ) {
106
-                $this->custom_style = true;
107
-            }
108
-
109
-            $this->load_style = 'all';
110
-        }
111
-
112
-        $this->fill_with_defaults();
113
-
114
-        if ( is_multisite() && is_admin() ) {
115
-            $mu_menu = get_site_option('frm_admin_menu_name');
116
-            if ( $mu_menu && ! empty($mu_menu) ) {
117
-                $this->menu = $mu_menu;
118
-                $this->mu_menu = 1;
119
-            }
120
-        }
121
-
122
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
123
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
-            if ( ! isset($this->$frm_role) ) {
125
-                $this->$frm_role = 'administrator';
126
-            }
127
-        }
128
-    }
102
+		$this->fill_recaptcha_settings();
103
+
104
+		if ( ! isset($this->load_style) ) {
105
+			if ( ! isset($this->custom_style) ) {
106
+				$this->custom_style = true;
107
+			}
108
+
109
+			$this->load_style = 'all';
110
+		}
111
+
112
+		$this->fill_with_defaults();
113
+
114
+		if ( is_multisite() && is_admin() ) {
115
+			$mu_menu = get_site_option('frm_admin_menu_name');
116
+			if ( $mu_menu && ! empty($mu_menu) ) {
117
+				$this->menu = $mu_menu;
118
+				$this->mu_menu = 1;
119
+			}
120
+		}
121
+
122
+		$frm_roles = FrmAppHelper::frm_capabilities('pro');
123
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
+			if ( ! isset($this->$frm_role) ) {
125
+				$this->$frm_role = 'administrator';
126
+			}
127
+		}
128
+	}
129 129
 
130 130
 	public function fill_with_defaults( $params = array() ) {
131
-        $settings = $this->default_options();
131
+		$settings = $this->default_options();
132 132
 
133
-        foreach ( $settings as $setting => $default ) {
133
+		foreach ( $settings as $setting => $default ) {
134 134
 			if ( isset( $params[ 'frm_' . $setting ] ) ) {
135 135
 				$this->{$setting} = $params[ 'frm_' . $setting ];
136
-            } else if ( ! isset($this->{$setting}) ) {
137
-                $this->{$setting} = $default;
138
-            }
136
+			} else if ( ! isset($this->{$setting}) ) {
137
+				$this->{$setting} = $default;
138
+			}
139 139
 
140 140
 			if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
141 141
 				$this->{$setting} = $default;
142 142
 			}
143 143
 
144
-            unset($setting, $default);
145
-        }
146
-    }
144
+			unset($setting, $default);
145
+		}
146
+	}
147 147
 
148
-    private function fill_recaptcha_settings() {
149
-        $privkey = '';
148
+	private function fill_recaptcha_settings() {
149
+		$privkey = '';
150 150
 		$re_lang = '';
151 151
 
152
-        if ( ! isset($this->pubkey) ) {
153
-            // get the options from the database
154
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
158
-        }
152
+		if ( ! isset($this->pubkey) ) {
153
+			// get the options from the database
154
+			$recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
+			$this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
+			$privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
+			$re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
158
+		}
159 159
 
160
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
161
-            $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162
-        }
160
+		if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
161
+			$this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162
+		}
163 163
 
164
-        if ( ! isset($this->privkey) ) {
165
-            $this->privkey = $privkey;
166
-        }
164
+		if ( ! isset($this->privkey) ) {
165
+			$this->privkey = $privkey;
166
+		}
167 167
 
168
-        if ( ! isset($this->re_lang) ) {
169
-            $this->re_lang = $re_lang;
170
-        }
171
-    }
168
+		if ( ! isset($this->re_lang) ) {
169
+			$this->re_lang = $re_lang;
170
+		}
171
+	}
172 172
 
173
-    public function validate( $params, $errors ) {
174
-        $errors = apply_filters( 'frm_validate_settings', $errors, $params );
175
-        return $errors;
176
-    }
173
+	public function validate( $params, $errors ) {
174
+		$errors = apply_filters( 'frm_validate_settings', $errors, $params );
175
+		return $errors;
176
+	}
177 177
 
178 178
 	public function update( $params ) {
179
-        $this->fill_with_defaults($params);
180
-        $this->update_settings($params);
179
+		$this->fill_with_defaults($params);
180
+		$this->update_settings($params);
181 181
 
182
-        if ( $this->mu_menu ) {
183
-            update_site_option('frm_admin_menu_name', $this->menu);
184
-        } else if ( current_user_can('administrator') ) {
185
-            update_site_option('frm_admin_menu_name', false);
186
-        }
182
+		if ( $this->mu_menu ) {
183
+			update_site_option('frm_admin_menu_name', $this->menu);
184
+		} else if ( current_user_can('administrator') ) {
185
+			update_site_option('frm_admin_menu_name', false);
186
+		}
187 187
 
188
-        $this->update_roles($params);
188
+		$this->update_roles($params);
189 189
 
190
-        do_action( 'frm_update_settings', $params );
191
-    }
190
+		do_action( 'frm_update_settings', $params );
191
+	}
192 192
 
193 193
 	private function update_settings( $params ) {
194
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
194
+		$this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
195 195
 
196
-        $this->pubkey = trim($params['frm_pubkey']);
197
-        $this->privkey = $params['frm_privkey'];
198
-        $this->re_lang = $params['frm_re_lang'];
196
+		$this->pubkey = trim($params['frm_pubkey']);
197
+		$this->privkey = $params['frm_privkey'];
198
+		$this->re_lang = $params['frm_re_lang'];
199 199
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
200 200
 
201
-        $this->load_style = $params['frm_load_style'];
202
-        $this->preview_page_id = (int) $params['frm-preview-page-id'];
201
+		$this->load_style = $params['frm_load_style'];
202
+		$this->preview_page_id = (int) $params['frm-preview-page-id'];
203 203
 
204
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
205
-        //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
204
+		$this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
205
+		//$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
206 206
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
207 207
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
208
-    }
208
+	}
209 209
 
210 210
 	private function update_roles( $params ) {
211
-        global $wp_roles;
211
+		global $wp_roles;
212 212
 
213
-        $frm_roles = FrmAppHelper::frm_capabilities();
214
-        $roles = get_editable_roles();
215
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
213
+		$frm_roles = FrmAppHelper::frm_capabilities();
214
+		$roles = get_editable_roles();
215
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
+			$this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
217 217
 
218
-            // Make sure administrators always have permissions
219
-            if ( ! in_array( 'administrator', $this->$frm_role ) ) {
218
+			// Make sure administrators always have permissions
219
+			if ( ! in_array( 'administrator', $this->$frm_role ) ) {
220 220
 				array_push( $this->$frm_role, 'administrator' );
221
-            }
221
+			}
222 222
 
223
-            foreach ( $roles as $role => $details ) {
224
-                if ( in_array($role, $this->$frm_role) ) {
225
-    			    $wp_roles->add_cap( $role, $frm_role );
226
-    			} else {
227
-    			    $wp_roles->remove_cap( $role, $frm_role );
228
-    			}
229
-    		}
223
+			foreach ( $roles as $role => $details ) {
224
+				if ( in_array($role, $this->$frm_role) ) {
225
+					$wp_roles->add_cap( $role, $frm_role );
226
+				} else {
227
+					$wp_roles->remove_cap( $role, $frm_role );
228
+				}
229
+			}
230 230
 		}
231
-    }
231
+	}
232 232
 
233 233
 	public function store() {
234
-        // Save the posted value in the database
234
+		// Save the posted value in the database
235 235
 
236
-        update_option('frm_options', $this);
236
+		update_option('frm_options', $this);
237 237
 
238
-        delete_transient('frm_options');
239
-        set_transient('frm_options', $this);
238
+		delete_transient('frm_options');
239
+		set_transient('frm_options', $this);
240 240
 
241
-        do_action( 'frm_store_settings' );
242
-    }
241
+		do_action( 'frm_store_settings' );
242
+	}
243 243
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
 	public $re_multi;
30 30
 
31 31
     public function __construct() {
32
-        if ( ! defined('ABSPATH') ) {
33
-            die('You are not allowed to call this page directly.');
32
+        if ( ! defined( 'ABSPATH' ) ) {
33
+            die( 'You are not allowed to call this page directly.' );
34 34
         }
35 35
 
36
-        $settings = get_transient($this->option_name);
36
+        $settings = get_transient( $this->option_name );
37 37
 
38
-        if ( ! is_object($settings) ) {
39
-            $settings = $this->translate_settings($settings);
38
+        if ( ! is_object( $settings ) ) {
39
+            $settings = $this->translate_settings( $settings );
40 40
         }
41 41
 
42 42
         foreach ( $settings as $setting_name => $setting ) {
43 43
             $this->{$setting_name} = $setting;
44
-            unset($setting_name, $setting);
44
+            unset( $setting_name, $setting );
45 45
         }
46 46
 
47 47
         $this->set_default_options();
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private function translate_settings( $settings ) {
51 51
         if ( $settings ) { //workaround for W3 total cache conflict
52
-            return unserialize(serialize($settings));
52
+            return unserialize( serialize( $settings ) );
53 53
         }
54 54
 
55
-        $settings = get_option($this->option_name);
56
-        if ( is_object($settings) ) {
57
-            set_transient($this->option_name, $settings);
55
+        $settings = get_option( $this->option_name );
56
+        if ( is_object( $settings ) ) {
57
+            set_transient( $this->option_name, $settings );
58 58
             return $settings;
59 59
         }
60 60
 
61 61
         // If unserializing didn't work
62 62
         if ( $settings ) { //workaround for W3 total cache conflict
63
-            $settings = unserialize(serialize($settings));
63
+            $settings = unserialize( serialize( $settings ) );
64 64
         } else {
65 65
             $settings = $this;
66 66
         }
67 67
 
68
-        update_option($this->option_name, $settings);
69
-        set_transient($this->option_name, $settings);
68
+        update_option( $this->option_name, $settings );
69
+        set_transient( $this->option_name, $settings );
70 70
 
71 71
         return $settings;
72 72
     }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	private function set_default_options() {
102 102
         $this->fill_recaptcha_settings();
103 103
 
104
-        if ( ! isset($this->load_style) ) {
105
-            if ( ! isset($this->custom_style) ) {
104
+        if ( ! isset( $this->load_style ) ) {
105
+            if ( ! isset( $this->custom_style ) ) {
106 106
                 $this->custom_style = true;
107 107
             }
108 108
 
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
         $this->fill_with_defaults();
113 113
 
114 114
         if ( is_multisite() && is_admin() ) {
115
-            $mu_menu = get_site_option('frm_admin_menu_name');
116
-            if ( $mu_menu && ! empty($mu_menu) ) {
115
+            $mu_menu = get_site_option( 'frm_admin_menu_name' );
116
+            if ( $mu_menu && ! empty( $mu_menu ) ) {
117 117
                 $this->menu = $mu_menu;
118 118
                 $this->mu_menu = 1;
119 119
             }
120 120
         }
121 121
 
122
-        $frm_roles = FrmAppHelper::frm_capabilities('pro');
122
+        $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
123 123
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
124
-            if ( ! isset($this->$frm_role) ) {
124
+            if ( ! isset( $this->$frm_role ) ) {
125 125
                 $this->$frm_role = 'administrator';
126 126
             }
127 127
         }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
         $settings = $this->default_options();
132 132
 
133 133
         foreach ( $settings as $setting => $default ) {
134
-			if ( isset( $params[ 'frm_' . $setting ] ) ) {
135
-				$this->{$setting} = $params[ 'frm_' . $setting ];
136
-            } else if ( ! isset($this->{$setting}) ) {
134
+			if ( isset( $params['frm_' . $setting] ) ) {
135
+				$this->{$setting} = $params['frm_' . $setting];
136
+            } else if ( ! isset( $this->{$setting}) ) {
137 137
                 $this->{$setting} = $default;
138 138
             }
139 139
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				$this->{$setting} = $default;
142 142
 			}
143 143
 
144
-            unset($setting, $default);
144
+            unset( $setting, $default );
145 145
         }
146 146
     }
147 147
 
@@ -149,23 +149,23 @@  discard block
 block discarded – undo
149 149
         $privkey = '';
150 150
 		$re_lang = '';
151 151
 
152
-        if ( ! isset($this->pubkey) ) {
152
+        if ( ! isset( $this->pubkey ) ) {
153 153
             // get the options from the database
154
-            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha');
155
-            $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : '';
156
-            $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey;
157
-            $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang;
154
+            $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
155
+            $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
156
+            $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
157
+            $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
158 158
         }
159 159
 
160
-        if ( ! isset($this->re_msg) || empty($this->re_msg) ) {
160
+        if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
161 161
             $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
162 162
         }
163 163
 
164
-        if ( ! isset($this->privkey) ) {
164
+        if ( ! isset( $this->privkey ) ) {
165 165
             $this->privkey = $privkey;
166 166
         }
167 167
 
168
-        if ( ! isset($this->re_lang) ) {
168
+        if ( ! isset( $this->re_lang ) ) {
169 169
             $this->re_lang = $re_lang;
170 170
         }
171 171
     }
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
     }
177 177
 
178 178
 	public function update( $params ) {
179
-        $this->fill_with_defaults($params);
180
-        $this->update_settings($params);
179
+        $this->fill_with_defaults( $params );
180
+        $this->update_settings( $params );
181 181
 
182 182
         if ( $this->mu_menu ) {
183
-            update_site_option('frm_admin_menu_name', $this->menu);
184
-        } else if ( current_user_can('administrator') ) {
185
-            update_site_option('frm_admin_menu_name', false);
183
+            update_site_option( 'frm_admin_menu_name', $this->menu );
184
+        } else if ( current_user_can( 'administrator' ) ) {
185
+            update_site_option( 'frm_admin_menu_name', false );
186 186
         }
187 187
 
188
-        $this->update_roles($params);
188
+        $this->update_roles( $params );
189 189
 
190 190
         do_action( 'frm_update_settings', $params );
191 191
     }
192 192
 
193 193
 	private function update_settings( $params ) {
194
-        $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
194
+        $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0;
195 195
 
196
-        $this->pubkey = trim($params['frm_pubkey']);
196
+        $this->pubkey = trim( $params['frm_pubkey'] );
197 197
         $this->privkey = $params['frm_privkey'];
198 198
         $this->re_lang = $params['frm_re_lang'];
199 199
 		$this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         $this->load_style = $params['frm_load_style'];
202 202
         $this->preview_page_id = (int) $params['frm-preview-page-id'];
203 203
 
204
-        $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
204
+        $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0;
205 205
         //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
206 206
 		$this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0;
207 207
 		$this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $frm_roles = FrmAppHelper::frm_capabilities();
214 214
         $roles = get_editable_roles();
215 215
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
216
-            $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
216
+            $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' );
217 217
 
218 218
             // Make sure administrators always have permissions
219 219
             if ( ! in_array( 'administrator', $this->$frm_role ) ) {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             }
222 222
 
223 223
             foreach ( $roles as $role => $details ) {
224
-                if ( in_array($role, $this->$frm_role) ) {
224
+                if ( in_array( $role, $this->$frm_role ) ) {
225 225
     			    $wp_roles->add_cap( $role, $frm_role );
226 226
     			} else {
227 227
     			    $wp_roles->remove_cap( $role, $frm_role );
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	public function store() {
234 234
         // Save the posted value in the database
235 235
 
236
-        update_option('frm_options', $this);
236
+        update_option( 'frm_options', $this );
237 237
 
238
-        delete_transient('frm_options');
239
-        set_transient('frm_options', $this);
238
+        delete_transient( 'frm_options' );
239
+        set_transient( 'frm_options', $this );
240 240
 
241 241
         do_action( 'frm_store_settings' );
242 242
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,8 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
 	private function translate_settings( $settings ) {
51
-        if ( $settings ) { //workaround for W3 total cache conflict
51
+        if ( $settings ) {
52
+//workaround for W3 total cache conflict
52 53
             return unserialize(serialize($settings));
53 54
         }
54 55
 
@@ -59,7 +60,8 @@  discard block
 block discarded – undo
59 60
         }
60 61
 
61 62
         // If unserializing didn't work
62
-        if ( $settings ) { //workaround for W3 total cache conflict
63
+        if ( $settings ) {
64
+//workaround for W3 total cache conflict
63 65
             $settings = unserialize(serialize($settings));
64 66
         } else {
65 67
             $settings = $this;
Please login to merge, or discard this patch.
classes/models/FrmEDD_SL_Plugin_Updater.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 	 * @uses api_request()
71 71
 	 *
72 72
 	 * @param array   $_transient_data Update array build by WordPress.
73
-	 * @return array Modified update array with custom plugin data.
73
+	 * @return stdClass Modified update array with custom plugin data.
74 74
 	 */
75 75
 	public function check_update( $_transient_data ) {
76 76
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$this->version     = $_api_data['version'];
44 44
 		$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
45 45
 
46
-		$frm_edd_plugin_data[ $this->slug ] = $this->api_data;
46
+		$frm_edd_plugin_data[$this->slug] = $this->api_data;
47 47
 
48 48
 		// Set up hooks.
49 49
 		$this->init();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			$_transient_data = new stdClass;
84 84
 		}
85 85
 
86
-		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
86
+		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[$this->name] ) && false === $this->wp_override ) {
87 87
 			return $_transient_data;
88 88
 		}
89 89
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 					$version_info->plugin = $this->name;
98 98
 				}
99 99
 
100
-				$_transient_data->response[ $this->name ] = $version_info;
100
+				$_transient_data->response[$this->name] = $version_info;
101 101
 
102 102
 			}
103 103
 
104 104
 			$_transient_data->last_checked = time();
105
-			$_transient_data->checked[ $this->name ] = $this->version;
105
+			$_transient_data->checked[$this->name] = $this->version;
106 106
 
107 107
 		}
108 108
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 			wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) );
246 246
 		}
247 247
 
248
-		$data         = $frm_edd_plugin_data[ $_REQUEST['slug'] ];
248
+		$data         = $frm_edd_plugin_data[$_REQUEST['slug']];
249 249
 		$cache_key    = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
250 250
 		$version_info = get_transient( $cache_key );
251 251
 
Please login to merge, or discard this patch.