Completed
Push — master ( 245232...0ef5c7 )
by Jamie
03:27
created
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmFormsListHelper extends FrmListHelper {
7
-    var $status = '';
7
+	var $status = '';
8 8
 
9 9
 	public function __construct( $args ) {
10 10
 		$this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function prepare_items() {
16
-	    global $wpdb, $per_page, $mode;
16
+		global $wpdb, $per_page, $mode;
17 17
 
18
-	    $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
18
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
19 19
 
20 20
 		$default_orderby = 'name';
21 21
 		$default_order = 'ASC';
22 22
 
23
-        $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
23
+		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
24 24
 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order;
25 25
 
26 26
 		$page = $this->get_pagenum();
@@ -28,40 +28,40 @@  discard block
 block discarded – undo
28 28
 
29 29
 		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
30 30
 
31
-        $s_query = array();
32
-        $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
31
+		$s_query = array();
32
+		$s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
33 33
 		switch ( $this->status ) {
34
-		    case 'template':
35
-                $s_query['is_template'] = 1;
36
-                $s_query['status !'] = 'trash';
37
-		        break;
38
-		    case 'draft':
39
-                $s_query['is_template'] = 0;
40
-                $s_query['status'] = 'draft';
41
-		        break;
42
-		    case 'trash':
43
-                $s_query['status'] = 'trash';
44
-		        break;
45
-		    default:
46
-                $s_query['is_template'] = 0;
47
-                $s_query['status !'] = 'trash';
48
-		        break;
34
+			case 'template':
35
+				$s_query['is_template'] = 1;
36
+				$s_query['status !'] = 'trash';
37
+				break;
38
+			case 'draft':
39
+				$s_query['is_template'] = 0;
40
+				$s_query['status'] = 'draft';
41
+				break;
42
+			case 'trash':
43
+				$s_query['status'] = 'trash';
44
+				break;
45
+			default:
46
+				$s_query['is_template'] = 0;
47
+				$s_query['status !'] = 'trash';
48
+				break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
-	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
55
-	        foreach ( (array) $search_terms as $term ) {
56
-                $s_query[] = array(
57
-                    'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
-                );
59
-	            unset($term);
60
-            }
61
-	    }
51
+		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
+		if ( $s != '' ) {
53
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
+			$search_terms = array_map('trim', $matches[0]);
55
+			foreach ( (array) $search_terms as $term ) {
56
+				$s_query[] = array(
57
+					'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
+				);
59
+				unset($term);
60
+			}
61
+		}
62 62
 
63 63
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
64
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
64
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -70,69 +70,69 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	public function no_items() {
73
-	    if ( 'template' == $this->status ) {
74
-            _e( 'No Templates Found.', 'formidable' ) ?>
73
+		if ( 'template' == $this->status ) {
74
+			_e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77 77
                 <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
81
-            _e( 'No Forms Found.', 'formidable' ) ?>
81
+			_e( 'No Forms Found.', 'formidable' ) ?>
82 82
             <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a>
83 83
 <?php   }
84 84
 	}
85 85
 
86 86
 	public function get_bulk_actions() {
87
-	    $actions = array();
87
+		$actions = array();
88 88
 
89 89
 		if ( in_array( $this->status, array( '', 'published' ) ) ) {
90
-	        $actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
-	    }
92
-
93
-	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
95
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
-	        }
97
-
98
-	        if ( current_user_can('frm_delete_forms') ) {
99
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
-	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
105
-	    }
106
-
107
-        return $actions;
108
-    }
90
+			$actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
+		}
92
+
93
+		if ( 'trash' == $this->status ) {
94
+			if ( current_user_can('frm_edit_forms') ) {
95
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
+			}
97
+
98
+			if ( current_user_can('frm_delete_forms') ) {
99
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
+			}
101
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
+		} else if ( current_user_can('frm_delete_forms') ) {
104
+			$actions['bulk_delete'] = __( 'Delete');
105
+		}
106
+
107
+		return $actions;
108
+	}
109 109
 
110 110
 	public function extra_tablenav( $which ) {
111
-        if ( 'top' != $which ) {
112
-            return;
113
-        }
111
+		if ( 'top' != $which ) {
112
+			return;
113
+		}
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
119 119
             </div>
120 120
 <?php
121
-            return;
122
-        }
121
+			return;
122
+		}
123 123
 
124
-        if ( 'template' != $this->status ) {
125
-            return;
126
-        }
124
+		if ( 'template' != $this->status ) {
125
+			return;
126
+		}
127 127
 
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
132
-        $args = array(
133
-            'frm_action'    => 'duplicate',
134
-            'template'      => true,
135
-        );
131
+		$base = admin_url('admin.php?page=formidable&form_type=template');
132
+		$args = array(
133
+			'frm_action'    => 'duplicate',
134
+			'template'      => true,
135
+		);
136 136
 
137 137
 ?>
138 138
     <div class="alignleft actions frm_visible_overflow">
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
         <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
141 141
 		<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
142 142
 		<?php
143
-        if ( empty( $forms ) ) { ?>
143
+		if ( empty( $forms ) ) { ?>
144 144
             <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li>
145 145
         <?php
146
-        } else {
147
-            foreach ( $forms as $form ) {
148
-		        $args['id'] = $form->id; ?>
146
+		} else {
147
+			foreach ( $forms as $form ) {
148
+				$args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+				unset($form);
152 152
 			}
153
-        }
154
-        ?>
153
+		}
154
+		?>
155 155
 		</ul>
156 156
 	</div>
157 157
 	</div>
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 	public function get_views() {
162 162
 
163 163
 		$statuses = array(
164
-		    'published' => __( 'My Forms', 'formidable' ),
165
-		    'template'  => __( 'Templates', 'formidable' ),
166
-		    'draft'     => __( 'Drafts', 'formidable' ),
167
-		    'trash'     => __( 'Trash', 'formidable' ),
164
+			'published' => __( 'My Forms', 'formidable' ),
165
+			'template'  => __( 'Templates', 'formidable' ),
166
+			'draft'     => __( 'Drafts', 'formidable' ),
167
+			'trash'     => __( 'Trash', 'formidable' ),
168 168
 		);
169 169
 
170
-	    $links = array();
171
-	    $counts = FrmForm::get_count();
172
-        $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
170
+		$links = array();
171
+		$counts = FrmForm::get_count();
172
+		$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
173 173
 
174
-	    foreach ( $statuses as $status => $name ) {
174
+		foreach ( $statuses as $status => $name ) {
175 175
 
176
-	        if ( $status == $form_type ) {
177
-    			$class = ' class="current"';
178
-    		} else {
179
-    		    $class = '';
180
-    		}
176
+			if ( $status == $form_type ) {
177
+				$class = ' class="current"';
178
+			} else {
179
+				$class = '';
180
+			}
181 181
 
182
-    		if ( $counts->{$status} || 'published' == $status ) {
182
+			if ( $counts->{$status} || 'published' == $status ) {
183 183
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184
-		    }
184
+			}
185 185
 
186
-		    unset($status, $name);
187
-	    }
186
+			unset($status, $name);
187
+		}
188 188
 
189 189
 		return $links;
190 190
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public function single_row( $item, $style = '' ) {
203
-	    global $frm_vars, $mode;
203
+		global $frm_vars, $mode;
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+		$this->get_actions($actions, $item, $edit_link, $duplicate_link);
211 211
 
212
-        $action_links = $this->row_actions( $actions );
212
+		$action_links = $this->row_actions( $actions );
213 213
 
214 214
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
215 215
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 		list( $columns, $hidden ) = $this->get_column_info();
220 220
 
221
-        $format = 'Y/m/d';
222
-        if ( 'list' != $mode ) {
223
-            $format .= ' \<\b\r \/\> g:i:s a';
221
+		$format = 'Y/m/d';
222
+		if ( 'list' != $mode ) {
223
+			$format .= ' \<\b\r \/\> g:i:s a';
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
231
-                $class .= ' frm_hidden';
231
+				$class .= ' frm_hidden';
232 232
 			}
233 233
 
234 234
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
244
-				    $val = $item->{$column_name};
245
-				    break;
244
+					$val = $item->{$column_name};
245
+					break;
246 246
 				case 'name':
247
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
-			        $val .= $action_links;
247
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
+					$val .= $action_links;
249 249
 
250
-				    break;
250
+					break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+					$date = date($format, strtotime($item->created_at));
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
256 256
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
257
-				    if ( 'excerpt' == $mode ) {
257
+					if ( 'excerpt' == $mode ) {
258 258
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
259
-				    }
260
-			        break;
261
-			    case 'entries':
259
+					}
260
+					break;
261
+				case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263 263
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
264
-			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
264
+					} else {
265
+						$text = FrmEntry::getRecordCount($item->id);
266 266
 						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
268
-                    }
269
-			        break;
270
-                case 'type':
271
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
-                    break;
267
+						unset($text);
268
+					}
269
+					break;
270
+				case 'type':
271
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
+					break;
273 273
 			}
274 274
 
275 275
 			if ( isset($val) ) {
276
-			    $r .= "<td $attributes>";
277
-			    $r .= $val;
278
-			    $r .= '</td>';
276
+				$r .= "<td $attributes>";
277
+				$r .= $val;
278
+				$r .= '</td>';
279 279
 			}
280 280
 			unset($val);
281 281
 		}
@@ -284,38 +284,38 @@  discard block
 block discarded – undo
284 284
 		return $r;
285 285
 	}
286 286
 
287
-    /**
288
-     * @param string $edit_link
289
-     * @param string $duplicate_link
290
-     */
291
-    private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287
+	/**
288
+	 * @param string $edit_link
289
+	 * @param string $duplicate_link
290
+	 */
291
+	private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293 293
 			if ( current_user_can('frm_edit_forms') ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+			if ( current_user_can('frm_delete_forms') ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) .'" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300
-    		}
301
-            return;
300
+			}
301
+			return;
302 302
 		}
303 303
 
304 304
 		if ( current_user_can('frm_edit_forms') ) {
305
-            if ( ! $item->is_template || ! $item->default_template ) {
305
+			if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307
-            }
307
+			}
308 308
 
309
-		    if ( $item->is_template ) {
309
+			if ( $item->is_template ) {
310 310
 				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
311
-            } else {
311
+			} else {
312 312
 				$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
313 313
 
314
-    		    if ( FrmAppHelper::pro_is_installed() ) {
314
+				if ( FrmAppHelper::pro_is_installed() ) {
315 315
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
316
-        	    }
317
-        	}
318
-        }
316
+				}
317
+			}
318
+		}
319 319
 
320 320
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
321 321
 		if ( empty( $actions['trash'] ) ) {
@@ -324,52 +324,52 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 
326 326
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
327
-    }
327
+	}
328 328
 
