Completed
Push — master ( 9a0984...263488 )
by Stephanie
11:38 queued 05:45
created
classes/models/fields/FrmFieldNumber.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 		//validate the number format
45 45
 		if ( ! is_numeric( $args['value'] ) && '' !== $args['value'] ) {
46
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
46
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
47 47
 		}
48 48
 
49 49
 		// validate number settings
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 			if ( $frm_settings->use_html && $maxnum != '' && $minnum != '' ) {
56 56
 				$value = (float) $args['value'];
57 57
 				if ( $value < $minnum ) {
58
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
58
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
59 59
 				} elseif ( $value > $maxnum ) {
60
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
60
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
61 61
 				}
62 62
 			}
63 63
 		}
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldUrl.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,9 +61,9 @@
 block discarded – undo
61 61
 
62 62
 		// validate the url format
63 63
 		if ( ! empty( $value ) && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
64
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
64
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
65 65
 		} elseif ( $this->field->required == '1' && empty( $value ) ) {
66
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
66
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
67 67
 		}
68 68
 
69 69
 		return $errors;
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
         FrmEntry::sanitize_entry_post( $values );
6 6
         $errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
8
+        if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) {
9 9
             $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10 10
             return $errors;
11 11
         }
12 12
 
13
-		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' ) ) ) {
13
+		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' ) ) ) {
14 14
             $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15 15
         }
16 16
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
         );
67 67
         $args = wp_parse_args( $args, $defaults );
68 68
 
69
-        if ( empty($args['parent_field_id']) ) {
70
-			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
69
+        if ( empty( $args['parent_field_id'] ) ) {
70
+			$value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : '';
71 71
         } else {
72 72
             // value is from a nested form
73 73
             $value = $values;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80 80
 
81 81
 		// Reset arrays with only one value if it's not a field where array keys need to be preserved
82
-		if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) {
83
-			$value = reset($value);
82
+		if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) {
83
+			$value = reset( $value );
84 84
 		}
85 85
 
86 86
 		if ( ! is_array( $value ) ) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
91
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
91
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
92 92
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
93 93
             $_POST['item_name'] = $value;
94 94
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			$pattern = self::phone_format( $field );
172 172
 
173 173
 			if ( ! preg_match( $pattern, $value ) ) {
174
-				$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
174
+				$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
175 175
 			}
176 176
 		}
177 177
 	}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 	private static function is_akismet_spam( $values ) {
282 282
 		global $wpcom_api_key;
283
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
283
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
284 284
 	}
285 285
 
286 286
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
     public static function blacklist_check( $values ) {
292
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
292
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
293 293
             return false;
294 294
         }
295 295
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
349 349
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
350 350
 		$datas['blog_lang'] = get_locale();
351
-		$datas['blog_charset'] = get_option('blog_charset');
351
+		$datas['blog_charset'] = get_option( 'blog_charset' );
352 352
 
353 353
 		if ( akismet_test_mode() ) {
354 354
 			$datas['is_test'] = 'true';
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
 			// Send any potentially useful $_SERVER vars, but avoid sending junk we don't need.
404 404
 			if ( $include_value ) {
405
-				$datas[ $key ] = $value;
405
+				$datas[$key] = $value;
406 406
 			}
407 407
 			unset( $key, $value );
408 408
 		}
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmEntryValidate {
4
-    public static function validate( $values, $exclude = false ) {
5
-        FrmEntry::sanitize_entry_post( $values );
6
-        $errors = array();
4
+	public static function validate( $values, $exclude = false ) {
5
+		FrmEntry::sanitize_entry_post( $values );
6
+		$errors = array();
7 7
 
8
-        if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
-            $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
-            return $errors;
11
-        }
8
+		if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
9
+			$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
10
+			return $errors;
11
+		}
12 12
 
13 13
 		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' ) ) ) {
14
-            $errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
-        }
14
+			$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
15
+		}
16 16
 
17 17
 		self::set_item_key( $values );
18 18
 
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
 		return FrmField::getAll( $where, 'field_order' );
58 58
 	}
59 59
 
60
-    public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
-        $defaults = array(
62
-            'id'              => $posted_field->id,
63
-            'parent_field_id' => '', // the id of the repeat or embed form
64
-            'key_pointer'     => '', // the pointer in the posted array
65
-            'exclude'         => array(), // exclude these field types from validation
66
-        );
67
-        $args = wp_parse_args( $args, $defaults );
60
+	public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
61
+		$defaults = array(
62
+			'id'              => $posted_field->id,
63
+			'parent_field_id' => '', // the id of the repeat or embed form
64
+			'key_pointer'     => '', // the pointer in the posted array
65
+			'exclude'         => array(), // exclude these field types from validation
66
+		);
67
+		$args = wp_parse_args( $args, $defaults );
68 68
 
69
-        if ( empty($args['parent_field_id']) ) {
69
+		if ( empty($args['parent_field_id']) ) {
70 70
 			$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
71
-        } else {
72
-            // value is from a nested form
73
-            $value = $values;
74
-        }
71
+		} else {
72
+			// value is from a nested form
73
+			$value = $values;
74
+		}
75 75
 
76
-        // Check for values in "Other" fields
77
-        FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
76
+		// Check for values in "Other" fields
77
+		FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
78 78
 
79 79
 		self::maybe_clear_value_for_default_blank_setting( $posted_field, $value );
80 80
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 			$value = trim( $value );
88 88
 		}
89 89
 
90
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
90
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
91 91
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
92
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
93
-            $_POST['item_name'] = $value;
94
-        }
92
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
93
+			$_POST['item_name'] = $value;
94
+		}
95 95
 
96 96
 		FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
105 105
 		$errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
106
-    }
106
+	}
107 107
 
108 108
 	private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) {
109 109
 		$is_default = ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value );
@@ -239,34 +239,34 @@  discard block
 block discarded – undo
239 239
 		}
240 240
 
241 241
 		self::validate_field_types( $errors, $field, '', $args );
242
-    }
243
-
244
-    /**
245
-     * check for spam
246
-     * @param boolean $exclude
247
-     * @param array $values
248
-     * @param array $errors by reference
249
-     */
250
-    public static function spam_check( $exclude, $values, &$errors ) {
251
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
252
-            // only check spam if there are no other errors
253
-            return;
254
-        }
242
+	}
243
+
244
+	/**
245
+	 * check for spam
246
+	 * @param boolean $exclude
247
+	 * @param array $values
248
+	 * @param array $errors by reference
249
+	 */
250
+	public static function spam_check( $exclude, $values, &$errors ) {
251
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
252
+			// only check spam if there are no other errors
253
+			return;
254
+		}
255 255
 
256 256
 		if ( self::is_honeypot_spam() || self::is_spam_bot() ) {
257 257
 			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
258 258
 		}
259 259
 
260
-    	if ( self::blacklist_check( $values ) ) {
261
-            $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
262
-    	}
260
+		if ( self::blacklist_check( $values ) ) {
261
+			$errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' );
262
+		}
263 263
 
264
-        if ( self::is_akismet_spam( $values ) ) {
264
+		if ( self::is_akismet_spam( $values ) ) {
265 265
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
266 266
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
267 267
 			}
268
-	    }
269
-    }
268
+		}
269
+	}
270 270
 
271 271
 	private static function is_honeypot_spam() {
272 272
 		$honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' );
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
289 289
 	}
290 290
 
291
-    public static function blacklist_check( $values ) {
292
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
293
-            return false;
294
-        }
291
+	public static function blacklist_check( $values ) {
292
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
293
+			return false;
294
+		}
295 295
 
296
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
297
-    	if ( empty( $mod_keys ) ) {
298
-    		return false;
299
-    	}
296
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
297
+		if ( empty( $mod_keys ) ) {
298
+			return false;
299
+		}
300 300
 
301 301
 		$content = FrmEntriesHelper::entry_array_to_string( $values );
302 302
 		if ( empty( $content ) ) {
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		$user_info = self::get_spam_check_user_info( $values );
309 309
 
310 310
 		return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent );
311
-    }
311
+	}
312 312
 