329
-    /**
330
-     * @param string $edit_link
331
-     */
329
+	/**
330
+	 * @param string $edit_link
331
+	 */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333
-        $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
336
-        }
333
+		$form_name = $item->name;
334
+		if ( trim($form_name) == '' ) {
335
+			$form_name = __( '(no title)');
336
+		}
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
339 339
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
340 340
 		}
341 341
 
342
-        $val = '<strong>';
343
-        if ( 'trash' == $this->status ) {
344
-            $val .= $form_name;
345
-        } else {
342
+		$val = '<strong>';
343
+		if ( 'trash' == $this->status ) {
344
+			$val .= $form_name;
345
+		} else {
346 346
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
347
-        }
347
+		}
348 348
 
349
-        $this->add_draft_label( $item, $val );
350
-        $val .= '</strong>';
349
+		$this->add_draft_label( $item, $val );
350
+		$val .= '</strong>';
351 351
 
352
-        $this->add_form_description( $item, $val );
352
+		$this->add_form_description( $item, $val );
353 353
 
354
-        return $val;
355
-    }
354
+		return $val;
355
+	}
356 356
 
357
-    /**
358
-     * @param string $val
359
-     */
360
-    private function add_draft_label( $item, &$val ) {
361
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
357
+	/**
358
+	 * @param string $val
359
+	 */
360
+	private function add_draft_label( $item, &$val ) {
361
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
362 362
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
363
-        }
364
-    }
365
-
366
-    /**
367
-     * @param string $val
368
-     */
369
-    private function add_form_description( $item, &$val ) {
370
-        global $mode;
371
-        if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
-        }
374
-    }
363
+		}
364
+	}
365
+
366
+	/**
367
+	 * @param string $val
368
+	 */
369
+	private function add_form_description( $item, &$val ) {
370
+		global $mode;
371
+		if ( 'excerpt' == $mode ) {
372
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
+		}
374
+	}
375 375
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$page = $this->get_pagenum();
27 27
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
28 28
 
29
-		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
29
+		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page );
30 30
 
31 31
         $s_query = array();
32 32
         $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 		        break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
51
+        $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
52 52
 	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
53
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
54
+		    $search_terms = array_map( 'trim', $matches[0] );
55 55
 	        foreach ( (array) $search_terms as $term ) {
56 56
                 $s_query[] = array(
57 57
                     'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58 58
                 );
59
-	            unset($term);
59
+	            unset( $term );
60 60
             }
61 61
 	    }
62 62
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             _e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77
-                <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
77
+                <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	    }
92 92
 
93 93
 	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
94
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
95 95
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96 96
 	        }
97 97
 
98
-	        if ( current_user_can('frm_delete_forms') ) {
98
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
99 99
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100 100
 	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
101
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
102 102
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
103
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
104
+	        $actions['bulk_delete'] = __( 'Delete' );
105 105
 	    }
106 106
 
107 107
         return $actions;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return;
113 113
         }
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
131
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
132 132
         $args = array(
133 133
             'frm_action'    => 'duplicate',
134 134
             'template'      => true,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		        $args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+			    unset( $form );
152 152
 			}
153 153
         }
154 154
         ?>
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
     		}
181 181
 
182 182
     		if ( $counts->{$status} || 'published' == $status ) {
183
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
183
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184 184
 		    }
185 185
 
186
-		    unset($status, $name);
186
+		    unset( $status, $name );
187 187
 	    }
188 188
 
189 189
 		return $links;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+        $this->get_actions( $actions, $item, $edit_link, $duplicate_link );
211 211
 
212 212
         $action_links = $this->row_actions( $actions );
213 213
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				    break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+				    $date = date( $format, strtotime( $item->created_at ) );
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			        break;
261 261
 			    case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
263
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>';
264 264
 			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
266
-						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
265
+			            $text = FrmEntry::getRecordCount( $item->id );
266
+						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
+                        unset( $text );
268 268
                     }
269 269
 			        break;
270 270
                 case 'type':
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                     break;
273 273
 			}
274 274
 
275
-			if ( isset($val) ) {
275
+			if ( isset( $val ) ) {
276 276
 			    $r .= "<td $attributes>";
277 277
 			    $r .= $val;
278 278
 			    $r .= '</td>';
279 279
 			}
280
-			unset($val);
280
+			unset( $val );
281 281
 		}
282 282
 		$r .= '</tr>';
283 283
 
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
      */
291 291
     private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293
-			if ( current_user_can('frm_edit_forms') ) {
293
+			if ( current_user_can( 'frm_edit_forms' ) ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300 300
     		}
301 301
             return;
302 302
 		}
303 303
 
304
-		if ( current_user_can('frm_edit_forms') ) {
304
+		if ( current_user_can( 'frm_edit_forms' ) ) {
305 305
             if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307 307
             }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			unset( $actions['trash'] );
324 324
 		}
325 325
 
326
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
326
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
327 327
     }
328 328
 
329 329
     /**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
      */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333 333
         $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
334
+        if ( trim( $form_name ) == '' ) {
335
+            $form_name = __( '(no title)' );
336 336
         }
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     private function add_form_description( $item, &$val ) {
370 370
         global $mode;
371 371
         if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
373 373
         }
374 374
     }
375 375
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68 68
 
69 69
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name . ' column-' . $column_name;
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+		if ( current_user_can('frm_delete_entries') ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
130
+			unset( $class );
131 131
 			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133 133
 			$col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
52
+			}
53
+		}
54 54
 
55
-        return $css_file;
56
-    }
55
+		return $css_file;
56
+	}
57 57
 
58
-    public static function enqueue_jquery_css() {
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+		$hex = str_replace('#', '', $hex);
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+		if ( strlen($hex) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199
-        } else {
199
+		} else {
200 200
 			$r = hexdec( substr( $hex, 0, 2 ) );
201 201
 			$g = hexdec( substr( $hex, 2, 2 ) );
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203
-        }
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162 162
 				<?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+        if ( strlen( $hex ) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
css/_single_theme.css.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@  discard block
 block discarded – undo
3 3
 if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6
-    } else {
7
-        extract($_GET);
8
-    }
6
+	} else {
7
+		extract($_GET);
8
+	}
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+	$important_style = isset($important_style) ? $important_style : 0;
11
+	$auto_width = isset($auto_width) ? $auto_width : 0;
12
+	$submit_style = isset($submit_style) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
16 16
 		$style_class = $style_name . '.with_frm_style';
17
-    } else {
18
-        $style_class = 'with_frm_style';
19
-    }
17
+	} else {
18
+		$style_class = 'with_frm_style';
19
+	}
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+	extract($style->post_content);
23 23
 }
24 24
 
25 25
 $important = empty($important_style) ? '' : ' !important';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 if ( ! isset($collapse_icon) ) {
43
-    $collapse_icon = 0;
43
+	$collapse_icon = 0;
44 44
 }
45 45
 
46 46
 if ( ! isset( $center_form ) ) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339 339
 <?php if ( ! empty($important) ) {
340
-    echo esc_html( 'background-image:none' . $important . ';' );
340
+	echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
343 343
     border-color:#<?php echo esc_html( $border_color . $important ) ?>;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     color:#<?php echo esc_html( $submit_active_color . $important ) ?>;
549 549
 }
550 550
 <?php
551
-    }
551
+	}
552 552
 }
553 553
 ?>
554 554
 
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854
-    // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
854
+	// calculate the top position based on field padding
855
+	$top_pad = explode(' ', $field_pad);
856
+	$top_pad = reset($top_pad); // the top padding is listed first
857
+	$pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
+	$top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
3
+if ( isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] ) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6 6
     } else {
7
-        extract($_GET);
7
+        extract( $_GET );
8 8
     }
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+    $important_style = isset( $important_style ) ? $important_style : 0;
11
+    $auto_width = isset( $auto_width ) ? $auto_width : 0;
12
+    $submit_style = isset( $submit_style ) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     }
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+    extract( $style->post_content );
23 23
 }
24 24
 
25
-$important = empty($important_style) ? '' : ' !important';
25
+$important = empty( $important_style ) ? '' : ' !important';
26 26
 $label_margin = (int) $width + 10;
27 27
 
28 28
 $minus_icons = FrmStylesHelper::minus_icons();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	$change_margin = 650 . 'px';
40 40
 }
41 41
 
42
-if ( ! isset($collapse_icon) ) {
42
+if ( ! isset( $collapse_icon ) ) {
43 43
     $collapse_icon = 0;
44 44
 }
45 45
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 }
149 149
 
150 150
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{
151
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>";
151
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>";
152 152
 }
153 153
 
154 154
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{
155
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>";
155
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>";
156 156
 }
157 157
 
158 158
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before,
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 }
162 162
 
163 163
 .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
164
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>";
164
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>";
165 165
 }
166 166
 
167 167
 .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
168
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>";
168
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>";
169 169
 }
170 170
 