313 313
 	/**
314 314
 	 * Check entries for Akismet spam
Please login to merge, or discard this patch.
classes/models/FrmMigrate.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	/**
187
-	 * @param int|string $old_db_version
187
+	 * @param boolean $old_db_version
188 188
 	 */
189 189
 	private function migrate_data( $old_db_version ) {
190 190
 		if ( ! $old_db_version ) {
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 		return $charset_collate;
83 83
 	}
84 84
 
85
-    private function create_tables() {
86
-        $charset_collate = $this->collation();
87
-        $sql = array();
85
+	private function create_tables() {
86
+		$charset_collate = $this->collation();
87
+		$sql = array();
88 88
 
89
-        /* Create/Upgrade Fields Table */
89
+		/* Create/Upgrade Fields Table */
90 90
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
91 91
 				id BIGINT(20) NOT NULL auto_increment,
92 92
 				field_key varchar(100) default NULL,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 UNIQUE KEY field_key (field_key)
106 106
         )';
107 107
 
108
-        /* Create/Upgrade Forms Table */
108
+		/* Create/Upgrade Forms Table */
109 109
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
110 110
                 id int(11) NOT NULL auto_increment,
111 111
 				form_key varchar(100) default NULL,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 UNIQUE KEY form_key (form_key)
124 124
         )';
125 125
 
126
-        /* Create/Upgrade Items Table */
126
+		/* Create/Upgrade Items Table */
127 127
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
128 128
 				id BIGINT(20) NOT NULL auto_increment,
129 129
 				item_key varchar(100) default NULL,
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                 UNIQUE KEY item_key (item_key)
147 147
         )';
148 148
 
149
-        /* Create/Upgrade Meta Table */
149
+		/* Create/Upgrade Meta Table */
150 150
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
151 151
 				id BIGINT(20) NOT NULL auto_increment,
152 152
 				meta_value longtext default NULL,
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
                 KEY item_id (item_id)
159 159
         )';
160 160
 
161
-        foreach ( $sql as $q ) {
161
+		foreach ( $sql as $q ) {
162 162
 			if ( function_exists( 'dbDelta' ) ) {
163 163
 				dbDelta( $q . $charset_collate . ';' );
164 164
 			} else {
165 165
 				global $wpdb;
166 166
 				$wpdb->query( $q . $charset_collate );
167 167
 			}
168
-            unset($q);
169
-        }
170
-    }
168
+			unset($q);
169
+		}
170
+	}
171 171
 
172 172
 	private function maybe_create_contact_form() {
173 173
 		$template_id = FrmForm::get_id_by_key( 'contact' );
@@ -209,31 +209,31 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 	}
211 211
 
212
-    public function uninstall() {
212
+	public function uninstall() {
213 213
 		if ( ! current_user_can( 'administrator' ) ) {
214
-            $frm_settings = FrmAppHelper::get_settings();
215
-            wp_die($frm_settings->admin_permission);
216
-        }
214
+			$frm_settings = FrmAppHelper::get_settings();
215
+			wp_die($frm_settings->admin_permission);
216
+		}
217 217
 
218
-        global $wpdb, $wp_roles;
218
+		global $wpdb, $wp_roles;
219 219
 
220 220
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
221 221
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
222 222
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
223 223
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
224 224
 
225
-        delete_option('frm_options');
226
-        delete_option('frm_db_version');
227
-
228
-        //delete roles
229
-        $frm_roles = FrmAppHelper::frm_capabilities();
230
-        $roles = get_editable_roles();
231
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232
-            foreach ( $roles as $role => $details ) {
233
-                $wp_roles->remove_cap( $role, $frm_role );
234
-                unset($role, $details);
235
-    		}
236
-    		unset($frm_role, $frm_role_description);
225
+		delete_option('frm_options');
226
+		delete_option('frm_db_version');
227
+
228
+		//delete roles
229
+		$frm_roles = FrmAppHelper::frm_capabilities();
230
+		$roles = get_editable_roles();
231
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232
+			foreach ( $roles as $role => $details ) {
233
+				$wp_roles->remove_cap( $role, $frm_role );
234
+				unset($role, $details);
235
+			}
236
+			unset($frm_role, $frm_role_description);
237 237
 		}