171 171
 .<?php echo esc_html( $style_class ) ?> .form-field{
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 .<?php echo esc_html( $style_class ) ?> .frm_error{
188 188
     margin:0;
189 189
     padding:0;
190
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
190
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
191 191
     font-size:<?php echo esc_html( $description_font_size . $important ) ?>;
192 192
     color:#<?php echo esc_html( $description_color . $important ) ?>;
193 193
     font-weight:<?php echo esc_html( $description_weight . $important ) ?>;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 .<?php echo esc_html( $style_class ) ?> .frm_scale label{
295 295
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
296
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
296
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
297 297
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
298 298
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
299 299
 }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 .<?php echo esc_html( $style_class ) ?> select,
314 314
 .<?php echo esc_html( $style_class ) ?> textarea,
315 315
 .<?php echo esc_html( $style_class ) ?> .chosen-container{
316
-	font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
316
+	font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
317 317
     font-size:<?php echo esc_html( $field_font_size ) ?>;
318 318
     margin-bottom:0<?php echo esc_html( $important ) ?>;
319 319
 }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339
-<?php if ( ! empty($important) ) {
339
+<?php if ( ! empty( $important ) ) {
340 340
     echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     line-height:normal<?php echo esc_html( $important ) ?>;
495 495
     text-align:center;
496 496
     background:#<?php echo esc_html( $submit_bg_color );
497
-	if ( ! empty($submit_bg_img) ) {
497
+	if ( ! empty( $submit_bg_img ) ) {
498 498
 		echo esc_html( ' url(' . $submit_bg_img . ')' );
499 499
 	}
500 500
 	echo esc_html( $important ); ?>;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
 .<?php echo esc_html( $style_class ) ?> .frm_radio label,
594 594
 .<?php echo esc_html( $style_class ) ?> .frm_checkbox label{
595
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
595
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
596 596
     font-size:<?php echo esc_html( $check_font_size . $important ) ?>;
597 597
     color:#<?php echo esc_html( $check_label_color . $important ) ?>;
598 598
     font-weight:<?php echo esc_html( $check_weight . $important ) ?>;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     -webkit-border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
734 734
     border-radius:<?php echo esc_html( $border_radius . $important ) ?>;
735 735
     font-size:<?php echo esc_html( $submit_font_size . $important ) ?>;
736
-    font-family:<?php echo FrmAppHelper::kses( stripslashes($font) . $important ) ?>;
736
+    font-family:<?php echo FrmAppHelper::kses( stripslashes( $font ) . $important ) ?>;
737 737
     font-weight:<?php echo esc_html( $submit_weight . $important ) ?>;
738 738
     color:#<?php echo esc_html( $submit_text_color . $important ) ?>;
739 739
     background:#<?php echo esc_html( $submit_bg_color . $important ) ?>;
@@ -852,10 +852,10 @@  discard block
 block discarded – undo
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854 854
     // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
855
+    $top_pad = explode( ' ', $field_pad );
856
+    $top_pad = reset( $top_pad ); // the top padding is listed first
857
+    $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem...
858
+    $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
css/custom_theme.css.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! isset($saving) ) {
3
-    header( 'Content-type: text/css' );
3
+	header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
6
-        echo $css;
7
-        die();
8
-    }
5
+	if ( isset($css) && $css ) {
6
+		echo $css;
7
+		die();
8
+	}
9 9
 }
10 10
 
11 11
 if ( ! isset($frm_style) ) {
12
-    $frm_style = new FrmStyle();
12
+	$frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+	unset($style);
191 191
 }
192 192
 ?>
193 193
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! isset($saving) ) {
2
+if ( ! isset( $saving ) ) {
3 3
     header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
5
+    if ( isset( $css ) && $css ) {
6 6
         echo $css;
7 7
         die();
8 8
     }
9 9
 }
10 10
 
11
-if ( ! isset($frm_style) ) {
11
+if ( ! isset( $frm_style ) ) {
12 12
     $frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
16
-$default_style = $frm_style->get_default_style($styles);
16
+$default_style = $frm_style->get_default_style( $styles );
17 17
 $defaults = $default_style->post_content;
18 18
 ?>
19 19
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+    unset( $style );
191 191
 }
192 192
 ?>
193 193
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     overflow:hidden!important;
620 620
 }
621 621
 
622
-<?php include( dirname(__FILE__) . '/frm_grids.css' ); ?>
622
+<?php include( dirname( __FILE__ ) . '/frm_grids.css' ); ?>
623 623
 
624 624
 /* Left and right label styling for non-Formidable styling - very basic, not responsive */
625 625
 .frm_form_field.frm_left_container label.frm_primary_label{
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
     -moz-border-radius:<?php echo $defaults['border_radius'] ?>;
976 976
     -webkit-border-radius:<?php echo $defaults['border_radius'] ?>;
977 977
     border-radius:<?php echo $defaults['border_radius'] ?>;
978
-    width:<?php echo ($defaults['field_width'] == '' ? 'auto' : $defaults['field_width']) ?>;
978
+    width:<?php echo ( $defaults['field_width'] == '' ? 'auto' : $defaults['field_width'] ) ?>;
979 979
     max-width:100%;
980 980
     font-size:<?php echo $defaults['field_font_size'] ?>;
981 981
     padding:<?php echo $defaults['field_pad'] ?>;
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62
-    $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
62
+	$read_only = false;
63
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			?>
94 94
 		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
95 95
     <?php
96
-    	} ?>
96
+		} ?>
97 97
 </select>
98 98
 <?php
99 99
 		FrmFieldsHelper::include_other_input( array(
@@ -102,52 +102,52 @@  discard block
 block discarded – undo
102 102
 			'value' => $other_args['value'], 'field' => $field,
103 103
 			'html_id' => $html_id, 'opt_key' => false,
104 104
 		) );
105
-    }
105
+	}
106 106
 } else if ( $field['type'] == 'checkbox' ) {
107
-    $checked_values = $field['value'];
108
-    $read_only = false;
107
+	$checked_values = $field['value'];
108
+	$read_only = false;
109 109
 
110 110
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
111
-        $read_only = true;
112
-        if ( $checked_values ) {
113
-            foreach ( (array) $checked_values as $checked_value ) { ?>
111
+		$read_only = true;
112
+		if ( $checked_values ) {
113
+			foreach ( (array) $checked_values as $checked_value ) { ?>
114 114
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
115 115
 <?php
116
-            }
117
-        } else { ?>
116
+			}
117
+		} else { ?>
118 118
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125
-    } else if ( $field['options'] ) {
126
-        foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
-                continue;
129
-            }
130
-
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
-
135
-            // Check if other opt, and get values for other field if needed
136
-            $other_opt = false;
125
+	} else if ( $field['options'] ) {
126
+		foreach ( $field['options'] as $opt_key => $opt ) {
127
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
128
+				continue;
129
+			}
130
+
131
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
134
+
135
+			// Check if other opt, and get values for other field if needed
136
+			$other_opt = false;
137 137
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
138 138
 
139
-            ?>
139
+			?>
140 140
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
141 141
 
142
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
-            }
142
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
143
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144
+			}
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
147 147
 
148
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
148
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
150
-            }
150
+			}
151 151
 
152 152
 			FrmFieldsHelper::include_other_input( array(
153 153
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 				'html_id' => $html_id, 'opt_key' => $opt_key,
157 157
 			) );
158 158
 
159
-            unset( $other_opt, $other_args, $checked );
159
+			unset( $other_opt, $other_args, $checked );
160 160
 
161
-            ?></div>
161
+			?></div>
162 162
 <?php
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166
-    $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
169
-    }
166
+	$frm_settings = FrmAppHelper::get_settings();
167
+	if ( ! empty($frm_settings->pubkey) ) {
168
+		FrmFieldsHelper::display_recaptcha($field);
169
+	}
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
172 172
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     }
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
     $read_only = false;
63
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
63
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
64 64
 		echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
65 65
 	} else {
66 66
 		if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 					<input type="hidden" value="<?php echo esc_attr( $selected_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> <?php
72 72
 				}
73 73
 			} else { ?>
74
-				<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
74
+				<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" /> <?php
75 75
 			} ?>
76
-				<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>> <?php
76
+				<select disabled="disabled" <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
77 77
 
78 78
 		} else { ?>
79
-<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
79
+<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
80 80
 <?php   }
81 81
 
82 82
 		$other_opt = $other_checked = false;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 			}
93 93
 			?>
94
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo ($opt == '') ? ' ' : $opt; ?></option>
94
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo ( $opt == '' ) ? ' ' : $opt; ?></option>
95 95
     <?php
96 96
     	} ?>
97 97
 </select>
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
         }
121 121
     }
122 122
 
123
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
123
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
124 124
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
125 125
     } else if ( $field['options'] ) {
126 126
         foreach ( $field['options'] as $opt_key => $opt ) {
127
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
127
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
128 128
                 continue;
129 129
             }
130 130
 
131
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
132
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
133
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
131
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
132
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
133
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
134 134
 
135 135
             // Check if other opt, and get values for other field if needed
136 136
             $other_opt = false;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
144 144
             }
145 145
 
146
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
146
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
147 147
 
148 148
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
149 149
 				echo ' ' . $opt . '</label>';
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
     }
165 165
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
166 166
     $frm_settings = FrmAppHelper::get_settings();
167
-    if ( ! empty($frm_settings->pubkey) ) {
168
-        FrmFieldsHelper::display_recaptcha($field);
167
+    if ( ! empty( $frm_settings->pubkey ) ) {
168
+        FrmFieldsHelper::display_recaptcha( $field );
169 169
     }
170 170
 } else {
171 171
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$field = self::include_new_field( $field_type, $form_id, $section_id );
64 64
 
65 65
         // this hook will allow for multiple fields to be added at once
66
-        do_action('frm_after_field_created', $field, $form_id);
66
+        do_action( 'frm_after_field_created', $field, $form_id );
67 67
 
68 68
         wp_die();
69 69
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public static function include_new_field( $field_type, $form_id, $section_id = 0 ) {
80 80
         $values = array();
81 81
         if ( FrmAppHelper::pro_is_installed() ) {
82
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
82
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
83 83
         }
84 84
 
85 85
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
             return false;
93 93
         }
94 94
 
95
-        $field = self::include_single_field($field_id, $values, $form_id);
95
+        $field = self::include_single_field( $field_id, $values, $form_id );
96 96
 
97 97
         return $field;
98 98
     }
99 99
 
100 100
 	public static function edit_name( $field = 'name', $id = '' ) {
101
-		FrmAppHelper::permission_check('frm_edit_forms');
101
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
102 102
         check_ajax_referer( 'frm_ajax', 'nonce' );
103 103
 
104
-        if ( empty($field) ) {
104
+        if ( empty( $field ) ) {
105 105
             $field = 'name';
106 106
         }
107 107
 
108
-        if ( empty($id) ) {
108
+        if ( empty( $id ) ) {
109 109
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
110 110
 			$id = str_replace( 'field_label_', '', $id );
111 111
         }
112 112
 
113 113
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
114 114
 		$value = trim( $value );
115
-        if ( trim(strip_tags($value)) == '' ) {
115
+        if ( trim( strip_tags( $value ) ) == '' ) {
116 116
             // set blank value if there is no content
117 117
             $value = '';
118 118
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public static function update_ajax_option() {
129
-		FrmAppHelper::permission_check('frm_edit_forms');
129
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
130 130
         check_ajax_referer( 'frm_ajax', 'nonce' );
131 131
 
132 132
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		if ( isset( $_POST['separate_value'] ) ) {
140 140
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
141 141
 			$field->field_options['separate_value'] = $new_val;
142
-			unset($new_val);
142
+			unset( $new_val );
143 143
 		}
144 144
 
145 145
         FrmField::update( $field_id, array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function duplicate() {
153
-		FrmAppHelper::permission_check('frm_edit_forms');
153
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
154 154
         check_ajax_referer( 'frm_ajax', 'nonce' );
155 155
 
156 156
         global $wpdb;
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
         $values['field_order'] = $field_count + 1;
175 175
 
176
-        if ( ! $field_id = FrmField::create($values) ) {
176
+        if ( ! $field_id = FrmField::create( $values ) ) {
177 177
             wp_die();
178 178
         }
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+        self::include_single_field( $field_id, $values );
181 181
 
182 182
         wp_die();
183 183
     }
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * Load a single field in the form builder along with all needed variables
187 187
      */
188 188
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
+        $html_id = FrmFieldsHelper::get_html_id( $field );
192 192
         $id = $form_id ? $form_id : $field['form_id'];
193 193
         if ( $field['type'] == 'html' ) {
194 194
             $field['stop_filter'] = true;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     public static function destroy() {
203
-		FrmAppHelper::permission_check('frm_edit_forms');
203
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
204 204
         check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
     //Add Single Option or Other Option
214 214
     public static function add_option() {
215
-		FrmAppHelper::permission_check('frm_edit_forms');
215
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
216 216
         check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 
221 221
         //Get the field
222
-        $field = FrmField::getOne($id);
222
+        $field = FrmField::getOne( $id );
223 223
 
224 224
 		if ( ! empty( $field->options ) ) {
225 225
 			$keys = array_keys( $field->options );
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 			$first_opt = reset( $field->options );
243 243
 			$next_opt = count( $field->options );
244 244
             if ( $first_opt != '' ) {
245
-                $next_opt++;
245
+                $next_opt ++;
246 246
             }
247 247
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
248
-            unset($next_opt);
248
+            unset( $next_opt );
249 249
         }
250 250
         $field_val = $opt;
251
-		$field->options[ $opt_key ] = $opt;
251
+		$field->options[$opt_key] = $opt;
252 252
 
253 253
         //Update options in DB
254 254
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -257,13 +257,13 @@  discard block
 block discarded – undo
257 257
         $field = array(
258 258
             'type'  => $field_data->type,
259 259
             'id'    => $id,
260
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
261 261
             'form_id' => $field_data->form_id,
262 262
             'field_key' => $field_data->field_key,
263 263
         );
264 264
 
265 265
 		$field_name = 'item_meta[' . $id . ']';
266
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
+        $html_id = FrmFieldsHelper::get_html_id( $field );
267 267
         $checked = '';
268 268
 
269 269
         if ( 'other' == $opt_type ) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     }
276 276
 
277 277
     public static function edit_option() {
278
-		FrmAppHelper::permission_check('frm_edit_forms');
278
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
279 279
         check_ajax_referer( 'frm_ajax', 'nonce' );
280 280
 
281 281
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
             $new_label = $update_value;
290 290
         }
291 291
 
292
-        $field = FrmField::getOne($id);
292
+        $field = FrmField::getOne( $id );
293 293
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
294 294
 
295
-        $this_opt_id = end($ids);
296
-		$this_opt = (array) $field->options[ $this_opt_id ];
297
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
295
+        $this_opt_id = end( $ids );
296
+		$this_opt = (array) $field->options[$this_opt_id];
297
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
298 298
 
299
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
300
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
299
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
300
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
301 301
 
302 302
         if ( ! isset( $new_label ) ) {
303 303
             $new_label = $label;
304 304
         }
305 305
 
306
-        if ( isset($new_value) || isset($value) ) {
307
-            $update_value = isset($new_value) ? $new_value : $value;
306
+        if ( isset( $new_value ) || isset( $value ) ) {
307
+            $update_value = isset( $new_value ) ? $new_value : $value;
308 308
         }
309 309
 
310 310
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
311
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
312 312
         } else {
313
-			$field->options[ $this_opt_id ] = $orig_update_value;
313
+			$field->options[$this_opt_id] = $orig_update_value;
314 314
         }
315 315
 
316 316
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     }
320 320
 
321 321
     public static function delete_option() {
322
-		FrmAppHelper::permission_check('frm_edit_forms');
322
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
323 323
         check_ajax_referer( 'frm_ajax', 'nonce' );
324 324
 
325 325
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
329 329
 
330 330
 		$options = $field->options;
331
-        unset( $options[ $opt_key ] );
331
+        unset( $options[$opt_key] );
332 332
         $response = array( 'other' => true );
333 333
 
334 334
         //If the deleted option is an "other" option
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 
395 395
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
396 396
         $prepop = array();
397
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
398 398
 
399
-        $field = FrmField::getOne($field_id);
399
+        $field = FrmField::getOne( $field_id );
400 400
 
401 401
         wp_enqueue_script( 'utils' );
402 402
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -407,33 +407,33 @@  discard block
 block discarded – undo
407 407
     }
408 408
 
409 409
     public static function import_options() {
410
-		FrmAppHelper::permission_check('frm_edit_forms');
410
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
411 411
         check_ajax_referer( 'frm_ajax', 'nonce' );
412 412
 
413
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
414 414
             return;
415 415
         }
416 416
 
417 417
 		$field_id = absint( $_POST['field_id'] );
418
-        $field = FrmField::getOne($field_id);
418
+        $field = FrmField::getOne( $field_id );
419 419
 
420 420
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
421 421
             return;
422 422
         }
423 423
 
424
-        $field = FrmFieldsHelper::setup_edit_vars($field);
425
-        $opts = stripslashes_deep($_POST['opts']);
426
-        $opts = explode("\n", rtrim($opts, "\n"));
424
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
425
+        $opts = stripslashes_deep( $_POST['opts'] );
426
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
427 427
         if ( $field['separate_value'] ) {
428 428
             foreach ( $opts as $opt_key => $opt ) {
429
-                if ( strpos($opt, '|') !== false ) {
430
-                    $vals = explode('|', $opt);
429
+                if ( strpos( $opt, '|' ) !== false ) {
430
+                    $vals = explode( '|', $opt );
431 431
                     if ( $vals[0] != $vals[1] ) {
432
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
432
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433 433
                     }
434
-                    unset($vals);
434
+                    unset( $vals );
435 435
                 }
436
-                unset($opt_key, $opt);
436
+                unset( $opt_key, $opt );
437 437
             }
438 438
         }
439 439
 
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             $other_array = array();
443 443
             foreach ( $field['options'] as $opt_key => $opt ) {
444 444
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
445
-                    $other_array[ $opt_key ] = $opt;
445
+                    $other_array[$opt_key] = $opt;
446 446
                 }
447
-                unset($opt_key, $opt);
447
+                unset( $opt_key, $opt );
448 448
             }
449
-            if ( ! empty($other_array) ) {
450
-                $opts = array_merge( $opts, $other_array);
449
+            if ( ! empty( $other_array ) ) {
450
+                $opts = array_merge( $opts, $other_array );
451 451
             }
452 452
         }
453 453
 
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
463 463
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
464 464
         } else {
465
-            FrmFieldsHelper::show_single_option($field);
465
+            FrmFieldsHelper::show_single_option( $field );
466 466
         }
467 467
 
468 468
         wp_die();
469 469
     }
470 470
 
471 471
     public static function update_order() {
472
-		FrmAppHelper::permission_check('frm_edit_forms');
472
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
473 473
         check_ajax_referer( 'frm_ajax', 'nonce' );
474 474
 
475 475
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
             'rte'       => 'textarea',
487 487
             'website'   => 'url',
488 488
         );
489
-        if ( isset( $type_switch[ $type ] ) ) {
490
-            $type = $type_switch[ $type ];
489
+        if ( isset( $type_switch[$type] ) ) {
490
+            $type = $type_switch[$type];
491 491
         }
492 492
 
493 493
 		$frm_field_selection = FrmField::field_selection();
494
-        $types = array_keys($frm_field_selection);
495
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
494
+        $types = array_keys( $frm_field_selection );
495
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
496 496
             $type = 'text';
497 497
         }
498 498
 
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 
532 532
     public static function input_html( $field, $echo = true ) {
533 533
         $class = array(); //$field['type'];
534
-        self::add_input_classes($field, $class);
534
+        self::add_input_classes( $field, $class );
535 535
 
536 536
         $add_html = array();
537
-        self::add_html_size($field, $add_html);
538
-        self::add_html_length($field, $add_html);
539
-        self::add_html_placeholder($field, $add_html, $class);
537
+        self::add_html_size( $field, $add_html );
538
+        self::add_html_length( $field, $add_html );
539
+        self::add_html_placeholder( $field, $add_html, $class );
540 540
 		self::add_validation_messages( $field, $add_html );
541 541
 
542
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
542
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
543 543
 
544 544
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
545 545
 
546
-        self::add_shortcodes_to_html($field, $add_html);
546
+        self::add_shortcodes_to_html( $field, $add_html );
547 547
 
548 548
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
549 549
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     }
557 557
 
558 558
 	private static function add_input_classes( $field, array &$class ) {
559
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
559
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
560 560
             $class[] = $field['input_class'];
561 561
         }
562 562
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             $class[] = 'dyn_default_value';
570 570
         }
571 571
 
572
-        if ( isset($field['size']) && $field['size'] > 0 ) {
572
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
573 573
             $class[] = 'auto_width';
574 574
         }
575 575
     }
@@ -579,19 +579,19 @@  discard block
 block discarded – undo
579 579
             return;
580 580
         }
581 581
 
582
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
582
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
583 583
             return;
584 584
         }
585 585
 
586
-        if ( is_numeric($field['size']) ) {
586
+        if ( is_numeric( $field['size'] ) ) {
587 587
             $field['size'] .= 'px';
588 588
         }
589 589
 
590
-        $important = apply_filters('frm_use_important_width', 1, $field);
590
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
591 591
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
592 592
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
593 593
 
594
-        self::add_html_cols($field, $add_html);
594
+        self::add_html_cols( $field, $add_html );
595 595
     }
596 596
 
597 597
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
         );
609 609
 
610 610
         // include "col" for valid html
611
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
611
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
612 612
 
613
-        if ( ! isset( $calc[ $unit ] ) ) {
613
+        if ( ! isset( $calc[$unit] ) ) {
614 614
             return;
615 615
         }
616 616
 
617
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
617
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
618 618
 
619 619
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
620 620
     }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             return;
626 626
         }
627 627
 
628
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
628
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
629 629
             // don't load on form builder page
630 630
             return;
631 631
         }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
658 658
             // use HMTL5 placeholder with js fallback
659 659
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
660
-            wp_enqueue_script('jquery-placeholder');
660
+            wp_enqueue_script( 'jquery-placeholder' );
661 661
         } else if ( ! $frm_settings->use_html ) {
662 662
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
663 663
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$format = FrmEntryValidate::phone_format( $field );
685 685
 			$format = substr( $format, 2, -2 );
686 686
 			$key = 'pattern';
687
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
687
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
688 688
 		}
689 689
 	}
690 690
 
@@ -698,15 +698,15 @@  discard block
 block discarded – undo
698 698
                 continue;
699 699
             }
700 700
 
701
-            if ( is_numeric($k) && strpos($v, '=') ) {
701
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
702 702
                 $add_html[] = $v;
703
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
704
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
703
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
704
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
705 705
             } else {
706
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
706
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
707 707
             }
708 708
 
709
-            unset($k, $v);
709
+            unset( $k, $v );
710 710
         }
711 711
     }
712 712
 
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
     }
723 723
 