238 238
 		unset($roles, $frm_roles);
239 239
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
259 259
 
260
-        do_action('frm_after_uninstall');
261
-        return true;
262
-    }
260
+		do_action('frm_after_uninstall');
261
+		return true;
262
+	}
263 263
 
264 264
 	/**
265 265
 	 * Reverse migration 17 -- Divide by 9
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
 		}
371 371
 	}
372 372
 
373
-    /**
374
-     * Change field size from character to pixel -- Multiply by 9
375
-     */
376
-    private function migrate_to_17() {
377
-        global $wpdb;
373
+	/**
374
+	 * Change field size from character to pixel -- Multiply by 9
375
+	 */
376
+	private function migrate_to_17() {
377
+		global $wpdb;
378 378
 		$pixel_conversion = 9;
379 379
 
380
-        // Get query arguments
380
+		// Get query arguments
381 381
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
382 382
 		$query = array(
383 383
 			'type' => $field_types,
@@ -385,137 +385,137 @@  discard block
 block discarded – undo
385 385
 			'field_options not like' => 's:4:"size";s:0:',
386 386
 		);
387 387
 
388
-        // Get results
388
+		// Get results
389 389
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
390 390
 
391
-        $updated = 0;
392
-        foreach ( $fields as $f ) {
393
-            $f->field_options = maybe_unserialize($f->field_options);
394
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
395
-                continue;
396
-            }
391
+		$updated = 0;
392
+		foreach ( $fields as $f ) {
393
+			$f->field_options = maybe_unserialize($f->field_options);
394
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
395
+				continue;
396
+			}
397 397
 
398 398
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
399
-            $f->field_options['size'] .= 'px';
400
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
401
-            if ( $u ) {
402
-                $updated++;
403
-            }
404
-            unset($f);
405
-        }
406
-
407
-        // Change the characters in widgets to pixels
408
-        $widgets = get_option('widget_frm_show_form');
409
-        if ( empty($widgets) ) {
410
-            return;
411
-        }
412
-
413
-        $widgets = maybe_unserialize($widgets);
414
-        foreach ( $widgets as $k => $widget ) {
415
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
416
-                continue;
417
-            }
399
+			$f->field_options['size'] .= 'px';
400
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
401
+			if ( $u ) {
402
+				$updated++;
403
+			}
404
+			unset($f);
405
+		}
406
+
407
+		// Change the characters in widgets to pixels
408
+		$widgets = get_option('widget_frm_show_form');
409
+		if ( empty($widgets) ) {
410
+			return;
411
+		}
412
+
413
+		$widgets = maybe_unserialize($widgets);
414
+		foreach ( $widgets as $k => $widget ) {
415
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
416
+				continue;
417
+			}
418 418
 			$size = round( $pixel_conversion * (int) $widget['size'] );
419
-            $size .= 'px';
419
+			$size .= 'px';
420 420
 			$widgets[ $k ]['size'] = $size;
421
-        }
422
-        update_option('widget_frm_show_form', $widgets);
423
-    }
424
-
425
-    /**
426
-     * Migrate post and email notification settings into actions
427
-     */
428
-    private function migrate_to_16() {
429
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
430
-
431
-        /**
432
-        * Old email settings format:
433
-        * email_to: Email or field id
434
-        * also_email_to: array of fields ids
435
-        * reply_to: Email, field id, 'custom'
436
-        * cust_reply_to: string
437
-        * reply_to_name: field id, 'custom'
438
-        * cust_reply_to_name: string
439
-        * plain_text: 0|1
440
-        * email_message: string or ''
441
-        * email_subject: string or ''
442
-        * inc_user_info: 0|1
443
-        * update_email: 0, 1, 2
444
-        *
445
-        * Old autoresponder settings format:
446
-        * auto_responder: 0|1
447
-        * ar_email_message: string or ''
448
-        * ar_email_to: field id
449
-        * ar_plain_text: 0|1
450
-        * ar_reply_to_name: string
451
-        * ar_reply_to: string
452
-        * ar_email_subject: string
453
-        * ar_update_email: 0, 1, 2
454
-        *
455
-        * New email settings:
456
-        * post_content: json settings
457
-        * post_title: form id
458
-        * post_excerpt: message
459
-        *
460
-        */
461
-
462
-        foreach ( $forms as $form ) {
421
+		}
422
+		update_option('widget_frm_show_form', $widgets);
423
+	}
424
+
425
+	/**
426
+	 * Migrate post and email notification settings into actions
427
+	 */
428
+	private function migrate_to_16() {
429
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
430
+
431
+		/**
432
+		 * Old email settings format:
433
+		 * email_to: Email or field id
434
+		 * also_email_to: array of fields ids
435
+		 * reply_to: Email, field id, 'custom'
436
+		 * cust_reply_to: string
437
+		 * reply_to_name: field id, 'custom'
438
+		 * cust_reply_to_name: string
439
+		 * plain_text: 0|1
440
+		 * email_message: string or ''
441
+		 * email_subject: string or ''
442
+		 * inc_user_info: 0|1
443
+		 * update_email: 0, 1, 2
444
+		 *
445
+		 * Old autoresponder settings format:
446
+		 * auto_responder: 0|1
447
+		 * ar_email_message: string or ''
448
+		 * ar_email_to: field id
449
+		 * ar_plain_text: 0|1
450
+		 * ar_reply_to_name: string
451
+		 * ar_reply_to: string
452
+		 * ar_email_subject: string
453
+		 * ar_update_email: 0, 1, 2
454
+		 *
455
+		 * New email settings:
456
+		 * post_content: json settings
457
+		 * post_title: form id
458
+		 * post_excerpt: message
459
+		 *
460
+		 */
461
+
462
+		foreach ( $forms as $form ) {
463 463
 			if ( $form->is_template && $form->default_template ) {
464 464
 				// don't migrate the default templates since the email will be added anyway
465 465
 				continue;
466 466
 			}
467 467
 
468
-            // Format form options
469
-            $form_options = maybe_unserialize($form->options);
468
+			// Format form options
469
+			$form_options = maybe_unserialize($form->options);
470 470
 
471
-            // Migrate settings to actions
472
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
473
-        }
474
-    }
471
+			// Migrate settings to actions
472
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
473
+		}
474
+	}
475 475
 
476
-    private function migrate_to_11() {
477
-        global $wpdb;
476
+	private function migrate_to_11() {
477
+		global $wpdb;
478 478
 
479
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
479
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
480 480
 
481
-        $sending = __( 'Sending', 'formidable' );
481
+		$sending = __( 'Sending', 'formidable' );
482 482
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
483
-        $old_default_html = <<<DEFAULT_HTML
483
+		$old_default_html = <<<DEFAULT_HTML
484 484
 <div class="frm_submit">
485 485
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
486 486
 <input type="submit" value="[button_label]" [button_action] />
487 487
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
488 488
 </div>
489 489
 DEFAULT_HTML;
490
-        unset($sending, $img);
490
+		unset($sending, $img);
491 491
 
492
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
493
-        $draft_link = FrmFormsHelper::get_draft_link();
492
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
493
+		$draft_link = FrmFormsHelper::get_draft_link();
494 494
 		foreach ( $forms as $form ) {
495
-            $form->options = maybe_unserialize($form->options);
496
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
497
-                continue;
498
-            }
495
+			$form->options = maybe_unserialize($form->options);
496
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
497
+				continue;
498
+			}
499 499
 
500
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
501
-                $form->options['submit_html'] = $new_default_html;
500
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
501
+				$form->options['submit_html'] = $new_default_html;
502 502
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
503 503
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
504 504
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
505 505
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
506
-            }
507
-            unset($form);
508
-        }
509
-        unset($forms);
510
-    }
506
+			}
507
+			unset($form);
508
+		}
509
+		unset($forms);
510
+	}
511 511
 