724 724
 	public static function check_label( $opt ) {
725
-        if ( is_array($opt) ) {
726
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
725
+        if ( is_array( $opt ) ) {
726
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
727 727
         }
728 728
 
729 729
         return $opt;
Please login to merge, or discard this patch.
Indentation   +434 added lines, -434 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,141 +139,141 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166
-        $values = array( 'id' => $form_id );
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
166
+		$values = array( 'id' => $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-        if ( ! $field_id = FrmField::create($values) ) {
174
-            wp_die();
175
-        }
173
+		if ( ! $field_id = FrmField::create($values) ) {
174
+			wp_die();
175
+		}
176 176
 
177
-        self::include_single_field($field_id, $values);
177
+		self::include_single_field($field_id, $values);
178 178
 
179
-        wp_die();
180
-    }
179
+		wp_die();
180
+	}
181 181
 
182
-    /**
183
-     * Load a single field in the form builder along with all needed variables
184
-     */
185
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
186
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
182
+	/**
183
+	 * Load a single field in the form builder along with all needed variables
184
+	 */
185
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
186
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
187 187
 		$field_name = 'item_meta[' . $field_id . ']';
188
-        $html_id = FrmFieldsHelper::get_html_id($field);
189
-        $id = $form_id ? $form_id : $field['form_id'];
190
-        if ( $field['type'] == 'html' ) {
191
-            $field['stop_filter'] = true;
192
-        }
188
+		$html_id = FrmFieldsHelper::get_html_id($field);
189
+		$id = $form_id ? $form_id : $field['form_id'];
190
+		if ( $field['type'] == 'html' ) {
191
+			$field['stop_filter'] = true;
192
+		}
193 193
 
194 194
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
195 195
 
196
-        return $field;
197
-    }
196
+		return $field;
197
+	}
198 198
 
199
-    public static function destroy() {
199
+	public static function destroy() {
200 200
 		FrmAppHelper::permission_check('frm_edit_forms');
201
-        check_ajax_referer( 'frm_ajax', 'nonce' );
201
+		check_ajax_referer( 'frm_ajax', 'nonce' );
202 202
 
203 203
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
204 204
 		FrmField::destroy( $field_id );
205
-        wp_die();
206
-    }
205
+		wp_die();
206
+	}
207 207
 
208
-    /* Field Options */
208
+	/* Field Options */
209 209
 
210
-    //Add Single Option or Other Option
211
-    public static function add_option() {
210
+	//Add Single Option or Other Option
211
+	public static function add_option() {
212 212
 		FrmAppHelper::permission_check('frm_edit_forms');
213
-        check_ajax_referer( 'frm_ajax', 'nonce' );
213
+		check_ajax_referer( 'frm_ajax', 'nonce' );
214 214
 
215 215
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
216 216
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
217 217
 
218
-        //Get the field
219
-        $field = FrmField::getOne($id);
218
+		//Get the field
219
+		$field = FrmField::getOne($id);
220 220
 
221 221
 		if ( ! empty( $field->options ) ) {
222 222
 			$keys = array_keys( $field->options );
223
-            $last = str_replace( 'other_', '', end( $keys ) );
224
-        } else {
225
-            $last = 0;
226
-        }
227
-        $opt_key = $last + 1;
223
+			$last = str_replace( 'other_', '', end( $keys ) );
224
+		} else {
225
+			$last = 0;
226
+		}
227
+		$opt_key = $last + 1;
228 228
 
229
-        if ( 'other' == $opt_type ) {
229
+		if ( 'other' == $opt_type ) {
230 230
 			$opt = esc_html__( 'Other', 'formidable' );
231
-            $other_val = '';
232
-            $opt_key = 'other_' . $opt_key;
233
-
234
-            //Update value of "other" in DB
235
-            $field_options = maybe_unserialize( $field->field_options );
236
-            $field_options['other'] = 1;
237
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
238
-        } else {
231
+			$other_val = '';
232
+			$opt_key = 'other_' . $opt_key;
233
+
234
+			//Update value of "other" in DB
235
+			$field_options = maybe_unserialize( $field->field_options );
236
+			$field_options['other'] = 1;
237
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
238
+		} else {
239 239
 			$first_opt = reset( $field->options );
240 240
 			$next_opt = count( $field->options );
241
-            if ( $first_opt != '' ) {
242
-                $next_opt++;
243
-            }
241
+			if ( $first_opt != '' ) {
242
+				$next_opt++;
243
+			}
244 244
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
245
-            unset($next_opt);
246
-        }
247
-        $field_val = $opt;
245
+			unset($next_opt);
246
+		}
247
+		$field_val = $opt;
248 248
 		$field->options[ $opt_key ] = $opt;
249 249
 
250
-        //Update options in DB
250
+		//Update options in DB
251 251
 		FrmField::update( $id, array( 'options' => $field->options ) );
252 252
 
253
-        $field_data = $field;
254
-        $field = array(
255
-            'type'  => $field_data->type,
256
-            'id'    => $id,
257
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
258
-            'form_id' => $field_data->form_id,
259
-            'field_key' => $field_data->field_key,
260
-        );
253
+		$field_data = $field;
254
+		$field = array(
255
+			'type'  => $field_data->type,
256
+			'id'    => $id,
257
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
258
+			'form_id' => $field_data->form_id,
259
+			'field_key' => $field_data->field_key,
260
+		);
261 261
 
262 262
 		$field_name = 'item_meta[' . $id . ']';
263
-        $html_id = FrmFieldsHelper::get_html_id($field);
264
-        $checked = '';
263
+		$html_id = FrmFieldsHelper::get_html_id($field);
264
+		$checked = '';
265 265
 
266
-        if ( 'other' == $opt_type ) {
266
+		if ( 'other' == $opt_type ) {
267 267
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
268
-        } else {
268
+		} else {
269 269
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
270
-        }
271
-        wp_die();
272
-    }
270
+		}
271
+		wp_die();
272
+	}
273 273
 
274
-    public static function edit_option() {
274
+	public static function edit_option() {
275 275
 		FrmAppHelper::permission_check('frm_edit_forms');
276
-        check_ajax_referer( 'frm_ajax', 'nonce' );
276
+		check_ajax_referer( 'frm_ajax', 'nonce' );
277 277
 
278 278
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
279 279
 		$ids = explode( '-', $element_id );
@@ -281,43 +281,43 @@  discard block
 block discarded – undo
281 281
 
282 282
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
283 283
 		if ( strpos( $element_id, 'key_' ) ) {
284
-            $new_value = $update_value;
285
-        } else {
286
-            $new_label = $update_value;
287
-        }
284
+			$new_value = $update_value;
285
+		} else {
286
+			$new_label = $update_value;
287
+		}
288 288
 
289
-        $field = FrmField::getOne($id);
290
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
289
+		$field = FrmField::getOne($id);
290
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
291 291
 
292
-        $this_opt_id = end($ids);
292
+		$this_opt_id = end($ids);
293 293
 		$this_opt = (array) $field->options[ $this_opt_id ];
294 294
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
295 295
 
296
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
297
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
296
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
297
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
298 298
 
299
-        if ( ! isset( $new_label ) ) {
300
-            $new_label = $label;
301
-        }
299
+		if ( ! isset( $new_label ) ) {
300
+			$new_label = $label;
301
+		}
302 302
 
303
-        if ( isset($new_value) || isset($value) ) {
304
-            $update_value = isset($new_value) ? $new_value : $value;
305
-        }
303
+		if ( isset($new_value) || isset($value) ) {
304
+			$update_value = isset($new_value) ? $new_value : $value;
305
+		}
306 306
 
307 307
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
308 308
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
309
-        } else {
309
+		} else {
310 310
 			$field->options[ $this_opt_id ] = $orig_update_value;
311
-        }
311
+		}
312 312
 
313 313
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
314 314
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
315
-        wp_die();
316
-    }
315
+		wp_die();
316
+	}
317 317
 
318
-    public static function delete_option() {
318
+	public static function delete_option() {
319 319
 		FrmAppHelper::permission_check('frm_edit_forms');
320
-        check_ajax_referer( 'frm_ajax', 'nonce' );
320
+		check_ajax_referer( 'frm_ajax', 'nonce' );
321 321
 
322 322
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
323 323
 		$field = FrmField::getOne( $field_id );
@@ -325,310 +325,310 @@  discard block
 block discarded – undo
325 325
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
326 326
 
327 327
 		$options = $field->options;
328
-        unset( $options[ $opt_key ] );
329
-        $response = array( 'other' => true );
328
+		unset( $options[ $opt_key ] );
329
+		$response = array( 'other' => true );
330 330
 
331
-        //If the deleted option is an "other" option
331
+		//If the deleted option is an "other" option
332 332
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
333
-            //Assume all other options are gone, unless proven otherwise
334
-            $other = false;
333
+			//Assume all other options are gone, unless proven otherwise
334
+			$other = false;
335 335
 
336
-            //Check if all other options are really gone
337
-            foreach ( $options as $o_key => $o_val ) {
338
-                //If there is still an other option in the field, set other to true
336
+			//Check if all other options are really gone
337
+			foreach ( $options as $o_key => $o_val ) {
338
+				//If there is still an other option in the field, set other to true
339 339
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
340
-                    $other = true;
341
-                    break;
342
-                }
343
-                unset( $o_key, $o_val );
344
-            }
345
-
346
-            //If all other options are gone
347
-            if ( false === $other ) {
348
-                $field_options = maybe_unserialize( $field->field_options );
349
-                $field_options['other'] = 0;
340
+					$other = true;
341
+					break;
342
+				}
343
+				unset( $o_key, $o_val );
344
+			}
345
+
346
+			//If all other options are gone
347
+			if ( false === $other ) {
348
+				$field_options = maybe_unserialize( $field->field_options );
349
+				$field_options['other'] = 0;
350 350
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
351
-                $response = array( 'other' => false );
352
-            }
353
-        }
354
-        echo json_encode( $response );
351
+				$response = array( 'other' => false );
352
+			}
353
+		}
354
+		echo json_encode( $response );
355 355
 
356 356
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
357 357
 
358
-        wp_die();
359
-    }
358
+		wp_die();
359
+	}
360 360
 
361
-    public static function import_choices() {
362
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
361
+	public static function import_choices() {
362
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
363 363
 
364 364
 		$field_id = absint( $_REQUEST['field_id'] );
365 365
 
366
-        global $current_screen, $hook_suffix;
366
+		global $current_screen, $hook_suffix;
367 367
 
368
-        // Catch plugins that include admin-header.php before admin.php completes.
369
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
370
-            $hook_suffix = '';
371
-        	set_current_screen();
372
-        }
368
+		// Catch plugins that include admin-header.php before admin.php completes.
369
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
370
+			$hook_suffix = '';
371
+			set_current_screen();
372
+		}
373 373
 