512
-    private function migrate_to_6() {
513
-        global $wpdb;
512
+	private function migrate_to_6() {
513
+		global $wpdb;
514 514
 
515 515
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
516 516
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
517 517
 
518
-        $default_html = <<<DEFAULT_HTML
518
+		$default_html = <<<DEFAULT_HTML
519 519
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
520 520
     <label class="frm_pos_[label_position]">[field_name]
521 521
         <span class="frm_required">[required_label]</span>
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 </div>
526 526
 DEFAULT_HTML;
527 527
 
528
-        $old_default_html = <<<DEFAULT_HTML
528
+		$old_default_html = <<<DEFAULT_HTML
529 529
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
530 530
     <label class="frm_pos_[label_position]">[field_name]
531 531
         <span class="frm_required">[required_label]</span>
@@ -535,27 +535,27 @@  discard block
 block discarded – undo
535 535
 </div>
536 536
 DEFAULT_HTML;
537 537
 
538
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
539
-        foreach ( $fields as $field ) {
540
-            $field->field_options = maybe_unserialize($field->field_options);
538
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
539
+		foreach ( $fields as $field ) {
540
+			$field->field_options = maybe_unserialize($field->field_options);
541 541
 			$html = FrmField::get_option( $field, 'custom_html' );
542 542
 			if ( $html == $default_html || $html == $old_default_html ) {
543
-                $field->field_options['custom_html'] = $new_default_html;
543
+				$field->field_options['custom_html'] = $new_default_html;
544 544
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
545
-            }
546
-            unset($field);
547
-        }
548
-        unset($default_html, $old_default_html, $fields);
549
-    }
545
+			}
546
+			unset($field);
547
+		}
548
+		unset($default_html, $old_default_html, $fields);
549
+	}
550 550
 
551 551
 	/**
552 552
 	 * Adds user id to the entry
553 553
 	 */
554
-    private function migrate_to_4() {
555
-        global $wpdb;
554
+	private function migrate_to_4() {
555
+		global $wpdb;
556 556
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
557
-        foreach ( $user_ids as $user_id ) {
557
+		foreach ( $user_ids as $user_id ) {
558 558
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
559
-        }
560
-    }
559
+		}
560
+	}
561 561
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 	public $entry_metas;
8 8
 
9 9
 	public function __construct() {
10
-		if ( ! defined('ABSPATH') ) {
11
-			die('You are not allowed to call this page directly.');
10
+		if ( ! defined( 'ABSPATH' ) ) {
11
+			die( 'You are not allowed to call this page directly.' );
12 12
 		}
13 13
 
14 14
 		global $wpdb;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			}
52 52
 		}
53 53
 
54
-		do_action('frm_after_install');
54
+		do_action( 'frm_after_install' );
55 55
 
56 56
 		$frm_vars['doing_upgrade'] = false;
57 57
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				global $wpdb;
166 166
 				$wpdb->query( $q . $charset_collate );
167 167
 			}
168
-            unset($q);
168
+            unset( $q );
169 169
         }
170 170
     }
171 171
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     public function uninstall() {
213 213
 		if ( ! current_user_can( 'administrator' ) ) {
214 214
             $frm_settings = FrmAppHelper::get_settings();
215
-            wp_die($frm_settings->admin_permission);
215
+            wp_die( $frm_settings->admin_permission );
216 216
         }
217 217
 
218 218
         global $wpdb, $wp_roles;
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
223 223
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
224 224
 
225
-        delete_option('frm_options');
226
-        delete_option('frm_db_version');
225
+        delete_option( 'frm_options' );
226
+        delete_option( 'frm_db_version' );
227 227
 
228 228
         //delete roles
229 229
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232 232
             foreach ( $roles as $role => $details ) {
233 233
                 $wp_roles->remove_cap( $role, $frm_role );
234
-                unset($role, $details);
234
+                unset( $role, $details );
235 235
     		}
236
-    		unset($frm_role, $frm_role_description);
236
+    		unset( $frm_role, $frm_role_description );
237 237
 		}
238
-		unset($roles, $frm_roles);
238
+		unset( $roles, $frm_roles );
239 239
 
240 240
 		// delete actions, views, and styles
241 241
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
259 259
 