374
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
375
-            register_admin_color_schemes();
376
-        }
374
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
375
+			register_admin_color_schemes();
376
+		}
377 377
 
378
-        $hook_suffix = $admin_body_class = '';
378
+		$hook_suffix = $admin_body_class = '';
379 379
 
380
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
381
-        	$admin_body_class .= ' folded';
382
-        }
380
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
381
+			$admin_body_class .= ' folded';
382
+		}
383 383
 
384
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
385
-        	$admin_body_class .= ' admin-bar';
386
-        }
384
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
385
+			$admin_body_class .= ' admin-bar';
386
+		}
387 387
 
388
-        if ( is_rtl() ) {
389
-        	$admin_body_class .= ' rtl';
390
-        }
388
+		if ( is_rtl() ) {
389
+			$admin_body_class .= ' rtl';
390
+		}
391 391
 
392
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
393
-        $prepop = array();
394
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
392
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
393
+		$prepop = array();
394
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
395 395
 
396
-        $field = FrmField::getOne($field_id);
396
+		$field = FrmField::getOne($field_id);
397 397
 
398
-        wp_enqueue_script( 'utils' );
398
+		wp_enqueue_script( 'utils' );
399 399
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
400
-        FrmAppHelper::load_admin_wide_js();
400
+		FrmAppHelper::load_admin_wide_js();
401 401
 
402 402
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
403
-        wp_die();
404
-    }
403
+		wp_die();
404
+	}
405 405
 
406
-    public static function import_options() {
406
+	public static function import_options() {
407 407
 		FrmAppHelper::permission_check('frm_edit_forms');
408
-        check_ajax_referer( 'frm_ajax', 'nonce' );
408
+		check_ajax_referer( 'frm_ajax', 'nonce' );
409 409
 
410
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
411
-            return;
412
-        }
410
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
411
+			return;
412
+		}
413 413
 
414 414
 		$field_id = absint( $_POST['field_id'] );
415
-        $field = FrmField::getOne($field_id);
415
+		$field = FrmField::getOne($field_id);
416 416
 
417 417
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
418
-            return;
419
-        }
420
-
421
-        $field = FrmFieldsHelper::setup_edit_vars($field);
422
-        $opts = stripslashes_deep($_POST['opts']);
423
-        $opts = explode("\n", rtrim($opts, "\n"));
424
-        if ( $field['separate_value'] ) {
425
-            foreach ( $opts as $opt_key => $opt ) {
426
-                if ( strpos($opt, '|') !== false ) {
427
-                    $vals = explode('|', $opt);
428
-                    if ( $vals[0] != $vals[1] ) {
429
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
430
-                    }
431
-                    unset($vals);
432
-                }
433
-                unset($opt_key, $opt);
434
-            }
435
-        }
436
-
437
-        //Keep other options after bulk update
438
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
439
-            $other_array = array();
440
-            foreach ( $field['options'] as $opt_key => $opt ) {
441
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
442
-                    $other_array[ $opt_key ] = $opt;
443
-                }
444
-                unset($opt_key, $opt);
445
-            }
446
-            if ( ! empty($other_array) ) {
447
-                $opts = array_merge( $opts, $other_array);
448
-            }
449
-        }
450
-
451
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
452
-
453
-        $field['options'] = $opts;
454
-        $field_name = $field['name'];
455
-
456
-        // Get html_id which will be used in single-option.php
457
-        $html_id = FrmFieldsHelper::get_html_id( $field );
458
-
459
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
418
+			return;
419
+		}
420
+
421
+		$field = FrmFieldsHelper::setup_edit_vars($field);
422
+		$opts = stripslashes_deep($_POST['opts']);
423
+		$opts = explode("\n", rtrim($opts, "\n"));
424
+		if ( $field['separate_value'] ) {
425
+			foreach ( $opts as $opt_key => $opt ) {
426
+				if ( strpos($opt, '|') !== false ) {
427
+					$vals = explode('|', $opt);
428
+					if ( $vals[0] != $vals[1] ) {
429
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
430
+					}
431
+					unset($vals);
432
+				}
433
+				unset($opt_key, $opt);
434
+			}
435
+		}
436
+
437
+		//Keep other options after bulk update
438
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
439
+			$other_array = array();
440
+			foreach ( $field['options'] as $opt_key => $opt ) {
441
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
442
+					$other_array[ $opt_key ] = $opt;
443
+				}
444
+				unset($opt_key, $opt);
445
+			}
446
+			if ( ! empty($other_array) ) {
447
+				$opts = array_merge( $opts, $other_array);
448
+			}
449
+		}
450
+
451
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
452
+
453
+		$field['options'] = $opts;
454
+		$field_name = $field['name'];
455
+
456
+		// Get html_id which will be used in single-option.php
457
+		$html_id = FrmFieldsHelper::get_html_id( $field );
458
+
459
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
460 460
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
461
-        } else {
462
-            FrmFieldsHelper::show_single_option($field);
463
-        }
461
+		} else {
462
+			FrmFieldsHelper::show_single_option($field);
463
+		}
464 464
 
465
-        wp_die();
466
-    }
465
+		wp_die();
466
+	}
467 467
 
468
-    public static function update_order() {
468
+	public static function update_order() {
469 469
 		FrmAppHelper::permission_check('frm_edit_forms');
470
-        check_ajax_referer( 'frm_ajax', 'nonce' );
470
+		check_ajax_referer( 'frm_ajax', 'nonce' );
471 471
 
472 472
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
473 473
 		foreach ( (array) $fields as $position => $item ) {
474 474
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
475 475
 		}
476
-        wp_die();
477
-    }
476
+		wp_die();
477
+	}
478 478
 
479 479
 	public static function change_type( $type ) {
480
-        $type_switch = array(
481
-            'scale'     => 'radio',
482
-            '10radio'   => 'radio',
483
-            'rte'       => 'textarea',
484
-            'website'   => 'url',
485
-        );
486
-        if ( isset( $type_switch[ $type ] ) ) {
487
-            $type = $type_switch[ $type ];
488
-        }
480
+		$type_switch = array(
481
+			'scale'     => 'radio',
482
+			'10radio'   => 'radio',
483
+			'rte'       => 'textarea',
484
+			'website'   => 'url',
485
+		);
486
+		if ( isset( $type_switch[ $type ] ) ) {
487
+			$type = $type_switch[ $type ];
488
+		}
489 489
 
490 490
 		$frm_field_selection = FrmField::field_selection();
491
-        $types = array_keys($frm_field_selection);
492
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
493
-            $type = 'text';
494
-        }
491
+		$types = array_keys($frm_field_selection);
492
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
493
+			$type = 'text';
494
+		}
495 495
 
496
-        return $type;
497
-    }
496
+		return $type;
497
+	}
498 498
 
499 499
 	public static function display_field_options( $display ) {
500 500
 		switch ( $display['type'] ) {
501
-            case 'captcha':
502
-                $display['required'] = false;
503
-                $display['invalid'] = true;
504
-                $display['default_blank'] = false;
501
+			case 'captcha':
502
+				$display['required'] = false;
503
+				$display['invalid'] = true;
504
+				$display['default_blank'] = false;
505 505
 				$display['captcha_size'] = true;
506
-            break;
507
-            case 'radio':
508
-                $display['default_blank'] = false;
509
-            break;
510
-            case 'text':
511
-            case 'textarea':
512
-                $display['size'] = true;
513
-                $display['clear_on_focus'] = true;
514
-            break;
515
-            case 'select':
516
-                $display['size'] = true;
517
-            break;
518
-            case 'url':
519
-            case 'website':
520
-            case 'email':
521
-                $display['size'] = true;
522
-                $display['clear_on_focus'] = true;
523
-                $display['invalid'] = true;
524
-        }
525
-
526
-        return $display;
527
-    }
528
-
529
-    public static function input_html( $field, $echo = true ) {
530
-        $class = array(); //$field['type'];
531
-        self::add_input_classes($field, $class);
532
-
533
-        $add_html = array();
534
-        self::add_html_size($field, $add_html);
535
-        self::add_html_length($field, $add_html);
536
-        self::add_html_placeholder($field, $add_html, $class);
506
+			break;
507
+			case 'radio':
508
+				$display['default_blank'] = false;
509
+			break;
510
+			case 'text':
511
+			case 'textarea':
512
+				$display['size'] = true;
513
+				$display['clear_on_focus'] = true;
514
+			break;
515
+			case 'select':
516
+				$display['size'] = true;
517
+			break;
518
+			case 'url':
519
+			case 'website':
520
+			case 'email':
521
+				$display['size'] = true;
522
+				$display['clear_on_focus'] = true;
523
+				$display['invalid'] = true;
524
+		}
525
+
526
+		return $display;
527
+	}
528
+
529
+	public static function input_html( $field, $echo = true ) {
530
+		$class = array(); //$field['type'];
531
+		self::add_input_classes($field, $class);
532
+
533
+		$add_html = array();
534
+		self::add_html_size($field, $add_html);
535
+		self::add_html_length($field, $add_html);
536
+		self::add_html_placeholder($field, $add_html, $class);
537 537
 		self::add_validation_messages( $field, $add_html );
538 538
 
539
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
539
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
540 540
 
541 541
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
542 542
 
543
-        self::add_shortcodes_to_html($field, $add_html);
543
+		self::add_shortcodes_to_html($field, $add_html);
544 544
 
545 545
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
546 546
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
547 547
 
548
-        if ( $echo ) {
549
-            echo $add_html;
550
-        }
548
+		if ( $echo ) {
549
+			echo $add_html;
550
+		}
551 551
 
552
-        return $add_html;
553
-    }
552
+		return $add_html;
553
+	}
554 554
 
555 555
 	private static function add_input_classes( $field, array &$class ) {
556
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
557
-            $class[] = $field['input_class'];
558
-        }
556
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
557
+			$class[] = $field['input_class'];
558
+		}
559 559
 
560
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
561
-            return;
562
-        }
560
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
561
+			return;
562
+		}
563 563
 
564
-        global $frm_vars;
564
+		global $frm_vars;
565 565
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
566
-            $class[] = 'dyn_default_value';
567
-        }
566
+			$class[] = 'dyn_default_value';
567
+		}
568 568
 
569
-        if ( isset($field['size']) && $field['size'] > 0 ) {
570
-            $class[] = 'auto_width';
571
-        }
572
-    }
569
+		if ( isset($field['size']) && $field['size'] > 0 ) {
570
+			$class[] = 'auto_width';
571
+		}
572
+	}
573 573
 
574 574
 	private static function add_html_size( $field, array &$add_html ) {
575 575
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
576
-            return;
577
-        }
576
+			return;
577
+		}
578 578
 
579
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
580
-            return;
581
-        }
579
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
580
+			return;
581
+		}
582 582
 
583
-        if ( is_numeric($field['size']) ) {
584
-            $field['size'] .= 'px';
585
-        }
583
+		if ( is_numeric($field['size']) ) {
584
+			$field['size'] .= 'px';
585
+		}
586 586
 
587
-        $important = apply_filters('frm_use_important_width', 1, $field);
588
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
587
+		$important = apply_filters('frm_use_important_width', 1, $field);
588
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
589 589
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
590 590
 
591
-        self::add_html_cols($field, $add_html);
592
-    }
591
+		self::add_html_cols($field, $add_html);
592
+	}
593 593
 
594 594
 	private static function add_html_cols( $field, array &$add_html ) {
595 595
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
596
-            return;
597
-        }
596
+			return;
597
+		}
598 598
 
599
-        // convert to cols for textareas
600
-        $calc = array(
601
-            ''      => 9,
602
-            'px'    => 9,
603
-            'rem'   => 0.444,
604
-            'em'    => 0.544,
605
-        );
599
+		// convert to cols for textareas
600
+		$calc = array(
601
+			''      => 9,
602
+			'px'    => 9,
603
+			'rem'   => 0.444,
604
+			'em'    => 0.544,
605
+		);
606 606
 
607
-        // include "col" for valid html
608
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
607
+		// include "col" for valid html
608
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
609 609
 
610
-        if ( ! isset( $calc[ $unit ] ) ) {
611
-            return;
612
-        }
610
+		if ( ! isset( $calc[ $unit ] ) ) {
611
+			return;
612
+		}
613 613
 
614
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
614
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
615 615
 
616 616
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
617
-    }
617
+	}
618 618
 
619 619
 	private static function add_html_length( $field, array &$add_html ) {
620
-        // check for max setting and if this field accepts maxlength
620
+		// check for max setting and if this field accepts maxlength
621 621
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
622
-            return;
623
-        }
622
+			return;
623
+		}
624 624
 
625
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
626
-            // don't load on form builder page
627
-            return;
628
-        }
625
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
626
+			// don't load on form builder page
627
+			return;
628
+		}
629 629
 
630 630
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
631
-    }
631
+	}
632 632
 
633 633
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
634 634
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -636,35 +636,35 @@  discard block
 block discarded – undo
636 636
 		}
637 637
 
638 638
 		$default_value_array = is_array( $field['default_value'] );
639
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
639
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
640 640
 			if ( $default_value_array ) {
641 641
 				$field['default_value'] = json_encode( $field['default_value'] );
642 642
 			}
643 643
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
644
-            return;
645
-        }
644
+			return;
645
+		}
646 646
 
647 647
 		if ( $default_value_array ) {
648 648
 			// don't include a json placeholder
649 649
 			return;
650 650
 		}
651 651
 
652
-        $frm_settings = FrmAppHelper::get_settings();
652
+		$frm_settings = FrmAppHelper::get_settings();
653 653
 
654 654
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
655
-            // use HMTL5 placeholder with js fallback
655
+			// use HMTL5 placeholder with js fallback
656 656
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
657
-            wp_enqueue_script('jquery-placeholder');
658
-        } else if ( ! $frm_settings->use_html ) {
657
+			wp_enqueue_script('jquery-placeholder');
658
+		} else if ( ! $frm_settings->use_html ) {
659 659
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
660 660
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
661
-            $class[] = 'frm_toggle_default';
661
+			$class[] = 'frm_toggle_default';
662 662
 
663
-            if ( $field['value'] == $field['default_value'] ) {
664
-                $class[] = 'frm_default';
665
-            }
666
-        }
667
-    }
663
+			if ( $field['value'] == $field['default_value'] ) {
664
+				$class[] = 'frm_default';
665
+			}
666
+		}
667
+	}
668 668
 
669 669
 	private static function add_validation_messages( $field, array &$add_html ) {
670 670
 		if ( FrmField::is_required( $field ) ) {
@@ -685,44 +685,44 @@  discard block
 block discarded – undo
685 685
 		}
686 686
 	}
687 687
 
688
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
689
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
690
-            return;
691
-        }
688
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
689
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
690
+			return;
691
+		}
692 692
 
693
-        foreach ( $field['shortcodes'] as $k => $v ) {
694
-            if ( 'opt' === $k ) {
695
-                continue;
696
-            }
693
+		foreach ( $field['shortcodes'] as $k => $v ) {
694
+			if ( 'opt' === $k ) {
695
+				continue;
696
+			}
697 697
 
698
-            if ( is_numeric($k) && strpos($v, '=') ) {
699
-                $add_html[] = $v;
700
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
698
+			if ( is_numeric($k) && strpos($v, '=') ) {
699
+				$add_html[] = $v;
700
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
701 701
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
702
-            } else {
702
+			} else {
703 703
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
704
-            }
705
-
706
-            unset($k, $v);
707
-        }
708
-    }
709
-
710
-    public static function check_value( $opt, $opt_key, $field ) {
711
-        if ( is_array( $opt ) ) {
712
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
713
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
714
-            } else {
715
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
716
-            }
717
-        }
718
-        return $opt;
719
-    }
704
+			}
705
+
706
+			unset($k, $v);
707
+		}
708
+	}
709
+
710
+	public static function check_value( $opt, $opt_key, $field ) {
711
+		if ( is_array( $opt ) ) {
712
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
713
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
714
+			} else {
715
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
716
+			}
717
+		}
718
+		return $opt;
719
+	}
720 720
 
721 721
 	public static function check_label( $opt ) {
722
-        if ( is_array($opt) ) {
723
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
724
-        }
722
+		if ( is_array($opt) ) {
723
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
724
+		}
725 725
 
726
-        return $opt;
727
-    }
726
+		return $opt;
727
+	}
728 728
 }
Please login to merge, or discard this patch.
classes/models/FrmEntryValidate.php 2 patches
Indentation   +159 added lines, -159 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,46 +28,46 @@  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
-        if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69
-            $value = '';
70
-        }
68
+		if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69
+			$value = '';
70
+		}
71 71
 
72 72
 		// Check for an array with only one value
73 73
 		// Don't reset values in "Other" fields because array keys need to be preserved
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			$value = reset($value);
76 76
 		}
77 77
 
78
-        if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
78
+		if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
79 79
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
80
-        } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81
-            $_POST['item_name'] = $value;
82
-        }
80
+		} else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81
+			$_POST['item_name'] = $value;
82
+		}
83 83
 
84 84
 		if ( $value != '' ) {
85 85
 			self::validate_url_field( $errors, $posted_field, $value, $args );
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
89 89
 		}
90 90
 
91
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
91
+		FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
92 92
 
93
-        self::validate_recaptcha($errors, $posted_field, $args);
93
+		self::validate_recaptcha($errors, $posted_field, $args);
94 94
 
95
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
95
+		$errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
96 96
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
97
-    }
97
+	}
98 98
 
99 99
 	public static function validate_url_field( &$errors, $field, &$value, $args ) {
100 100
 		if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
101
-            return;
102
-        }
101
+			return;
102
+		}
103 103
 
104
-        if ( trim($value) == 'http://' ) {
105
-            $value = '';
106
-        } else {
107
-            $value = esc_url_raw( $value );
104
+		if ( trim($value) == 'http://' ) {
105
+			$value = '';
106
+		} else {
107
+			$value = esc_url_raw( $value );
108 108
 			$value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
109
-        }
109
+		}
110 110
 
111
-        //validate the url format
112
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
111
+		//validate the url format
112
+		if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
113 113
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
114
-        }
115
-    }
114
+		}
115
+	}
116 116
 
117 117
 	public static function validate_email_field( &$errors, $field, $value, $args ) {
118
-        if ( $value == '' || $field->type != 'email' ) {
119
-            return;
120
-        }
118
+		if ( $value == '' || $field->type != 'email' ) {
119
+			return;
120
+		}
121 121
 
122
-        //validate the email format
123
-        if ( ! is_email($value) ) {
122
+		//validate the email format
123
+		if ( ! is_email($value) ) {
124 124
 			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
125
-        }
126
-    }
125
+		}
126
+	}
127 127
 
128 128
 	public static function validate_number_field( &$errors, $field, $value, $args ) {
129 129
 		//validate the number format
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public static function validate_recaptcha( &$errors, $field, $args ) {
203
-        if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
204
-            return;
205
-        }
203
+		if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) {
204
+			return;
205
+		}
206 206
 
207 207
 		$frm_settings = FrmAppHelper::get_settings();
208 208
 		if ( empty( $frm_settings->pubkey ) ) {
@@ -210,57 +210,57 @@  discard block
 block discarded – undo
210 210
 			return;
211 211
 		}
212 212
 
213
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
214
-            // If captcha is missing, check if it was already verified
213
+		if ( ! isset($_POST['g-recaptcha-response']) ) {
214
+			// If captcha is missing, check if it was already verified
215 215
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
216
-                // There was no captcha submitted
216
+				// There was no captcha submitted
217 217
 				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
218
-            }
219
-            return;
220
-        }
218
+			}
219
+			return;
220
+		}
221 221
 
222
-        $arg_array = array(
223
-            'body'      => array(
222
+		$arg_array = array(
223
+			'body'      => array(
224 224
 				'secret'   => $frm_settings->privkey,
225 225
 				'response' => $_POST['g-recaptcha-response'],
226 226
 				'remoteip' => FrmAppHelper::get_ip_address(),
227 227
 			),
228 228
 		);
229
-        $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
229
+		$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
+		$response = json_decode(wp_remote_retrieve_body( $resp ), true);
231 231
 
232
-        if ( isset( $response['success'] ) && ! $response['success'] ) {
233
-            // What happens when the CAPTCHA was entered incorrectly
232
+		if ( isset( $response['success'] ) && ! $response['success'] ) {
233
+			// What happens when the CAPTCHA was entered incorrectly
234 234
 			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
235
-        } else if ( is_wp_error( $resp ) ) {
235
+		} else if ( is_wp_error( $resp ) ) {
236 236
 			$error_string = $resp->get_error_message();
237 237
 			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238 238
 			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
239
-        }
240
-    }
241
-
242
-    /**
243
-     * check for spam
244
-     * @param boolean $exclude
245
-     * @param array $values
246
-     * @param array $errors by reference
247
-     */
248
-    public static function spam_check( $exclude, $values, &$errors ) {
249
-        if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
250
-            // only check spam if there are no other errors
251
-            return;
252
-        }
253
-
254
-        if ( self::is_akismet_spam( $values ) ) {
239
+		}
240
+	}
241
+
242
+	/**
243
+	 * check for spam
244
+	 * @param boolean $exclude
245
+	 * @param array $values
246
+	 * @param array $errors by reference
247
+	 */
248
+	public static function spam_check( $exclude, $values, &$errors ) {
249
+		if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
250
+			// only check spam if there are no other errors
251
+			return;
252
+		}
253
+
254
+		if ( self::is_akismet_spam( $values ) ) {
255 255
 			if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
256 256
 				$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
257 257
 			}
258
-	    }
258
+		}
259 259
 