260
-        do_action('frm_after_uninstall');
260
+        do_action( 'frm_after_uninstall' );
261 261
         return true;
262 262
     }
263 263
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				continue;
310 310
 			}
311 311
 
312
-			$widgets[ $k ]['size'] = $size;
312
+			$widgets[$k]['size'] = $size;
313 313
 		}
314 314
 		update_option( 'widget_frm_show_form', $widgets );
315 315
 	}
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 
391 391
         $updated = 0;
392 392
         foreach ( $fields as $f ) {
393
-            $f->field_options = maybe_unserialize($f->field_options);
394
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
393
+            $f->field_options = maybe_unserialize( $f->field_options );
394
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
395 395
                 continue;
396 396
             }
397 397
 
@@ -399,27 +399,27 @@  discard block
 block discarded – undo
399 399
             $f->field_options['size'] .= 'px';
400 400
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
401 401
             if ( $u ) {
402
-                $updated++;
402
+                $updated ++;
403 403
             }
404
-            unset($f);
404
+            unset( $f );
405 405
         }
406 406
 
407 407
         // Change the characters in widgets to pixels
408
-        $widgets = get_option('widget_frm_show_form');
409
-        if ( empty($widgets) ) {
408
+        $widgets = get_option( 'widget_frm_show_form' );
409
+        if ( empty( $widgets ) ) {
410 410
             return;
411 411
         }
412 412
 
413
-        $widgets = maybe_unserialize($widgets);
413
+        $widgets = maybe_unserialize( $widgets );
414 414
         foreach ( $widgets as $k => $widget ) {
415
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
415
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
416 416
                 continue;
417 417
             }
418 418
 			$size = round( $pixel_conversion * (int) $widget['size'] );
419 419
             $size .= 'px';
420
-			$widgets[ $k ]['size'] = $size;
420
+			$widgets[$k]['size'] = $size;
421 421
         }
422
-        update_option('widget_frm_show_form', $widgets);
422
+        update_option( 'widget_frm_show_form', $widgets );
423 423
     }
424 424
 
425 425
     /**
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 			}
467 467
 
468 468
             // Format form options
469
-            $form_options = maybe_unserialize($form->options);
469
+            $form_options = maybe_unserialize( $form->options );
470 470
 
471 471
             // Migrate settings to actions
472 472
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     private function migrate_to_11() {
477 477
         global $wpdb;
478 478
 
479
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
479
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
480 480
 
481 481
         $sending = __( 'Sending', 'formidable' );
482 482
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
488 488
 </div>
489 489
 DEFAULT_HTML;
490
-        unset($sending, $img);
490
+        unset( $sending, $img );
491 491
 
492
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
492
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
493 493
         $draft_link = FrmFormsHelper::get_draft_link();
494 494
 		foreach ( $forms as $form ) {
495
-            $form->options = maybe_unserialize($form->options);
496
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
495
+            $form->options = maybe_unserialize( $form->options );
496
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
497 497
                 continue;
498 498
             }
499 499
 
@@ -504,9 +504,9 @@  discard block
 block discarded – undo
504 504
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
505 505
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
506 506
             }
507
-            unset($form);
507
+            unset( $form );
508 508
         }
509
-        unset($forms);
509
+        unset( $forms );
510 510
     }
511 511
 
512 512
     private function migrate_to_6() {
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
 </div>
536 536
 DEFAULT_HTML;
537 537
 
538
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
538
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
539 539
         foreach ( $fields as $field ) {
540
-            $field->field_options = maybe_unserialize($field->field_options);
540
+            $field->field_options = maybe_unserialize( $field->field_options );
541 541
 			$html = FrmField::get_option( $field, 'custom_html' );
542 542
 			if ( $html == $default_html || $html == $old_default_html ) {
543 543
                 $field->field_options['custom_html'] = $new_default_html;
544 544
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
545 545
             }
546
-            unset($field);
546
+            unset( $field );
547 547
         }
548
-        unset($default_html, $old_default_html, $fields);
548
+        unset( $default_html, $old_default_html, $fields );
549 549
     }
550 550
 
551 551
 	/**
Please login to merge, or discard this patch.