260
-    	if ( self::blacklist_check( $values ) ) {
261
-            $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
262
-    	}
263
-    }
260
+		if ( self::blacklist_check( $values ) ) {
261
+			$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
262
+		}
263
+	}
264 264
 
265 265
 	private static function is_akismet_spam( $values ) {
266 266
 		global $wpcom_api_key;
@@ -272,54 +272,54 @@  discard block
 block discarded – undo
272 272
 		return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
273 273
 	}
274 274
 
275
-    public static function blacklist_check( $values ) {
276
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
277
-            return false;
278
-        }
275
+	public static function blacklist_check( $values ) {
276
+		if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
277
+			return false;
278
+		}
279 279
 
280
-    	$mod_keys = trim( get_option( 'blacklist_keys' ) );
280
+		$mod_keys = trim( get_option( 'blacklist_keys' ) );
281 281
 
282
-    	if ( empty( $mod_keys ) ) {
283
-    		return false;
284
-    	}
282
+		if ( empty( $mod_keys ) ) {
283
+			return false;
284
+		}
285 285
 
286
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
286
+		$content = FrmEntriesHelper::entry_array_to_string($values);
287 287
 
288 288
 		if ( empty($content) ) {
289
-		    return false;
289
+			return false;
290 290
 		}
291 291
 
292
-    	$words = explode( "\n", $mod_keys );
292
+		$words = explode( "\n", $mod_keys );
293 293
 
294
-    	foreach ( (array) $words as $word ) {
295
-    		$word = trim( $word );
294
+		foreach ( (array) $words as $word ) {
295
+			$word = trim( $word );
296 296
 
297
-    		if ( empty($word) ) {
298
-    			continue;
299
-    		}
297
+			if ( empty($word) ) {
298
+				continue;
299
+			}
300 300
 
301
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
302
-    			return true;
303
-    		}
304
-    	}
301
+			if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
302
+				return true;
303
+			}
304
+		}
305 305
 
306
-    	return false;
307
-    }
306
+		return false;
307
+	}
308 308
 
309
-    /**
310
-     * Check entries for spam
311
-     *
312
-     * @return boolean true if is spam
313
-     */
314
-    public static function akismet( $values ) {
315
-	    $content = FrmEntriesHelper::entry_array_to_string( $values );
309
+	/**
310
+	 * Check entries for spam
311
+	 *
312
+	 * @return boolean true if is spam
313
+	 */
314
+	public static function akismet( $values ) {
315
+		$content = FrmEntriesHelper::entry_array_to_string( $values );
316 316
 
317 317
 		if ( empty( $content ) ) {
318
-		    return false;
318
+			return false;
319 319
 		}
320 320
 
321
-        $datas = array();
322
-        self::parse_akismet_array( $datas, $content );
321
+		$datas = array();
322
+		self::parse_akismet_array( $datas, $content );
323 323
 
324 324
 		$query_string = '';
325 325
 		foreach ( $datas as $key => $data ) {
@@ -327,35 +327,35 @@  discard block
 block discarded – undo
327 327
 			unset( $key, $data );
328 328
 		}
329 329
 
330
-        $response = Akismet::http_post($query_string, 'comment-check');
330
+		$response = Akismet::http_post($query_string, 'comment-check');
331 331
 
332 332
 		return ( is_array( $response ) && $response[1] == 'true' );
333
-    }
334
-
335
-    /**
336
-     * @since 2.0
337
-     * @param string $content
338
-     */
339
-    private  static function parse_akismet_array( &$datas, $content ) {
340
-        $datas['blog'] = FrmAppHelper::site_url();
341
-        $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
333
+	}
334
+
335
+	/**
336
+	 * @since 2.0
337
+	 * @param string $content
338
+	 */
339
+	private  static function parse_akismet_array( &$datas, $content ) {
340
+		$datas['blog'] = FrmAppHelper::site_url();
341
+		$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
342 342
 		$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
343 343
 		$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
344
-        $datas['comment_type'] = 'formidable';
345
-        $datas['comment_content'] = $content;
344
+		$datas['comment_type'] = 'formidable';
345
+		$datas['comment_content'] = $content;
346 346
 
347
-        if ( $permalink = get_permalink() ) {
348
-            $datas['permalink'] = $permalink;
349
-        }
347
+		if ( $permalink = get_permalink() ) {
348
+			$datas['permalink'] = $permalink;
349
+		}
350 350
 
351
-        foreach ( $_SERVER as $key => $value ) {
351
+		foreach ( $_SERVER as $key => $value ) {
352 352
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
353 353
 				$datas[ $key ] = wp_strip_all_tags( $value );
354
-            } else {
354
+			} else {
355 355
 				$datas[ $key ] = '';
356
-            }
356
+			}
357 357
 
358
-            unset($key, $value);
359
-        }
360
-    }
358
+			unset($key, $value);
359
+		}
360
+	}
361 361
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 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;
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
         // Check for values in "Other" fields
66 66
         FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
67 67
 
68
-        if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
68
+        if ( isset( $posted_field->field_options['default_blank'] ) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
69 69
             $value = '';
70 70
         }
71 71
 
72 72
 		// Check for an array with only one value
73 73
 		// Don't reset values in "Other" fields because array keys need to be preserved
74
-		if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) {
75
-			$value = reset($value);
74
+		if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) {
75
+			$value = reset( $value );
76 76
 		}
77 77
 
78 78
         if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
79
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
79
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' );
80 80
         } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) {
81 81
             $_POST['item_name'] = $value;
82 82
         }
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 			self::validate_phone_field( $errors, $posted_field, $value, $args );
89 89
 		}
90 90
 
91
-        FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
91
+        FrmEntriesHelper::set_posted_value( $posted_field, $value, $args );
92 92
 
93
-        self::validate_recaptcha($errors, $posted_field, $args);
93
+        self::validate_recaptcha( $errors, $posted_field, $args );
94 94
 
95
-        $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
95
+        $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args );
96 96
 		$errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args );
97 97
     }
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-        if ( trim($value) == 'http://' ) {
104
+        if ( trim( $value ) == 'http://' ) {
105 105
             $value = '';
106 106
         } else {
107 107
             $value = esc_url_raw( $value );
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         //validate the url format
112
-        if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
113
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
112
+        if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) {
113
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
114 114
         }
115 115
     }
116 116
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
         }
121 121
 
122 122
         //validate the email format
123
-        if ( ! is_email($value) ) {
124
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
123
+        if ( ! is_email( $value ) ) {
124
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
125 125
         }
126 126
     }
127 127
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 			return;
132 132
 		}
133 133
 
134
-		if ( ! is_numeric( $value) ) {
135
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
134
+		if ( ! is_numeric( $value ) ) {
135
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
136 136
 		}
137 137
 
138 138
 		// validate number settings
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 			if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) {
143 143
 				//minnum maxnum
144 144
 				if ( (float) $value < $field->field_options['minnum'] ) {
145
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' );
145
+					$errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' );
146 146
 				} else if ( (float) $value > $field->field_options['maxnum'] ) {
147
-					$errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' );
147
+					$errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' );
148 148
 				}
149 149
 			}
150 150
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$pattern = self::phone_format( $field );
159 159
 
160 160
 		if ( ! preg_match( $pattern, $value ) ) {
161
-			$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
161
+			$errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
162 162
 		}
163 163
 	}
164 164
 
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 			return;
211 211
 		}
212 212
 
213
-        if ( ! isset($_POST['g-recaptcha-response']) ) {
213
+        if ( ! isset( $_POST['g-recaptcha-response'] ) ) {
214 214
             // If captcha is missing, check if it was already verified
215 215
 			if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
216 216
                 // There was no captcha submitted
217
-				$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
217
+				$errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' );
218 218
             }
219 219
             return;
220 220
         }
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
 			),
228 228
 		);
229 229
         $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
230
-        $response = json_decode(wp_remote_retrieve_body( $resp ), true);
230
+        $response = json_decode( wp_remote_retrieve_body( $resp ), true );
231 231
 
232 232
         if ( isset( $response['success'] ) && ! $response['success'] ) {
233 233
             // What happens when the CAPTCHA was entered incorrectly
234
-			$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
234
+			$errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
235 235
         } else if ( is_wp_error( $resp ) ) {
236 236
 			$error_string = $resp->get_error_message();
237
-			$errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238
-			$errors[ 'field' . $args['id'] ] .= ' ' . $error_string;
237
+			$errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' );
238
+			$errors['field' . $args['id']] .= ' ' . $error_string;
239 239
         }
240 240
     }
241 241
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 	private static function is_akismet_spam( $values ) {
266 266
 		global $wpcom_api_key;
267
-		return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
267
+		return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) );
268 268
 	}
269 269
 
270 270
 	private static function is_akismet_enabled_for_user( $form_id ) {
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	}
274 274
 
275 275
     public static function blacklist_check( $values ) {
276
-        if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
276
+        if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) {
277 277
             return false;
278 278
         }
279 279
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
     		return false;
284 284
     	}
285 285
 
286
-    	$content = FrmEntriesHelper::entry_array_to_string($values);
286
+    	$content = FrmEntriesHelper::entry_array_to_string( $values );
287 287
 
288
-		if ( empty($content) ) {
288
+		if ( empty( $content ) ) {
289 289
 		    return false;
290 290
 		}
291 291
 
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
     	foreach ( (array) $words as $word ) {
295 295
     		$word = trim( $word );
296 296
 
297
-    		if ( empty($word) ) {
297
+    		if ( empty( $word ) ) {
298 298
     			continue;
299 299
     		}
300 300
 
301
-    		if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
301
+    		if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) {
302 302
     			return true;
303 303
     		}
304 304
     	}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			unset( $key, $data );
328 328
 		}
329 329
 
330
-        $response = Akismet::http_post($query_string, 'comment-check');
330
+        $response = Akismet::http_post( $query_string, 'comment-check' );
331 331
 
332 332
 		return ( is_array( $response ) && $response[1] == 'true' );
333 333
     }
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 
351 351
         foreach ( $_SERVER as $key => $value ) {
352 352
 			if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
353
-				$datas[ $key ] = wp_strip_all_tags( $value );
353
+				$datas[$key] = wp_strip_all_tags( $value );
354 354
             } else {
355
-				$datas[ $key ] = '';
355
+				$datas[$key] = '';
356 356
             }
357 357
 
358
-            unset($key, $value);
358
+            unset( $key, $value );
359 359
         }
360 360
     }
361 361
 }
Please login to merge, or discard this patch.