Completed
Push — master ( 799fa9...225768 )
by Jamie
03:34
created
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +187 added lines, -187 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
-	    }
62
-
63
-        $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
64
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
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
+
63
+		$this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
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
-        $edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
208
-	    $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id;
207
+		$edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
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,17 +218,17 @@  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 ) {
227
-            $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
227
+			$class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
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
-			            $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);
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);
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,37 +284,37 @@  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') ) {
298
-    		    $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
299
-    		}
300
-            return;
297
+			if ( current_user_can('frm_delete_forms') ) {
298
+				$actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
299
+			}
300
+			return;
301 301
 		}
302 302
 
303 303
 		if ( current_user_can('frm_edit_forms') ) {
304
-            if ( ! $item->is_template || ! $item->default_template ) {
305
-		        $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
306
-            }
304
+			if ( ! $item->is_template || ! $item->default_template ) {
305
+				$actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
306
+			}
307 307
 
308
-		    if ( $item->is_template ) {
308
+			if ( $item->is_template ) {
309 309
 				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
310
-            } else {
311
-    		    $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
310
+			} else {
311
+				$actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
312 312
 
313
-    		    if ( FrmAppHelper::pro_is_installed() ) {
313
+				if ( FrmAppHelper::pro_is_installed() ) {
314 314
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
315
-        	    }
316
-        	}
317
-        }
315
+				}
316
+			}
317
+		}
318 318
 
319 319
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
320 320
 		if ( empty( $actions['trash'] ) ) {
@@ -323,52 +323,52 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 
325 325
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
326
-    }
326
+	}
327 327
 
328
-    /**
329
-     * @param string $edit_link
330
-     */
328
+	/**
329
+	 * @param string $edit_link
330
+	 */
331 331
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
332
-        $form_name = $item->name;
333
-        if ( trim($form_name) == '' ) {
334
-            $form_name = __( '(no title)');
335
-        }
332
+		$form_name = $item->name;
333
+		if ( trim($form_name) == '' ) {
334
+			$form_name = __( '(no title)');
335
+		}
336 336
 		$form_name = FrmAppHelper::kses( $form_name );
337 337
 		if ( 'excerpt' != $mode ) {
338 338
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
339 339
 		}
340 340
 
341
-        $val = '<strong>';
342
-        if ( 'trash' == $this->status ) {
343
-            $val .= $form_name;
344
-        } else {
341
+		$val = '<strong>';
342
+		if ( 'trash' == $this->status ) {
343
+			$val .= $form_name;
344
+		} else {
345 345
 			$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> ';
346
-        }
347
-
348
-        $this->add_draft_label( $item, $val );
349
-        $val .= '</strong>';
350
-
351
-        $this->add_form_description( $item, $val );
352
-
353
-        return $val;
354
-    }
355
-
356
-    /**
357
-     * @param string $val
358
-     */
359
-    private function add_draft_label( $item, &$val ) {
360
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
-            $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
362
-        }
363
-    }
364
-
365
-    /**
366
-     * @param string $val
367
-     */
368
-    private function add_form_description( $item, &$val ) {
369
-        global $mode;
370
-        if ( 'excerpt' == $mode ) {
371
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
-        }
373
-    }
346
+		}
347
+
348
+		$this->add_draft_label( $item, $val );
349
+		$val .= '</strong>';
350
+
351
+		$this->add_form_description( $item, $val );
352
+
353
+		return $val;
354
+	}
355
+
356
+	/**
357
+	 * @param string $val
358
+	 */
359
+	private function add_draft_label( $item, &$val ) {
360
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
+			$val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
362
+		}
363
+	}
364
+
365
+	/**
366
+	 * @param string $val
367
+	 */
368
+	private function add_form_description( $item, &$val ) {
369
+		global $mode;
370
+		if ( 'excerpt' == $mode ) {
371
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
+		}
373
+	}
374 374
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 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,19 +48,19 @@  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
 
63
-        $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
63
+        $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
64 64
         $total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	    if ( 'template' == $this->status ) {
74 74
             _e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
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>
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>
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;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207
-        $edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
208
-	    $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id;
207
+        $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
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
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
227
-            $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
227
+            $class = $column_name . ' column-' . $column_name . ( ( 'name' == $column_name ) ? ' post-title page-title column-title' : '' );
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 			switch ( $column_name ) {
239 239
 				case 'cb':
240
-					$r .= '<th scope="row" class="check-column">'. $checkbox .'</th>';
240
+					$r .= '<th scope="row" class="check-column">' . $checkbox . '</th>';
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
@@ -249,22 +249,22 @@  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':
256
-					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>';
256
+					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
257 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 259
 				    }
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,25 +290,25 @@  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') ) {
298
-    		    $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
297
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
298
+    		    $actions['trash'] = '<a href="' . esc_url( wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ) ) . '" class="submitdelete"  onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
299 299
     		}
300 300
             return;
301 301
 		}
302 302
 
303
-		if ( current_user_can('frm_edit_forms') ) {
303
+		if ( current_user_can( 'frm_edit_forms' ) ) {
304 304
             if ( ! $item->is_template || ! $item->default_template ) {
305
-		        $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
305
+		        $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
306 306
             }
307 307
 
308 308
 		    if ( $item->is_template ) {
309
-				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
309
+				$actions['frm_duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
310 310
             } else {
311
-    		    $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
311
+    		    $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
312 312
 
313 313
     		    if ( FrmAppHelper::pro_is_installed() ) {
314 314
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			unset( $actions['trash'] );
323 323
 		}
324 324
 
325
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
325
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
326 326
     }
327 327
 
328 328
     /**
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
      */
331 331
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
332 332
         $form_name = $item->name;
333
-        if ( trim($form_name) == '' ) {
334
-            $form_name = __( '(no title)');
333
+        if ( trim( $form_name ) == '' ) {
334
+            $form_name = __( '(no title)' );
335 335
         }
336 336
 		$form_name = FrmAppHelper::kses( $form_name );
337 337
 		if ( 'excerpt' != $mode ) {
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
      */
359 359
     private function add_draft_label( $item, &$val ) {
360 360
         if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
-            $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
361
+            $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
362 362
         }
363 363
     }
364 364
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     private function add_form_description( $item, &$val ) {
369 369
         global $mode;
370 370
         if ( 'excerpt' == $mode ) {
371
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
371
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
372 372
         }
373 373
     }
374 374
 }
Please login to merge, or discard this patch.
classes/controllers/FrmAddonsController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 class FrmAddonsController {
4 4
 
5 5
 	public static function menu() {
6
-		add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
6
+		add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
7 7
 
8 8
 		$affiliate = FrmAppHelper::get_affiliate();
9 9
 		if ( ! empty( $affiliate ) && ! FrmAppHelper::pro_is_installed() ) {
10
-			add_submenu_page( 'formidable', 'Formidable | '. __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
10
+			add_submenu_page( 'formidable', 'Formidable | ' . __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' );
11 11
 		}
12 12
 	}
13 13
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$keyed_addons = array();
41 41
 		foreach ( $addons as $addon ) {
42
-			$keyed_addons[ $addon['info']['slug'] ] = $addon;
42
+			$keyed_addons[$addon['info']['slug']] = $addon;
43 43
 		}
44 44
 
45 45
 		$plugin_order = array(
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		);
49 49
 		$ordered_addons = array();
50 50
 		foreach ( $plugin_order as $plugin ) {
51
-			if ( isset( $keyed_addons[ $plugin ] ) ) {
52
-				$ordered_addons[] = $keyed_addons[ $plugin ];
53
-				unset( $keyed_addons[ $plugin ] );
51
+			if ( isset( $keyed_addons[$plugin] ) ) {
52
+				$ordered_addons[] = $keyed_addons[$plugin];
53
+				unset( $keyed_addons[$plugin] );
54 54
 			}
55 55
 		}
56 56
 		$addons = $ordered_addons + $keyed_addons;
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	public static function get_licenses() {
88
-		FrmAppHelper::permission_check('frm_change_settings');
88
+		FrmAppHelper::permission_check( 'frm_change_settings' );
89 89
 		check_ajax_referer( 'frm_ajax', 'nonce' );
90 90
 
91
-		$license = get_option('frmpro-credentials');
91
+		$license = get_option( 'frmpro-credentials' );
92 92
 		if ( $license && is_array( $license ) && isset( $license['license'] ) ) {
93
-			$url = 'http://formidablepro.com/frm-edd-api/licenses?l='. urlencode( base64_encode( $license['license'] ) );
93
+			$url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) );
94 94
 			$licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) );
95 95
 			echo json_encode( $licenses );
96 96
 		}
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -2,137 +2,137 @@  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
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+			$field_name = 'item_meta['. $field_id .']';
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
39
+			ob_start();
40
+			include($path .'/classes/views/frm-forms/add_field.php');
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
-    public static function create() {
52
+	public static function create() {
53 53
 		FrmAppHelper::permission_check('frm_edit_forms');
54
-        check_ajax_referer( 'frm_ajax', 'nonce' );
54
+		check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+		$field = self::include_new_field($field_type, $form_id);
60 60
 
61
-        // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
61
+		// this hook will allow for multiple fields to be added at once
62
+		do_action('frm_after_field_created', $field, $form_id);
63 63
 
64
-        wp_die();
65
-    }
64
+		wp_die();
65
+	}
66 66
 
67
-    /**
68
-     * @param integer $form_id
69
-     */
67
+	/**
68
+	 * @param integer $form_id
69
+	 */
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71
-        $values = array();
72
-        if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
-        }
71
+		$values = array();
72
+		if ( FrmAppHelper::pro_is_installed() ) {
73
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
74
+		}
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
-        $field_id = FrmField::create( $field_values );
76
+		$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
77
+		$field_id = FrmField::create( $field_values );
78 78
 
79
-        if ( ! $field_id ) {
80
-            return false;
81
-        }
79
+		if ( ! $field_id ) {
80
+			return false;
81
+		}
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+		$field = self::include_single_field($field_id, $values, $form_id);
84 84
 
85
-        return $field;
86
-    }
85
+		return $field;
86
+	}
87 87
 
88
-    public static function update_form_id() {
88
+	public static function update_form_id() {
89 89
 		FrmAppHelper::permission_check('frm_edit_forms');
90
-        check_ajax_referer( 'frm_ajax', 'nonce' );
90
+		check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
93 93
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
94 94
 
95
-        if ( ! $field_id || ! $form_id ) {
96
-            wp_die();
97
-        }
95
+		if ( ! $field_id || ! $form_id ) {
96
+			wp_die();
97
+		}
98 98
 
99 99
 		$updated = FrmField::update( $field_id, compact( 'form_id' ) );
100 100
 		echo absint( $updated );
101 101
 
102
-        wp_die();
103
-    }
102
+		wp_die();
103
+	}
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106 106
 		FrmAppHelper::permission_check('frm_edit_forms');
107
-        check_ajax_referer( 'frm_ajax', 'nonce' );
107
+		check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
110
-            $field = 'name';
111
-        }
109
+		if ( empty($field) ) {
110
+			$field = 'name';
111
+		}
112 112
 
113
-        if ( empty($id) ) {
113
+		if ( empty($id) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116
-        }
116
+		}
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
121
-            // set blank value if there is no content
122
-            $value = '';
123
-        }
120
+		if ( trim(strip_tags($value)) == '' ) {
121
+			// set blank value if there is no content
122
+			$value = '';
123
+		}
124 124
 
125 125
 		FrmField::update( $id, array( $field => $value ) );
126 126
 
127 127
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
128 128
 
129 129
 		echo stripslashes( wp_kses_post( $value ) );
130
-        wp_die();
131
-    }
130
+		wp_die();
131
+	}
132 132
 
133
-    public static function update_ajax_option() {
133
+	public static function update_ajax_option() {
134 134
 		FrmAppHelper::permission_check('frm_edit_forms');
135
-        check_ajax_referer( 'frm_ajax', 'nonce' );
135
+		check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
138 138
 		if ( ! $field_id ) {
@@ -142,155 +142,155 @@  discard block
 block discarded – undo
142 142
 		$field = FrmField::getOne( $field_id );
143 143
 
144 144
 		foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) {
145
-            if ( isset($_POST[ $val ]) ) {
145
+			if ( isset($_POST[ $val ]) ) {
146 146
 				// all three of these options are boolean
147 147
 				$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
148 148
 
149
-                if ( $val == 'separate_value' ) {
149
+				if ( $val == 'separate_value' ) {
150 150
 					$new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1;
151
-                }
151
+				}
152 152
 
153
-                $field->field_options[ $val ] = $new_val;
154
-                unset($new_val);
155
-            }
156
-            unset($val);
157
-        }
153
+				$field->field_options[ $val ] = $new_val;
154
+				unset($new_val);
155
+			}
156
+			unset($val);
157
+		}
158 158
 
159
-        FrmField::update( $field_id, array(
160
-            'field_options' => $field->field_options,
159
+		FrmField::update( $field_id, array(
160
+			'field_options' => $field->field_options,
161 161
 			'form_id'		=> $field->form_id,
162
-        ) );
163
-        wp_die();
164
-    }
162
+		) );
163
+		wp_die();
164
+	}
165 165
 
166
-    public static function duplicate() {
166
+	public static function duplicate() {
167 167
 		FrmAppHelper::permission_check('frm_edit_forms');
168
-        check_ajax_referer( 'frm_ajax', 'nonce' );
168
+		check_ajax_referer( 'frm_ajax', 'nonce' );
169 169
 
170
-        global $wpdb;
170
+		global $wpdb;
171 171
 
172 172
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
173 173
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
174 174
 
175 175
 		$copy_field = FrmField::getOne( $field_id );
176
-        if ( ! $copy_field ) {
177
-            wp_die();
178
-        }
176
+		if ( ! $copy_field ) {
177
+			wp_die();
178
+		}
179 179
 
180
-        do_action('frm_duplicate_field', $copy_field, $form_id);
181
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
180
+		do_action('frm_duplicate_field', $copy_field, $form_id);
181
+		do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
182 182
 
183
-        $values = array( 'id' => $form_id );
184
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
183
+		$values = array( 'id' => $form_id );
184
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
185 185
 
186 186
 		$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 ) );
187 187
 
188
-        $values['field_order'] = $field_count + 1;
188
+		$values['field_order'] = $field_count + 1;
189 189
 
190
-        if ( ! $field_id = FrmField::create($values) ) {
191
-            wp_die();
192
-        }
190
+		if ( ! $field_id = FrmField::create($values) ) {
191
+			wp_die();
192
+		}
193 193
 
194
-        self::include_single_field($field_id, $values);
194
+		self::include_single_field($field_id, $values);
195 195
 
196
-        wp_die();
197
-    }
196
+		wp_die();
197
+	}
198 198
 
199
-    /**
200
-     * Load a single field in the form builder along with all needed variables
201
-     */
202
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
-        $field_name = 'item_meta['. $field_id .']';
205
-        $html_id = FrmFieldsHelper::get_html_id($field);
206
-        $id = $form_id ? $form_id : $field['form_id'];
207
-        if ( $field['type'] == 'html' ) {
208
-            $field['stop_filter'] = true;
209
-        }
199
+	/**
200
+	 * Load a single field in the form builder along with all needed variables
201
+	 */
202
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
+		$field_name = 'item_meta['. $field_id .']';
205
+		$html_id = FrmFieldsHelper::get_html_id($field);
206
+		$id = $form_id ? $form_id : $field['form_id'];
207
+		if ( $field['type'] == 'html' ) {
208
+			$field['stop_filter'] = true;
209
+		}
210 210
 
211
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
211
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
212 212
 
213
-        return $field;
214
-    }
213
+		return $field;
214
+	}
215 215
 
216
-    public static function destroy() {
216
+	public static function destroy() {
217 217
 		FrmAppHelper::permission_check('frm_edit_forms');
218
-        check_ajax_referer( 'frm_ajax', 'nonce' );
218
+		check_ajax_referer( 'frm_ajax', 'nonce' );
219 219
 
220 220
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
221 221
 		FrmField::destroy( $field_id );
222
-        wp_die();
223
-    }
222
+		wp_die();
223
+	}
224 224
 
225
-    /* Field Options */
225
+	/* Field Options */
226 226
 
227
-    //Add Single Option or Other Option
228
-    public static function add_option() {
227
+	//Add Single Option or Other Option
228
+	public static function add_option() {
229 229
 		FrmAppHelper::permission_check('frm_edit_forms');
230
-        check_ajax_referer( 'frm_ajax', 'nonce' );
230
+		check_ajax_referer( 'frm_ajax', 'nonce' );
231 231
 
232 232
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
233 233
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
234 234
 
235
-        //Get the field
236
-        $field = FrmField::getOne($id);
235
+		//Get the field
236
+		$field = FrmField::getOne($id);
237 237
 
238 238
 		if ( ! empty( $field->options ) ) {
239 239
 			$keys = array_keys( $field->options );
240
-            $last = str_replace( 'other_', '', end( $keys ) );
241
-        } else {
242
-            $last = 0;
243
-        }
244
-        $opt_key = $last + 1;
240
+			$last = str_replace( 'other_', '', end( $keys ) );
241
+		} else {
242
+			$last = 0;
243
+		}
244
+		$opt_key = $last + 1;
245 245
 
246
-        if ( 'other' == $opt_type ) {
246
+		if ( 'other' == $opt_type ) {
247 247
 			$opt = esc_html__( 'Other', 'formidable' );
248
-            $other_val = '';
249
-            $opt_key = 'other_' . $opt_key;
250
-
251
-            //Update value of "other" in DB
252
-            $field_options = maybe_unserialize( $field->field_options );
253
-            $field_options['other'] = 1;
254
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
255
-        } else {
248
+			$other_val = '';
249
+			$opt_key = 'other_' . $opt_key;
250
+
251
+			//Update value of "other" in DB
252
+			$field_options = maybe_unserialize( $field->field_options );
253
+			$field_options['other'] = 1;
254
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
255
+		} else {
256 256
 			$first_opt = reset( $field->options );
257 257
 			$next_opt = count( $field->options );
258
-            if ( $first_opt != '' ) {
259
-                $next_opt++;
260
-            }
261
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
-            unset($next_opt);
263
-        }
264
-        $field_val = $opt;
258
+			if ( $first_opt != '' ) {
259
+				$next_opt++;
260
+			}
261
+			$opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
+			unset($next_opt);
263
+		}
264
+		$field_val = $opt;
265 265
 		$field->options[ $opt_key ] = $opt;
266 266
 
267
-        //Update options in DB
267
+		//Update options in DB
268 268
 		FrmField::update( $id, array( 'options' => $field->options ) );
269 269
 
270
-        $field_data = $field;
271
-        $field = array(
272
-            'type'  => $field_data->type,
273
-            'id'    => $id,
274
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
275
-            'form_id' => $field_data->form_id,
276
-            'field_key' => $field_data->field_key,
277
-        );
278
-
279
-        $field_name = 'item_meta['. $id .']';
280
-        $html_id = FrmFieldsHelper::get_html_id($field);
281
-        $checked = '';
282
-
283
-        if ( 'other' == $opt_type ) {
284
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
285
-        } else {
286
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
287
-        }
288
-        wp_die();
289
-    }
290
-
291
-    public static function edit_option() {
270
+		$field_data = $field;
271
+		$field = array(
272
+			'type'  => $field_data->type,
273
+			'id'    => $id,
274
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
275
+			'form_id' => $field_data->form_id,
276
+			'field_key' => $field_data->field_key,
277
+		);
278
+
279
+		$field_name = 'item_meta['. $id .']';
280
+		$html_id = FrmFieldsHelper::get_html_id($field);
281
+		$checked = '';
282
+
283
+		if ( 'other' == $opt_type ) {
284
+			require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
285
+		} else {
286
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
287
+		}
288
+		wp_die();
289
+	}
290
+
291
+	public static function edit_option() {
292 292
 		FrmAppHelper::permission_check('frm_edit_forms');
293
-        check_ajax_referer( 'frm_ajax', 'nonce' );
293
+		check_ajax_referer( 'frm_ajax', 'nonce' );
294 294
 
295 295
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
296 296
 		$ids = explode( '-', $element_id );
@@ -298,43 +298,43 @@  discard block
 block discarded – undo
298 298
 
299 299
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) );
300 300
 		if ( strpos( $element_id, 'key_' ) ) {
301
-            $new_value = $update_value;
302
-        } else {
303
-            $new_label = $update_value;
304
-        }
301
+			$new_value = $update_value;
302
+		} else {
303
+			$new_label = $update_value;
304
+		}
305 305
 
306
-        $field = FrmField::getOne($id);
307
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
306
+		$field = FrmField::getOne($id);
307
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
308 308
 
309
-        $this_opt_id = end($ids);
309
+		$this_opt_id = end($ids);
310 310
 		$this_opt = (array) $field->options[ $this_opt_id ];
311 311
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
312 312
 
313
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
313
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
315 315
 
316
-        if ( ! isset( $new_label ) ) {
317
-            $new_label = $label;
318
-        }
316
+		if ( ! isset( $new_label ) ) {
317
+			$new_label = $label;
318
+		}
319 319
 
320
-        if ( isset($new_value) || isset($value) ) {
321
-            $update_value = isset($new_value) ? $new_value : $value;
322
-        }
320
+		if ( isset($new_value) || isset($value) ) {
321
+			$update_value = isset($new_value) ? $new_value : $value;
322
+		}
323 323
 
324 324
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
325 325
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
326
-        } else {
326
+		} else {
327 327
 			$field->options[ $this_opt_id ] = $orig_update_value;
328
-        }
328
+		}
329 329
 
330 330
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
331 331
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
332
-        wp_die();
333
-    }
332
+		wp_die();
333
+	}
334 334
 
335
-    public static function delete_option() {
335
+	public static function delete_option() {
336 336
 		FrmAppHelper::permission_check('frm_edit_forms');
337
-        check_ajax_referer( 'frm_ajax', 'nonce' );
337
+		check_ajax_referer( 'frm_ajax', 'nonce' );
338 338
 
339 339
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
340 340
 		$field = FrmField::getOne( $field_id );
@@ -342,340 +342,340 @@  discard block
 block discarded – undo
342 342
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
343 343
 
344 344
 		$options = $field->options;
345
-        unset( $options[ $opt_key ] );
346
-        $response = array( 'other' => true );
345
+		unset( $options[ $opt_key ] );
346
+		$response = array( 'other' => true );
347 347
 
348
-        //If the deleted option is an "other" option
348
+		//If the deleted option is an "other" option
349 349
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
350
-            //Assume all other options are gone, unless proven otherwise
351
-            $other = false;
350
+			//Assume all other options are gone, unless proven otherwise
351
+			$other = false;
352 352
 
353
-            //Check if all other options are really gone
354
-            foreach ( $options as $o_key => $o_val ) {
355
-                //If there is still an other option in the field, set other to true
353
+			//Check if all other options are really gone
354
+			foreach ( $options as $o_key => $o_val ) {
355
+				//If there is still an other option in the field, set other to true
356 356
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
357
-                    $other = true;
358
-                    break;
359
-                }
360
-                unset( $o_key, $o_val );
361
-            }
362
-
363
-            //If all other options are gone
364
-            if ( false === $other ) {
365
-                $field_options = maybe_unserialize( $field->field_options );
366
-                $field_options['other'] = 0;
357
+					$other = true;
358
+					break;
359
+				}
360
+				unset( $o_key, $o_val );
361
+			}
362
+
363
+			//If all other options are gone
364
+			if ( false === $other ) {
365
+				$field_options = maybe_unserialize( $field->field_options );
366
+				$field_options['other'] = 0;
367 367
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
368
-                $response = array( 'other' => false );
369
-            }
370
-        }
371
-        echo json_encode( $response );
368
+				$response = array( 'other' => false );
369
+			}
370
+		}
371
+		echo json_encode( $response );
372 372
 
373 373
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
374 374
 
375
-        wp_die();
376
-    }
375
+		wp_die();
376
+	}
377 377
 
378
-    public static function import_choices() {
379
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
378
+	public static function import_choices() {
379
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
380 380
 
381 381
 		$field_id = absint( $_REQUEST['field_id'] );
382 382
 
383
-        global $current_screen, $hook_suffix;
383
+		global $current_screen, $hook_suffix;
384 384
 
385
-        // Catch plugins that include admin-header.php before admin.php completes.
386
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
387
-            $hook_suffix = '';
388
-        	set_current_screen();
389
-        }
385
+		// Catch plugins that include admin-header.php before admin.php completes.
386
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
387
+			$hook_suffix = '';
388
+			set_current_screen();
389
+		}
390 390
 
391
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
392
-            register_admin_color_schemes();
393
-        }
391
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
392
+			register_admin_color_schemes();
393
+		}
394 394
 
395
-        $hook_suffix = $admin_body_class = '';
395
+		$hook_suffix = $admin_body_class = '';
396 396
 
397
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
398
-        	$admin_body_class .= ' folded';
399
-        }
397
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
398
+			$admin_body_class .= ' folded';
399
+		}
400 400
 
401
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
402
-        	$admin_body_class .= ' admin-bar';
403
-        }
401
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
402
+			$admin_body_class .= ' admin-bar';
403
+		}
404 404
 
405
-        if ( is_rtl() ) {
406
-        	$admin_body_class .= ' rtl';
407
-        }
405
+		if ( is_rtl() ) {
406
+			$admin_body_class .= ' rtl';
407
+		}
408 408
 
409
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410
-        $prepop = array();
411
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
409
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410
+		$prepop = array();
411
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
412 412
 
413
-        $field = FrmField::getOne($field_id);
413
+		$field = FrmField::getOne($field_id);
414 414
 
415
-        wp_enqueue_script( 'utils' );
416
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
417
-        FrmAppHelper::load_admin_wide_js();
415
+		wp_enqueue_script( 'utils' );
416
+		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
417
+		FrmAppHelper::load_admin_wide_js();
418 418
 
419
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
420
-        wp_die();
421
-    }
419
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
420
+		wp_die();
421
+	}
422 422
 
423
-    public static function import_options() {
423
+	public static function import_options() {
424 424
 		FrmAppHelper::permission_check('frm_edit_forms');
425
-        check_ajax_referer( 'frm_ajax', 'nonce' );
425
+		check_ajax_referer( 'frm_ajax', 'nonce' );
426 426
 
427
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
428
-            return;
429
-        }
427
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
428
+			return;
429
+		}
430 430
 
431 431
 		$field_id = absint( $_POST['field_id'] );
432
-        $field = FrmField::getOne($field_id);
432
+		$field = FrmField::getOne($field_id);
433 433
 
434 434
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
435
-            return;
436
-        }
437
-
438
-        $field = FrmFieldsHelper::setup_edit_vars($field);
439
-        $opts = stripslashes_deep($_POST['opts']);
440
-        $opts = explode("\n", rtrim($opts, "\n"));
441
-        if ( $field['separate_value'] ) {
442
-            foreach ( $opts as $opt_key => $opt ) {
443
-                if ( strpos($opt, '|') !== false ) {
444
-                    $vals = explode('|', $opt);
445
-                    if ( $vals[0] != $vals[1] ) {
446
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447
-                    }
448
-                    unset($vals);
449
-                }
450
-                unset($opt_key, $opt);
451
-            }
452
-        }
453
-
454
-        //Keep other options after bulk update
455
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
456
-            $other_array = array();
457
-            foreach ( $field['options'] as $opt_key => $opt ) {
458
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
-                    $other_array[ $opt_key ] = $opt;
460
-                }
461
-                unset($opt_key, $opt);
462
-            }
463
-            if ( ! empty($other_array) ) {
464
-                $opts = array_merge( $opts, $other_array);
465
-            }
466
-        }
467
-
468
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
469
-
470
-        $field['options'] = $opts;
471
-        $field_name = $field['name'];
472
-
473
-        // Get html_id which will be used in single-option.php
474
-        $html_id = FrmFieldsHelper::get_html_id( $field );
475
-
476
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
478
-        } else {
479
-            FrmFieldsHelper::show_single_option($field);
480
-        }
481
-
482
-        wp_die();
483
-    }
484
-
485
-    public static function update_order() {
435
+			return;
436
+		}
437
+
438
+		$field = FrmFieldsHelper::setup_edit_vars($field);
439
+		$opts = stripslashes_deep($_POST['opts']);
440
+		$opts = explode("\n", rtrim($opts, "\n"));
441
+		if ( $field['separate_value'] ) {
442
+			foreach ( $opts as $opt_key => $opt ) {
443
+				if ( strpos($opt, '|') !== false ) {
444
+					$vals = explode('|', $opt);
445
+					if ( $vals[0] != $vals[1] ) {
446
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447
+					}
448
+					unset($vals);
449
+				}
450
+				unset($opt_key, $opt);
451
+			}
452
+		}
453
+
454
+		//Keep other options after bulk update
455
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
456
+			$other_array = array();
457
+			foreach ( $field['options'] as $opt_key => $opt ) {
458
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
+					$other_array[ $opt_key ] = $opt;
460
+				}
461
+				unset($opt_key, $opt);
462
+			}
463
+			if ( ! empty($other_array) ) {
464
+				$opts = array_merge( $opts, $other_array);
465
+			}
466
+		}
467
+
468
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
469
+
470
+		$field['options'] = $opts;
471
+		$field_name = $field['name'];
472
+
473
+		// Get html_id which will be used in single-option.php
474
+		$html_id = FrmFieldsHelper::get_html_id( $field );
475
+
476
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
478
+		} else {
479
+			FrmFieldsHelper::show_single_option($field);
480
+		}
481
+
482
+		wp_die();
483
+	}
484
+
485
+	public static function update_order() {
486 486
 		FrmAppHelper::permission_check('frm_edit_forms');
487
-        check_ajax_referer( 'frm_ajax', 'nonce' );
487
+		check_ajax_referer( 'frm_ajax', 'nonce' );
488 488
 
489 489
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
490 490
 		foreach ( (array) $fields as $position => $item ) {
491 491
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
492 492
 		}
493
-        wp_die();
494
-    }
493
+		wp_die();
494
+	}
495 495
 
496 496
 	public static function change_type( $type ) {
497
-        $type_switch = array(
498
-            'scale'     => 'radio',
499
-            '10radio'   => 'radio',
500
-            'rte'       => 'textarea',
501
-            'website'   => 'url',
502
-        );
503
-        if ( isset( $type_switch[ $type ] ) ) {
504
-            $type = $type_switch[ $type ];
505
-        }
497
+		$type_switch = array(
498
+			'scale'     => 'radio',
499
+			'10radio'   => 'radio',
500
+			'rte'       => 'textarea',
501
+			'website'   => 'url',
502
+		);
503
+		if ( isset( $type_switch[ $type ] ) ) {
504
+			$type = $type_switch[ $type ];
505
+		}
506 506
 
507 507
 		$frm_field_selection = FrmField::field_selection();
508
-        $types = array_keys($frm_field_selection);
509
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
510
-            $type = 'text';
511
-        }
508
+		$types = array_keys($frm_field_selection);
509
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
510
+			$type = 'text';
511
+		}
512 512
 
513
-        return $type;
514
-    }
513
+		return $type;
514
+	}
515 515
 
516 516
 	public static function display_field_options( $display ) {
517 517
 		switch ( $display['type'] ) {
518
-            case 'captcha':
519
-                $display['required'] = false;
520
-                $display['invalid'] = true;
521
-                $display['default_blank'] = false;
518
+			case 'captcha':
519
+				$display['required'] = false;
520
+				$display['invalid'] = true;
521
+				$display['default_blank'] = false;
522 522
 				$display['captcha_size'] = true;
523
-            break;
524
-            case 'radio':
525
-                $display['default_blank'] = false;
526
-            break;
527
-            case 'text':
528
-            case 'textarea':
529
-                $display['size'] = true;
530
-                $display['clear_on_focus'] = true;
531
-            break;
532
-            case 'select':
533
-                $display['size'] = true;
534
-            break;
535
-            case 'url':
536
-            case 'website':
537
-            case 'email':
538
-                $display['size'] = true;
539
-                $display['clear_on_focus'] = true;
540
-                $display['invalid'] = true;
541
-        }
542
-
543
-        return $display;
544
-    }
545
-
546
-    public static function input_html( $field, $echo = true ) {
547
-        $class = array(); //$field['type'];
548
-        self::add_input_classes($field, $class);
549
-
550
-        $add_html = array();
551
-        self::add_html_size($field, $add_html);
552
-        self::add_html_length($field, $add_html);
553
-        self::add_html_placeholder($field, $add_html, $class);
523
+			break;
524
+			case 'radio':
525
+				$display['default_blank'] = false;
526
+			break;
527
+			case 'text':
528
+			case 'textarea':
529
+				$display['size'] = true;
530
+				$display['clear_on_focus'] = true;
531
+			break;
532
+			case 'select':
533
+				$display['size'] = true;
534
+			break;
535
+			case 'url':
536
+			case 'website':
537
+			case 'email':
538
+				$display['size'] = true;
539
+				$display['clear_on_focus'] = true;
540
+				$display['invalid'] = true;
541
+		}
542
+
543
+		return $display;
544
+	}
545
+
546
+	public static function input_html( $field, $echo = true ) {
547
+		$class = array(); //$field['type'];
548
+		self::add_input_classes($field, $class);
549
+
550
+		$add_html = array();
551
+		self::add_html_size($field, $add_html);
552
+		self::add_html_length($field, $add_html);
553
+		self::add_html_placeholder($field, $add_html, $class);
554 554
 		//self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete
555 555
 
556
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
556
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
557 557
 
558 558
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
559 559
 
560
-        self::add_shortcodes_to_html($field, $add_html);
560
+		self::add_shortcodes_to_html($field, $add_html);
561 561
 
562 562
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
563 563
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
564 564
 
565
-        if ( $echo ) {
566
-            echo $add_html;
567
-        }
565
+		if ( $echo ) {
566
+			echo $add_html;
567
+		}
568 568
 
569
-        return $add_html;
570
-    }
569
+		return $add_html;
570
+	}
571 571
 
572 572
 	private static function add_input_classes( $field, array &$class ) {
573
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
574
-            $class[] = $field['input_class'];
575
-        }
573
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
574
+			$class[] = $field['input_class'];
575
+		}
576 576
 
577
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
578
-            return;
579
-        }
577
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
578
+			return;
579
+		}
580 580
 
581
-        global $frm_vars;
581
+		global $frm_vars;
582 582
 		if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) {
583
-            $class[] = 'dyn_default_value';
584
-        }
583
+			$class[] = 'dyn_default_value';
584
+		}
585 585
 
586
-        if ( isset($field['size']) && $field['size'] > 0 ) {
587
-            $class[] = 'auto_width';
588
-        }
589
-    }
586
+		if ( isset($field['size']) && $field['size'] > 0 ) {
587
+			$class[] = 'auto_width';
588
+		}
589
+	}
590 590
 
591 591
 	private static function add_html_size( $field, array &$add_html ) {
592 592
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) {
593
-            return;
594
-        }
593
+			return;
594
+		}
595 595
 
596
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
597
-            return;
598
-        }
596
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
597
+			return;
598
+		}
599 599
 
600
-        if ( is_numeric($field['size']) ) {
601
-            $field['size'] .= 'px';
602
-        }
600
+		if ( is_numeric($field['size']) ) {
601
+			$field['size'] .= 'px';
602
+		}
603 603
 
604
-        $important = apply_filters('frm_use_important_width', 1, $field);
605
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
604
+		$important = apply_filters('frm_use_important_width', 1, $field);
605
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
+		$add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
607 607
 
608
-        self::add_html_cols($field, $add_html);
609
-    }
608
+		self::add_html_cols($field, $add_html);
609
+	}
610 610
 
611 611
 	private static function add_html_cols( $field, array &$add_html ) {
612 612
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
613
-            return;
614
-        }
613
+			return;
614
+		}
615 615
 
616
-        // convert to cols for textareas
617
-        $calc = array(
618
-            ''      => 9,
619
-            'px'    => 9,
620
-            'rem'   => 0.444,
621
-            'em'    => 0.544,
622
-        );
616
+		// convert to cols for textareas
617
+		$calc = array(
618
+			''      => 9,
619
+			'px'    => 9,
620
+			'rem'   => 0.444,
621
+			'em'    => 0.544,
622
+		);
623 623
 
624
-        // include "col" for valid html
625
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
624
+		// include "col" for valid html
625
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
626 626
 
627
-        if ( ! isset( $calc[ $unit ] ) ) {
628
-            return;
629
-        }
627
+		if ( ! isset( $calc[ $unit ] ) ) {
628
+			return;
629
+		}
630 630
 
631
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
631
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
632 632
 
633 633
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
634
-    }
634
+	}
635 635
 
636 636
 	private static function add_html_length( $field, array &$add_html ) {
637
-        // check for max setting and if this field accepts maxlength
637
+		// check for max setting and if this field accepts maxlength
638 638
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
639
-            return;
640
-        }
639
+			return;
640
+		}
641 641
 
642
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
643
-            // don't load on form builder page
644
-            return;
645
-        }
642
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
643
+			// don't load on form builder page
644
+			return;
645
+		}
646 646
 
647 647
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
648
-    }
648
+	}
649 649
 
650 650
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
651 651
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
652 652
 			return;
653 653
 		}
654 654
 
655
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
655
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
656 656
 			if ( is_array( $field['default_value'] ) ) {
657 657
 				$field['default_value'] = json_encode( $field['default_value'] );
658 658
 			}
659 659
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
660
-            return;
661
-        }
660
+			return;
661
+		}
662 662
 
663
-        $frm_settings = FrmAppHelper::get_settings();
663
+		$frm_settings = FrmAppHelper::get_settings();
664 664
 
665 665
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
666
-            // use HMTL5 placeholder with js fallback
667
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
-            wp_enqueue_script('jquery-placeholder');
669
-        } else if ( ! $frm_settings->use_html ) {
666
+			// use HMTL5 placeholder with js fallback
667
+			$add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
+			wp_enqueue_script('jquery-placeholder');
669
+		} else if ( ! $frm_settings->use_html ) {
670 670
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
671
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
672
-            $class[] = 'frm_toggle_default';
671
+			$add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
672
+			$class[] = 'frm_toggle_default';
673 673
 
674
-            if ( $field['value'] == $field['default_value'] ) {
675
-                $class[] = 'frm_default';
676
-            }
677
-        }
678
-    }
674
+			if ( $field['value'] == $field['default_value'] ) {
675
+				$class[] = 'frm_default';
676
+			}
677
+		}
678
+	}
679 679
 
680 680
 	private static function add_validation_messages( $field, array &$add_html ) {
681 681
 		if ( FrmField::is_required( $field ) ) {
@@ -696,44 +696,44 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 	}
698 698
 
699
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
700
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
701
-            return;
702
-        }
703
-
704
-        foreach ( $field['shortcodes'] as $k => $v ) {
705
-            if ( 'opt' === $k ) {
706
-                continue;
707
-            }
708
-
709
-            if ( is_numeric($k) && strpos($v, '=') ) {
710
-                $add_html[] = $v;
711
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
713
-            } else {
699
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
700
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
701
+			return;
702
+		}
703
+
704
+		foreach ( $field['shortcodes'] as $k => $v ) {
705
+			if ( 'opt' === $k ) {
706
+				continue;
707
+			}
708
+
709
+			if ( is_numeric($k) && strpos($v, '=') ) {
710
+				$add_html[] = $v;
711
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
+				$add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
713
+			} else {
714 714
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
715
-            }
716
-
717
-            unset($k, $v);
718
-        }
719
-    }
720
-
721
-    public static function check_value( $opt, $opt_key, $field ) {
722
-        if ( is_array( $opt ) ) {
723
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
724
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
725
-            } else {
726
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
727
-            }
728
-        }
729
-        return $opt;
730
-    }
715
+			}
716
+
717
+			unset($k, $v);
718
+		}
719
+	}
720
+
721
+	public static function check_value( $opt, $opt_key, $field ) {
722
+		if ( is_array( $opt ) ) {
723
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
724
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
725
+			} else {
726
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
727
+			}
728
+		}
729
+		return $opt;
730
+	}
731 731
 
732 732
 	public static function check_label( $opt ) {
733
-        if ( is_array($opt) ) {
734
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
735
-        }
733
+		if ( is_array($opt) ) {
734
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
735
+		}
736 736
 
737
-        return $opt;
738
-    }
737
+		return $opt;
738
+	}
739 739
 }
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 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'];
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
                 $field['value'] = '';
34 34
             }
35 35
 
36
-            $field_name = 'item_meta['. $field_id .']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
36
+            $field_name = 'item_meta[' . $field_id . ']';
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40
-            include($path .'/classes/views/frm-forms/add_field.php');
41
-            $field_html[ $field_id ] = ob_get_contents();
40
+            include( $path . '/classes/views/frm-forms/add_field.php' );
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
     }
51 51
 
52 52
     public static function create() {
53
-		FrmAppHelper::permission_check('frm_edit_forms');
53
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
54 54
         check_ajax_referer( 'frm_ajax', 'nonce' );
55 55
 
56 56
 		$field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' );
57 57
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
58 58
 
59
-        $field = self::include_new_field($field_type, $form_id);
59
+        $field = self::include_new_field( $field_type, $form_id );
60 60
 
61 61
         // this hook will allow for multiple fields to be added at once
62
-        do_action('frm_after_field_created', $field, $form_id);
62
+        do_action( 'frm_after_field_created', $field, $form_id );
63 63
 
64 64
         wp_die();
65 65
     }
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	public static function include_new_field( $field_type, $form_id ) {
71 71
         $values = array();
72 72
         if ( FrmAppHelper::pro_is_installed() ) {
73
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
73
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
74 74
         }
75 75
 
76
-        $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
76
+        $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) );
77 77
         $field_id = FrmField::create( $field_values );
78 78
 
79 79
         if ( ! $field_id ) {
80 80
             return false;
81 81
         }
82 82
 
83
-        $field = self::include_single_field($field_id, $values, $form_id);
83
+        $field = self::include_single_field( $field_id, $values, $form_id );
84 84
 
85 85
         return $field;
86 86
     }
87 87
 
88 88
     public static function update_form_id() {
89
-		FrmAppHelper::permission_check('frm_edit_forms');
89
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
90 90
         check_ajax_referer( 'frm_ajax', 'nonce' );
91 91
 
92 92
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function edit_name( $field = 'name', $id = '' ) {
106
-		FrmAppHelper::permission_check('frm_edit_forms');
106
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
107 107
         check_ajax_referer( 'frm_ajax', 'nonce' );
108 108
 
109
-        if ( empty($field) ) {
109
+        if ( empty( $field ) ) {
110 110
             $field = 'name';
111 111
         }
112 112
 
113
-        if ( empty($id) ) {
113
+        if ( empty( $id ) ) {
114 114
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
115 115
 			$id = str_replace( 'field_label_', '', $id );
116 116
         }
117 117
 
118 118
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
119 119
 		$value = trim( $value );
120
-        if ( trim(strip_tags($value)) == '' ) {
120
+        if ( trim( strip_tags( $value ) ) == '' ) {
121 121
             // set blank value if there is no content
122 122
             $value = '';
123 123
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     public static function update_ajax_option() {
134
-		FrmAppHelper::permission_check('frm_edit_forms');
134
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
135 135
         check_ajax_referer( 'frm_ajax', 'nonce' );
136 136
 
137 137
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$field = FrmField::getOne( $field_id );
143 143
 
144 144
 		foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) {
145
-            if ( isset($_POST[ $val ]) ) {
145
+            if ( isset( $_POST[$val] ) ) {
146 146
 				// all three of these options are boolean
147 147
 				$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
148 148
 
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 					$new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1;
151 151
                 }
152 152
 
153
-                $field->field_options[ $val ] = $new_val;
154
-                unset($new_val);
153
+                $field->field_options[$val] = $new_val;
154
+                unset( $new_val );
155 155
             }
156
-            unset($val);
156
+            unset( $val );
157 157
         }
158 158
 
159 159
         FrmField::update( $field_id, array(
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     }
165 165
 
166 166
     public static function duplicate() {
167
-		FrmAppHelper::permission_check('frm_edit_forms');
167
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
168 168
         check_ajax_referer( 'frm_ajax', 'nonce' );
169 169
 
170 170
         global $wpdb;
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
             wp_die();
178 178
         }
179 179
 
180
-        do_action('frm_duplicate_field', $copy_field, $form_id);
181
-        do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id);
180
+        do_action( 'frm_duplicate_field', $copy_field, $form_id );
181
+        do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
182 182
 
183 183
         $values = array( 'id' => $form_id );
184 184
         FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
185 185
 
186
-		$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 ) );
186
+		$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 ) );
187 187
 
188 188
         $values['field_order'] = $field_count + 1;
189 189
 
190
-        if ( ! $field_id = FrmField::create($values) ) {
190
+        if ( ! $field_id = FrmField::create( $values ) ) {
191 191
             wp_die();
192 192
         }
193 193
 
194
-        self::include_single_field($field_id, $values);
194
+        self::include_single_field( $field_id, $values );
195 195
 
196 196
         wp_die();
197 197
     }
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
      * Load a single field in the form builder along with all needed variables
201 201
      */
202 202
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
203
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
204
-        $field_name = 'item_meta['. $field_id .']';
205
-        $html_id = FrmFieldsHelper::get_html_id($field);
203
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
204
+        $field_name = 'item_meta[' . $field_id . ']';
205
+        $html_id = FrmFieldsHelper::get_html_id( $field );
206 206
         $id = $form_id ? $form_id : $field['form_id'];
207 207
         if ( $field['type'] == 'html' ) {
208 208
             $field['stop_filter'] = true;
209 209
         }
210 210
 
211
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
211
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
212 212
 
213 213
         return $field;
214 214
     }
215 215
 
216 216
     public static function destroy() {
217
-		FrmAppHelper::permission_check('frm_edit_forms');
217
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
218 218
         check_ajax_referer( 'frm_ajax', 'nonce' );
219 219
 
220 220
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 
227 227
     //Add Single Option or Other Option
228 228
     public static function add_option() {
229
-		FrmAppHelper::permission_check('frm_edit_forms');
229
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
230 230
         check_ajax_referer( 'frm_ajax', 'nonce' );
231 231
 
232 232
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
233 233
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
234 234
 
235 235
         //Get the field
236
-        $field = FrmField::getOne($id);
236
+        $field = FrmField::getOne( $id );
237 237
 
238 238
 		if ( ! empty( $field->options ) ) {
239 239
 			$keys = array_keys( $field->options );
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 			$first_opt = reset( $field->options );
257 257
 			$next_opt = count( $field->options );
258 258
             if ( $first_opt != '' ) {
259
-                $next_opt++;
259
+                $next_opt ++;
260 260
             }
261
-            $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt;
262
-            unset($next_opt);
261
+            $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
262
+            unset( $next_opt );
263 263
         }
264 264
         $field_val = $opt;
265
-		$field->options[ $opt_key ] = $opt;
265
+		$field->options[$opt_key] = $opt;
266 266
 
267 267
         //Update options in DB
268 268
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
         $field = array(
272 272
             'type'  => $field_data->type,
273 273
             'id'    => $id,
274
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
274
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
275 275
             'form_id' => $field_data->form_id,
276 276
             'field_key' => $field_data->field_key,
277 277
         );
278 278
 
279
-        $field_name = 'item_meta['. $id .']';
280
-        $html_id = FrmFieldsHelper::get_html_id($field);
279
+        $field_name = 'item_meta[' . $id . ']';
280
+        $html_id = FrmFieldsHelper::get_html_id( $field );
281 281
         $checked = '';
282 282
 
283 283
         if ( 'other' == $opt_type ) {
284
-            require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
284
+            require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
285 285
         } else {
286
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
286
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
287 287
         }
288 288
         wp_die();
289 289
     }
290 290
 
291 291
     public static function edit_option() {
292
-		FrmAppHelper::permission_check('frm_edit_forms');
292
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
293 293
         check_ajax_referer( 'frm_ajax', 'nonce' );
294 294
 
295 295
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -303,28 +303,28 @@  discard block
 block discarded – undo
303 303
             $new_label = $update_value;
304 304
         }
305 305
 
306
-        $field = FrmField::getOne($id);
306
+        $field = FrmField::getOne( $id );
307 307
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
308 308
 
309
-        $this_opt_id = end($ids);
310
-		$this_opt = (array) $field->options[ $this_opt_id ];
311
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
309
+        $this_opt_id = end( $ids );
310
+		$this_opt = (array) $field->options[$this_opt_id];
311
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
312 312
 
313
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
314
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
313
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
314
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
315 315
 
316 316
         if ( ! isset( $new_label ) ) {
317 317
             $new_label = $label;
318 318
         }
319 319
 
320
-        if ( isset($new_value) || isset($value) ) {
321
-            $update_value = isset($new_value) ? $new_value : $value;
320
+        if ( isset( $new_value ) || isset( $value ) ) {
321
+            $update_value = isset( $new_value ) ? $new_value : $value;
322 322
         }
323 323
 
324 324
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
325
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
325
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
326 326
         } else {
327
-			$field->options[ $this_opt_id ] = $orig_update_value;
327
+			$field->options[$this_opt_id] = $orig_update_value;
328 328
         }
329 329
 
330 330
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     }
334 334
 
335 335
     public static function delete_option() {
336
-		FrmAppHelper::permission_check('frm_edit_forms');
336
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
337 337
         check_ajax_referer( 'frm_ajax', 'nonce' );
338 338
 
339 339
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
343 343
 
344 344
 		$options = $field->options;
345
-        unset( $options[ $opt_key ] );
345
+        unset( $options[$opt_key] );
346 346
         $response = array( 'other' => true );
347 347
 
348 348
         //If the deleted option is an "other" option
@@ -408,46 +408,46 @@  discard block
 block discarded – undo
408 408
 
409 409
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
410 410
         $prepop = array();
411
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
411
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
412 412
 
413
-        $field = FrmField::getOne($field_id);
413
+        $field = FrmField::getOne( $field_id );
414 414
 
415 415
         wp_enqueue_script( 'utils' );
416
-        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' );
416
+        wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
417 417
         FrmAppHelper::load_admin_wide_js();
418 418
 
419
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
419
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
420 420
         wp_die();
421 421
     }
422 422
 
423 423
     public static function import_options() {
424
-		FrmAppHelper::permission_check('frm_edit_forms');
424
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
425 425
         check_ajax_referer( 'frm_ajax', 'nonce' );
426 426
 
427
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
427
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
428 428
             return;
429 429
         }
430 430
 
431 431
 		$field_id = absint( $_POST['field_id'] );
432
-        $field = FrmField::getOne($field_id);
432
+        $field = FrmField::getOne( $field_id );
433 433
 
434 434
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
435 435
             return;
436 436
         }
437 437
 
438
-        $field = FrmFieldsHelper::setup_edit_vars($field);
439
-        $opts = stripslashes_deep($_POST['opts']);
440
-        $opts = explode("\n", rtrim($opts, "\n"));
438
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
439
+        $opts = stripslashes_deep( $_POST['opts'] );
440
+        $opts = explode( "\n", rtrim( $opts, "\n" ) );
441 441
         if ( $field['separate_value'] ) {
442 442
             foreach ( $opts as $opt_key => $opt ) {
443
-                if ( strpos($opt, '|') !== false ) {
444
-                    $vals = explode('|', $opt);
443
+                if ( strpos( $opt, '|' ) !== false ) {
444
+                    $vals = explode( '|', $opt );
445 445
                     if ( $vals[0] != $vals[1] ) {
446
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
446
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
447 447
                     }
448
-                    unset($vals);
448
+                    unset( $vals );
449 449
                 }
450
-                unset($opt_key, $opt);
450
+                unset( $opt_key, $opt );
451 451
             }
452 452
         }
453 453
 
@@ -456,12 +456,12 @@  discard block
 block discarded – undo
456 456
             $other_array = array();
457 457
             foreach ( $field['options'] as $opt_key => $opt ) {
458 458
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
459
-                    $other_array[ $opt_key ] = $opt;
459
+                    $other_array[$opt_key] = $opt;
460 460
                 }
461
-                unset($opt_key, $opt);
461
+                unset( $opt_key, $opt );
462 462
             }
463
-            if ( ! empty($other_array) ) {
464
-                $opts = array_merge( $opts, $other_array);
463
+            if ( ! empty( $other_array ) ) {
464
+                $opts = array_merge( $opts, $other_array );
465 465
             }
466 466
         }
467 467
 
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
         $html_id = FrmFieldsHelper::get_html_id( $field );
475 475
 
476 476
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
477
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
477
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
478 478
         } else {
479
-            FrmFieldsHelper::show_single_option($field);
479
+            FrmFieldsHelper::show_single_option( $field );
480 480
         }
481 481
 
482 482
         wp_die();
483 483
     }
484 484
 
485 485
     public static function update_order() {
486
-		FrmAppHelper::permission_check('frm_edit_forms');
486
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
487 487
         check_ajax_referer( 'frm_ajax', 'nonce' );
488 488
 
489 489
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
             'rte'       => 'textarea',
501 501
             'website'   => 'url',
502 502
         );
503
-        if ( isset( $type_switch[ $type ] ) ) {
504
-            $type = $type_switch[ $type ];
503
+        if ( isset( $type_switch[$type] ) ) {
504
+            $type = $type_switch[$type];
505 505
         }
506 506
 
507 507
 		$frm_field_selection = FrmField::field_selection();
508
-        $types = array_keys($frm_field_selection);
509
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
508
+        $types = array_keys( $frm_field_selection );
509
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
510 510
             $type = 'text';
511 511
         }
512 512
 
@@ -545,19 +545,19 @@  discard block
 block discarded – undo
545 545
 
546 546
     public static function input_html( $field, $echo = true ) {
547 547
         $class = array(); //$field['type'];
548
-        self::add_input_classes($field, $class);
548
+        self::add_input_classes( $field, $class );
549 549
 
550 550
         $add_html = array();
551
-        self::add_html_size($field, $add_html);
552
-        self::add_html_length($field, $add_html);
553
-        self::add_html_placeholder($field, $add_html, $class);
551
+        self::add_html_size( $field, $add_html );
552
+        self::add_html_length( $field, $add_html );
553
+        self::add_html_placeholder( $field, $add_html, $class );
554 554
 		//self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete
555 555
 
556
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
556
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
557 557
 
558 558
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
559 559
 
560
-        self::add_shortcodes_to_html($field, $add_html);
560
+        self::add_shortcodes_to_html( $field, $add_html );
561 561
 
562 562
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
563 563
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     }
571 571
 
572 572
 	private static function add_input_classes( $field, array &$class ) {
573
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
573
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
574 574
             $class[] = $field['input_class'];
575 575
         }
576 576
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             $class[] = 'dyn_default_value';
584 584
         }
585 585
 
586
-        if ( isset($field['size']) && $field['size'] > 0 ) {
586
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
587 587
             $class[] = 'auto_width';
588 588
         }
589 589
     }
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
             return;
594 594
         }
595 595
 
596
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
596
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
597 597
             return;
598 598
         }
599 599
 
600
-        if ( is_numeric($field['size']) ) {
600
+        if ( is_numeric( $field['size'] ) ) {
601 601
             $field['size'] .= 'px';
602 602
         }
603 603
 
604
-        $important = apply_filters('frm_use_important_width', 1, $field);
604
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
605 605
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
606
-        $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"';
606
+        $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
607 607
 
608
-        self::add_html_cols($field, $add_html);
608
+        self::add_html_cols( $field, $add_html );
609 609
     }
610 610
 
611 611
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
         );
623 623
 
624 624
         // include "col" for valid html
625
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
625
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
626 626
 
627
-        if ( ! isset( $calc[ $unit ] ) ) {
627
+        if ( ! isset( $calc[$unit] ) ) {
628 628
             return;
629 629
         }
630 630
 
631
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
631
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
632 632
 
633 633
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
634 634
     }
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
             return;
640 640
         }
641 641
 
642
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
642
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
643 643
             // don't load on form builder page
644 644
             return;
645 645
         }
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 
665 665
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
666 666
             // use HMTL5 placeholder with js fallback
667
-            $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"';
668
-            wp_enqueue_script('jquery-placeholder');
667
+            $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
668
+            wp_enqueue_script( 'jquery-placeholder' );
669 669
         } else if ( ! $frm_settings->use_html ) {
670 670
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
671
-            $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"';
671
+            $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
672 672
             $class[] = 'frm_toggle_default';
673 673
 
674 674
             if ( $field['value'] == $field['default_value'] ) {
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			$format = FrmEntryValidate::phone_format( $field );
693 693
 			$format = substr( $format, 2, -2 );
694 694
 			$key = 'pattern';
695
-			$add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"';
695
+			$add_html[$key] = $key . '="' . esc_attr( $format ) . '"';
696 696
 		}
697 697
 	}
698 698
 
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
                 continue;
707 707
             }
708 708
 
709
-            if ( is_numeric($k) && strpos($v, '=') ) {
709
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
710 710
                 $add_html[] = $v;
711
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
712
-                $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] );
711
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
712
+                $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
713 713
             } else {
714
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
714
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
715 715
             }
716 716
 
717
-            unset($k, $v);
717
+            unset( $k, $v );
718 718
         }
719 719
     }
720 720
 
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
     }
731 731
 
732 732
 	public static function check_label( $opt ) {
733
-        if ( is_array($opt) ) {
734
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
733
+        if ( is_array( $opt ) ) {
734
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
735 735
         }
736 736
 
737 737
         return $opt;
Please login to merge, or discard this patch.
classes/controllers/FrmFormActionsController.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,109 +1,109 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmFormActionsController {
4
-    public static $action_post_type = 'frm_form_actions';
5
-    public static $registered_actions;
6
-
7
-    public static function register_post_types() {
8
-        register_post_type( self::$action_post_type, array(
9
-            'label' => __( 'Form Actions', 'formidable' ),
10
-            'description' => '',
11
-            'public' => false,
12
-            'show_ui' => false,
13
-            'exclude_from_search' => true,
14
-            'show_in_nav_menus' => false,
15
-            'show_in_menu' => true,
16
-            'capability_type' => 'page',
17
-            'supports' => array(
4
+	public static $action_post_type = 'frm_form_actions';
5
+	public static $registered_actions;
6
+
7
+	public static function register_post_types() {
8
+		register_post_type( self::$action_post_type, array(
9
+			'label' => __( 'Form Actions', 'formidable' ),
10
+			'description' => '',
11
+			'public' => false,
12
+			'show_ui' => false,
13
+			'exclude_from_search' => true,
14
+			'show_in_nav_menus' => false,
15
+			'show_in_menu' => true,
16
+			'capability_type' => 'page',
17
+			'supports' => array(
18 18
 				'title', 'editor', 'excerpt', 'custom-fields',
19 19
 				'page-attributes',
20
-            ),
21
-            'has_archive' => false,
22
-        ) );
23
-
24
-        /**
25
-         * post_content: json settings
26
-         * menu_order: form id
27
-         * post_excerpt: action type
28
-         */
29
-
30
-        self::actions_init();
31
-    }
32
-
33
-    public static function actions_init() {
34
-        self::$registered_actions = new Frm_Form_Action_Factory();
35
-        self::register_actions();
36
-        do_action( 'frm_form_actions_init' );
37
-    }
38
-
39
-    public static function register_actions() {
40
-        $action_classes = apply_filters( 'frm_registered_form_actions', array(
41
-            'email'     => 'FrmEmailAction',
42
-            'wppost'    => 'FrmDefPostAction',
43
-            'register'  => 'FrmDefRegAction',
44
-            'paypal'    => 'FrmDefPayPalAction',
45
-            //'aweber'    => 'FrmDefAweberAction',
46
-            'mailchimp' => 'FrmDefMlcmpAction',
47
-            'twilio'    => 'FrmDefTwilioAction',
48
-            'highrise'  => 'FrmDefHrsAction',
49
-        ) );
50
-
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
-
54
-        foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
56
-        }
57
-    }
20
+			),
21
+			'has_archive' => false,
22
+		) );
23
+
24
+		/**
25
+		 * post_content: json settings
26
+		 * menu_order: form id
27
+		 * post_excerpt: action type
28
+		 */
29
+
30
+		self::actions_init();
31
+	}
32
+
33
+	public static function actions_init() {
34
+		self::$registered_actions = new Frm_Form_Action_Factory();
35
+		self::register_actions();
36
+		do_action( 'frm_form_actions_init' );
37
+	}
38
+
39
+	public static function register_actions() {
40
+		$action_classes = apply_filters( 'frm_registered_form_actions', array(
41
+			'email'     => 'FrmEmailAction',
42
+			'wppost'    => 'FrmDefPostAction',
43
+			'register'  => 'FrmDefRegAction',
44
+			'paypal'    => 'FrmDefPayPalAction',
45
+			//'aweber'    => 'FrmDefAweberAction',
46
+			'mailchimp' => 'FrmDefMlcmpAction',
47
+			'twilio'    => 'FrmDefTwilioAction',
48
+			'highrise'  => 'FrmDefHrsAction',
49
+		) );
50
+
51
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
+		include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
53
+
54
+		foreach ( $action_classes as $action_class ) {
55
+			self::$registered_actions->register($action_class);
56
+		}
57
+	}
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60
-        $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
62
-            self::actions_init();
63
-            $temp_actions = self::$registered_actions->actions;
64
-        } else {
65
-            $temp_actions = $temp_actions->actions;
66
-        }
60
+		$temp_actions = self::$registered_actions;
61
+		if ( empty($temp_actions) ) {
62
+			self::actions_init();
63
+			$temp_actions = self::$registered_actions->actions;
64
+		} else {
65
+			$temp_actions = $temp_actions->actions;
66
+		}
67 67
 
68
-        $actions = array();
68
+		$actions = array();
69 69
 
70
-        foreach ( $temp_actions as $a ) {
71
-            if ( 'all' != $action && $a->id_base == $action ) {
72
-                return $a;
73
-            }
70
+		foreach ( $temp_actions as $a ) {
71
+			if ( 'all' != $action && $a->id_base == $action ) {
72
+				return $a;
73
+			}
74 74
 
75 75
 			$actions[ $a->id_base ] = $a;
76
-        }
77
-        unset( $temp_actions, $a );
78
-
79
-        $action_limit = 10;
80
-        if ( count( $actions ) <= $action_limit ) {
81
-            return $actions;
82
-        }
83
-
84
-        // remove the last few inactive icons if there are too many
85
-        $temp_actions = $actions;
86
-        arsort( $temp_actions );
87
-        foreach ( $temp_actions as $type => $a ) {
88
-            if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
76
+		}
77
+		unset( $temp_actions, $a );
78
+
79
+		$action_limit = 10;
80
+		if ( count( $actions ) <= $action_limit ) {
81
+			return $actions;
82
+		}
83
+
84
+		// remove the last few inactive icons if there are too many
85
+		$temp_actions = $actions;
86
+		arsort( $temp_actions );
87
+		foreach ( $temp_actions as $type => $a ) {
88
+			if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89 89
 				unset( $actions[ $type ] );
90
-                if ( count( $actions ) <= $action_limit ) {
91
-                    break;
92
-                }
93
-            }
94
-            unset( $type, $a );
95
-        }
90
+				if ( count( $actions ) <= $action_limit ) {
91
+					break;
92
+				}
93
+			}
94
+			unset( $type, $a );
95
+		}
96 96
 
97
-        return $actions;
98
-    }
97
+		return $actions;
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * @since 2.0
102 102
 	 */
103
-    public static function list_actions( $form, $values ) {
104
-        if ( empty( $form ) ) {
105
-            return;
106
-        }
103
+	public static function list_actions( $form, $values ) {
104
+		if ( empty( $form ) ) {
105
+			return;
106
+		}
107 107
 
108 108
 		/**
109 109
 		 * use this hook to migrate old settings into a new action
@@ -113,116 +113,116 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$form_actions = FrmFormAction::get_action_for_form( $form->id );
115 115
 
116
-        $action_controls = self::get_form_actions();
116
+		$action_controls = self::get_form_actions();
117 117
 
118
-        $action_map = array();
118
+		$action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
122
-        }
121
+			$action_map[ $control->id_base ] = $key;
122
+		}
123 123
 
124
-    	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
-    	        // don't try and show settings if action no longer exists
127
-    	        continue;
128
-    	    }
124
+		foreach ( $form_actions as $action ) {
125
+			if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
126
+				// don't try and show settings if action no longer exists
127
+				continue;
128
+			}
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
-    	}
132
-    }
130
+			self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
131
+		}
132
+	}
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
-    }
135
+		$action_control->_set($action_key);
136
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
137
+	}
138 138
 
139
-    public static function add_form_action() {
139
+	public static function add_form_action() {
140 140
 		FrmAppHelper::permission_check('frm_edit_forms');
141
-        check_ajax_referer( 'frm_ajax', 'nonce' );
141
+		check_ajax_referer( 'frm_ajax', 'nonce' );
142 142
 
143
-        global $frm_vars;
143
+		global $frm_vars;
144 144
 
145 145
 		$action_key = absint( $_POST['list_id'] );
146
-        $action_type = sanitize_text_field( $_POST['type'] );
146
+		$action_type = sanitize_text_field( $_POST['type'] );
147 147
 
148
-        $action_control = self::get_form_actions( $action_type );
149
-        $action_control->_set($action_key);
148
+		$action_control = self::get_form_actions( $action_type );
149
+		$action_control->_set($action_key);
150 150
 
151
-        $form_id = absint( $_POST['form_id'] );
151
+		$form_id = absint( $_POST['form_id'] );
152 152
 
153
-        $form_action = $action_control->prepare_new($form_id);
153
+		$form_action = $action_control->prepare_new($form_id);
154 154
 
155
-        $values = array();
156
-        $form = self::fields_to_values($form_id, $values);
155
+		$values = array();
156
+		$form = self::fields_to_values($form_id, $values);
157 157
 
158
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
159
-        wp_die();
160
-    }
158
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
159
+		wp_die();
160
+	}
161 161
 
162
-    public static function fill_action() {
162
+	public static function fill_action() {
163 163
 		FrmAppHelper::permission_check('frm_edit_forms');
164
-        check_ajax_referer( 'frm_ajax', 'nonce' );
164
+		check_ajax_referer( 'frm_ajax', 'nonce' );
165 165
 
166
-        $action_key = absint( $_POST['action_id'] );
167
-        $action_type = sanitize_text_field( $_POST['action_type'] );
166
+		$action_key = absint( $_POST['action_id'] );
167
+		$action_type = sanitize_text_field( $_POST['action_type'] );
168 168
 
169
-        $action_control = self::get_form_actions( $action_type );
170
-        if ( empty($action_control) ) {
171
-            wp_die();
172
-        }
169
+		$action_control = self::get_form_actions( $action_type );
170
+		if ( empty($action_control) ) {
171
+			wp_die();
172
+		}
173 173
 
174
-        $form_action = $action_control->get_single_action( $action_key );
174
+		$form_action = $action_control->get_single_action( $action_key );
175 175
 
176
-        $values = array();
177
-        $form = self::fields_to_values($form_action->menu_order, $values);
176
+		$values = array();
177
+		$form = self::fields_to_values($form_action->menu_order, $values);
178 178
 
179
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
180
-        wp_die();
181
-    }
179
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
180
+		wp_die();
181
+	}
182 182
 
183 183
 	private static function fields_to_values( $form_id, array &$values ) {
184
-        $form = FrmForm::getOne($form_id);
184
+		$form = FrmForm::getOne($form_id);
185 185
 
186 186
 		$values = array( 'fields' => array(), 'id' => $form->id );
187 187
 
188
-        $fields = FrmField::get_all_for_form($form->id);
189
-        foreach ( $fields as $k => $f ) {
190
-            $f = (array) $f;
191
-            $opts = (array) $f['field_options'];
192
-            $f = array_merge($opts, $f);
193
-            if ( ! isset( $f['post_field'] ) ) {
194
-                $f['post_field'] = '';
195
-            }
196
-            $values['fields'][] = $f;
197
-            unset($k, $f);
198
-        }
199
-
200
-        return $form;
201
-    }
188
+		$fields = FrmField::get_all_for_form($form->id);
189
+		foreach ( $fields as $k => $f ) {
190
+			$f = (array) $f;
191
+			$opts = (array) $f['field_options'];
192
+			$f = array_merge($opts, $f);
193
+			if ( ! isset( $f['post_field'] ) ) {
194
+				$f['post_field'] = '';
195
+			}
196
+			$values['fields'][] = $f;
197
+			unset($k, $f);
198
+		}
199
+
200
+		return $form;
201
+	}
202 202
 
203 203
 	public static function update_settings( $form_id ) {
204
-        global $wpdb;
204
+		global $wpdb;
205 205
 
206
-        $registered_actions = self::$registered_actions->actions;
206
+		$registered_actions = self::$registered_actions->actions;
207 207
 
208 208
 		$old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' );
209
-        $new_actions = array();
209
+		$new_actions = array();
210 210
 
211
-        foreach ( $registered_actions as $registered_action ) {
212
-            $action_ids = $registered_action->update_callback($form_id);
213
-            if ( ! empty( $action_ids ) ) {
214
-                $new_actions[] = $action_ids;
215
-            }
216
-        }
211
+		foreach ( $registered_actions as $registered_action ) {
212
+			$action_ids = $registered_action->update_callback($form_id);
213
+			if ( ! empty( $action_ids ) ) {
214
+				$new_actions[] = $action_ids;
215
+			}
216
+		}
217 217
 
218
-        //Only use array_merge if there are new actions
219
-        if ( ! empty( $new_actions ) ) {
220
-            $new_actions = call_user_func_array( 'array_merge', $new_actions );
221
-        }
222
-        $old_actions = array_diff( $old_actions, $new_actions );
218
+		//Only use array_merge if there are new actions
219
+		if ( ! empty( $new_actions ) ) {
220
+			$new_actions = call_user_func_array( 'array_merge', $new_actions );
221
+		}
222
+		$old_actions = array_diff( $old_actions, $new_actions );
223 223
 
224 224
 		self::delete_missing_actions( $old_actions );
225
-    }
225
+	}
226 226
 
227 227
 	public static function delete_missing_actions( $old_actions ) {
228 228
 		if ( ! empty( $old_actions ) ) {
@@ -237,36 +237,36 @@  discard block
 block discarded – undo
237 237
 		self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args );
238 238
 	}
239 239
 
240
-    /**
241
-     * @param string $event
242
-     */
240
+	/**
241
+	 * @param string $event
242
+	 */
243 243
 	public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
244 244
 		$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
245 245
 
246 246
 		if ( empty( $form_actions ) ) {
247
-            return;
248
-        }
247
+			return;
248
+		}
249 249
 
250 250
 		FrmForm::maybe_get_form( $form );
251 251
 
252
-        $link_settings = self::get_form_actions( $type );
253
-        if ( 'all' != $type ) {
254
-            $link_settings = array( $type => $link_settings );
255
-        }
252
+		$link_settings = self::get_form_actions( $type );
253
+		if ( 'all' != $type ) {
254
+			$link_settings = array( $type => $link_settings );
255
+		}
256 256
 
257
-        $stored_actions = $action_priority = array();
257
+		$stored_actions = $action_priority = array();
258 258
 
259 259
 		$importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING;
260 260
 
261
-        foreach ( $form_actions as $action ) {
261
+		foreach ( $form_actions as $action ) {
262 262
 			$trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] );
263 263
 			if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) {
264
-                continue;
265
-            }
264
+				continue;
265
+			}
266 266
 
267
-            if ( ! is_object( $entry ) ) {
268
-                $entry = FrmEntry::getOne( $entry, true );
269
-            }
267
+			if ( ! is_object( $entry ) ) {
268
+				$entry = FrmEntry::getOne( $entry, true );
269
+			}
270 270
 
271 271
 			if ( empty( $entry ) || $entry->is_draft ) {
272 272
 				continue;
@@ -275,66 +275,66 @@  discard block
 block discarded – undo
275 275
 			$child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
276 276
 
277 277
 			if ( $child_entry ) {
278
-                //don't trigger actions for sub forms
279
-                continue;
280
-            }
278
+				//don't trigger actions for sub forms
279
+				continue;
280
+			}
281 281
 
282
-            // check conditional logic
282
+			// check conditional logic
283 283
 			$stop = FrmFormAction::action_conditions_met( $action, $entry );
284
-            if ( $stop ) {
285
-                continue;
286
-            }
284
+			if ( $stop ) {
285
+				continue;
286
+			}
287 287
 
288
-            // store actions so they can be triggered with the correct priority
289
-            $stored_actions[ $action->ID ] = $action;
290
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
288
+			// store actions so they can be triggered with the correct priority
289
+			$stored_actions[ $action->ID ] = $action;
290
+			$action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
291 291
 
292
-            unset($action);
293
-        }
292
+			unset($action);
293
+		}
294 294
 
295
-        if ( ! empty( $stored_actions ) ) {
296
-            asort($action_priority);
295
+		if ( ! empty( $stored_actions ) ) {
296
+			asort($action_priority);
297 297
 
298
-            // make sure hooks are loaded
299
-            new FrmNotification();
298
+			// make sure hooks are loaded
299
+			new FrmNotification();
300 300
 
301
-            foreach ( $action_priority as $action_id => $priority ) {
302
-                $action = $stored_actions[ $action_id ];
303
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
301
+			foreach ( $action_priority as $action_id => $priority ) {
302
+				$action = $stored_actions[ $action_id ];
303
+				do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
+				do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
305 305
 
306
-                // If post is created, get updated $entry object
307
-                if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
-                    $entry = FrmEntry::getOne($entry->id, true);
309
-                }
310
-            }
311
-        }
312
-    }
306
+				// If post is created, get updated $entry object
307
+				if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
+					$entry = FrmEntry::getOne($entry->id, true);
309
+				}
310
+			}
311
+		}
312
+	}
313 313
 
314 314
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
315
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
316
-            // continue if we know which actions to copy
317
-            return;
318
-        }
315
+		if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
316
+			// continue if we know which actions to copy
317
+			return;
318
+		}
319 319
 
320
-        $action_controls = self::get_form_actions( );
320
+		$action_controls = self::get_form_actions( );
321 321
 
322
-        foreach ( $action_controls as $action_control ) {
323
-            $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
324
-            unset( $action_control );
325
-        }
326
-    }
322
+		foreach ( $action_controls as $action_control ) {
323
+			$action_control->duplicate_form_actions( $form_id, $args['old_id'] );
324
+			unset( $action_control );
325
+		}
326
+	}
327 327
 
328
-    public static function limit_by_type( $where ) {
329
-        global $frm_vars, $wpdb;
328
+	public static function limit_by_type( $where ) {
329
+		global $frm_vars, $wpdb;
330 330
 
331
-        if ( ! isset( $frm_vars['action_type'] ) ) {
332
-            return $where;
333
-        }
331
+		if ( ! isset( $frm_vars['action_type'] ) ) {
332
+			return $where;
333
+		}
334 334
 
335
-        $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
336
-        return $where;
337
-    }
335
+		$where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
336
+		return $where;
337
+	}
338 338
 }
339 339
 
340 340
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		foreach ( $keys as $key ) {
362 362
 			// don't register new action if old action with the same id is already registered
363 363
 			if ( ! isset( $this->actions[ $key ] ) ) {
364
-			    $this->actions[ $key ]->_register();
364
+				$this->actions[ $key ]->_register();
365 365
 			}
366 366
 		}
367 367
 	}
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
             'highrise'  => 'FrmDefHrsAction',
49 49
         ) );
50 50
 
51
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php');
52
-        include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php');
51
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
52
+        include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
53 53
 
54 54
         foreach ( $action_classes as $action_class ) {
55
-            self::$registered_actions->register($action_class);
55
+            self::$registered_actions->register( $action_class );
56 56
         }
57 57
     }
58 58
 
59 59
 	public static function get_form_actions( $action = 'all' ) {
60 60
         $temp_actions = self::$registered_actions;
61
-        if ( empty($temp_actions) ) {
61
+        if ( empty( $temp_actions ) ) {
62 62
             self::actions_init();
63 63
             $temp_actions = self::$registered_actions->actions;
64 64
         } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 return $a;
73 73
             }
74 74
 
75
-			$actions[ $a->id_base ] = $a;
75
+			$actions[$a->id_base] = $a;
76 76
         }
77 77
         unset( $temp_actions, $a );
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         arsort( $temp_actions );
87 87
         foreach ( $temp_actions as $type => $a ) {
88 88
             if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
89
-				unset( $actions[ $type ] );
89
+				unset( $actions[$type] );
90 90
                 if ( count( $actions ) <= $action_limit ) {
91 91
                     break;
92 92
                 }
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
         $action_map = array();
119 119
 
120 120
 		foreach ( $action_controls as $key => $control ) {
121
-            $action_map[ $control->id_base ] = $key;
121
+            $action_map[$control->id_base] = $key;
122 122
         }
123 123
 
124 124
     	foreach ( $form_actions as $action ) {
125
-    	    if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
125
+    	    if ( ! isset( $action_map[$action->post_excerpt] ) ) {
126 126
     	        // don't try and show settings if action no longer exists
127 127
     	        continue;
128 128
     	    }
129 129
 
130
-    		self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
130
+    		self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values );
131 131
     	}
132 132
     }
133 133
 
134 134
 	public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
135
-        $action_control->_set($action_key);
136
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
135
+        $action_control->_set( $action_key );
136
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
137 137
     }
138 138
 
139 139
     public static function add_form_action() {
140
-		FrmAppHelper::permission_check('frm_edit_forms');
140
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
141 141
         check_ajax_referer( 'frm_ajax', 'nonce' );
142 142
 
143 143
         global $frm_vars;
@@ -146,55 +146,55 @@  discard block
 block discarded – undo
146 146
         $action_type = sanitize_text_field( $_POST['type'] );
147 147
 
148 148
         $action_control = self::get_form_actions( $action_type );
149
-        $action_control->_set($action_key);
149
+        $action_control->_set( $action_key );
150 150
 
151 151
         $form_id = absint( $_POST['form_id'] );
152 152
 
153
-        $form_action = $action_control->prepare_new($form_id);
153
+        $form_action = $action_control->prepare_new( $form_id );
154 154
 
155 155
         $values = array();
156
-        $form = self::fields_to_values($form_id, $values);
156
+        $form = self::fields_to_values( $form_id, $values );
157 157
 
158
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php');
158
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
159 159
         wp_die();
160 160
     }
161 161
 
162 162
     public static function fill_action() {
163
-		FrmAppHelper::permission_check('frm_edit_forms');
163
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
164 164
         check_ajax_referer( 'frm_ajax', 'nonce' );
165 165
 
166 166
         $action_key = absint( $_POST['action_id'] );
167 167
         $action_type = sanitize_text_field( $_POST['action_type'] );
168 168
 
169 169
         $action_control = self::get_form_actions( $action_type );
170
-        if ( empty($action_control) ) {
170
+        if ( empty( $action_control ) ) {
171 171
             wp_die();
172 172
         }
173 173
 
174 174
         $form_action = $action_control->get_single_action( $action_key );
175 175
 
176 176
         $values = array();
177
-        $form = self::fields_to_values($form_action->menu_order, $values);
177
+        $form = self::fields_to_values( $form_action->menu_order, $values );
178 178
 
179
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php');
179
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
180 180
         wp_die();
181 181
     }
182 182
 
183 183
 	private static function fields_to_values( $form_id, array &$values ) {
184
-        $form = FrmForm::getOne($form_id);
184
+        $form = FrmForm::getOne( $form_id );
185 185
 
186 186
 		$values = array( 'fields' => array(), 'id' => $form->id );
187 187
 
188
-        $fields = FrmField::get_all_for_form($form->id);
188
+        $fields = FrmField::get_all_for_form( $form->id );
189 189
         foreach ( $fields as $k => $f ) {
190 190
             $f = (array) $f;
191 191
             $opts = (array) $f['field_options'];
192
-            $f = array_merge($opts, $f);
192
+            $f = array_merge( $opts, $f );
193 193
             if ( ! isset( $f['post_field'] ) ) {
194 194
                 $f['post_field'] = '';
195 195
             }
196 196
             $values['fields'][] = $f;
197
-            unset($k, $f);
197
+            unset( $k, $f );
198 198
         }
199 199
 
200 200
         return $form;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         $new_actions = array();
210 210
 
211 211
         foreach ( $registered_actions as $registered_action ) {
212
-            $action_ids = $registered_action->update_callback($form_id);
212
+            $action_ids = $registered_action->update_callback( $form_id );
213 213
             if ( ! empty( $action_ids ) ) {
214 214
                 $new_actions[] = $action_ids;
215 215
             }
@@ -286,33 +286,33 @@  discard block
 block discarded – undo
286 286
             }
287 287
 
288 288
             // store actions so they can be triggered with the correct priority
289
-            $stored_actions[ $action->ID ] = $action;
290
-            $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
289
+            $stored_actions[$action->ID] = $action;
290
+            $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority'];
291 291
 
292
-            unset($action);
292
+            unset( $action );
293 293
         }
294 294
 
295 295
         if ( ! empty( $stored_actions ) ) {
296
-            asort($action_priority);
296
+            asort( $action_priority );
297 297
 
298 298
             // make sure hooks are loaded
299 299
             new FrmNotification();
300 300
 
301 301
             foreach ( $action_priority as $action_id => $priority ) {
302
-                $action = $stored_actions[ $action_id ];
303
-                do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event);
304
-                do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form);
302
+                $action = $stored_actions[$action_id];
303
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
304
+                do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
305 305
 
306 306
                 // If post is created, get updated $entry object
307 307
                 if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
308
-                    $entry = FrmEntry::getOne($entry->id, true);
308
+                    $entry = FrmEntry::getOne( $entry->id, true );
309 309
                 }
310 310
             }
311 311
         }
312 312
     }
313 313
 
314 314
 	public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
315
-        if ( ! isset($args['old_id']) || empty($args['old_id']) ) {
315
+        if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
316 316
             // continue if we know which actions to copy
317 317
             return;
318 318
         }
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	public function register( $action_class ) {
349
-		$this->actions[ $action_class ] = new $action_class();
349
+		$this->actions[$action_class] = new $action_class();
350 350
 	}
351 351
 
352 352
 	public function unregister( $action_class ) {
353
-		if ( isset( $this->actions[ $action_class ] ) ) {
354
-			unset($this->actions[ $action_class ]);
353
+		if ( isset( $this->actions[$action_class] ) ) {
354
+			unset( $this->actions[$action_class] );
355 355
 		}
356 356
 	}
357 357
 
358 358
 	public function _register_actions() {
359
-		$keys = array_keys($this->actions);
359
+		$keys = array_keys( $this->actions );
360 360
 
361 361
 		foreach ( $keys as $key ) {
362 362
 			// don't register new action if old action with the same id is already registered
363
-			if ( ! isset( $this->actions[ $key ] ) ) {
364
-			    $this->actions[ $key ]->_register();
363
+			if ( ! isset( $this->actions[$key] ) ) {
364
+			    $this->actions[$key]->_register();
365 365
 			}
366 366
 		}
367 367
 	}
Please login to merge, or discard this patch.
classes/controllers/FrmAppController.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			$tip = FrmTipsHelper::get_banner_tip();
134 134
 ?>
135 135
 <div class="update-nag frm-update-to-pro">
136
-	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip='. absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
136
+	<?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a>
137 137
 </div>
138 138
 <?php
139 139
 		}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     public static function uninstall() {
384
-		FrmAppHelper::permission_check('administrator');
384
+		FrmAppHelper::permission_check( 'administrator' );
385 385
         check_ajax_referer( 'frm_ajax', 'nonce' );
386 386
 
387 387
 		$frmdb = new FrmDb();
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     }
417 417
 
418 418
     public static function deauthorize() {
419
-		FrmAppHelper::permission_check('frm_change_settings');
419
+		FrmAppHelper::permission_check( 'frm_change_settings' );
420 420
         check_ajax_referer( 'frm_ajax', 'nonce' );
421 421
 
422 422
         delete_option( 'frmpro-credentials' );
Please login to merge, or discard this patch.
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@  discard block
 block discarded – undo
3 3
 class FrmAppController {
4 4
 
5 5
 	public static function menu() {
6
-        FrmAppHelper::maybe_add_permissions();
7
-        if ( ! current_user_can( 'frm_view_forms' ) ) {
8
-            return;
9
-        }
6
+		FrmAppHelper::maybe_add_permissions();
7
+		if ( ! current_user_can( 'frm_view_forms' ) ) {
8
+			return;
9
+		}
10 10
 
11 11
 		$menu_name = FrmAppHelper::get_menu_name();
12 12
 		add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
13
-    }
13
+	}
14 14
 
15 15
 	private static function get_menu_position() {
16 16
 		$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
@@ -19,39 +19,39 @@  discard block
 block discarded – undo
19 19
 		return $pos;
20 20
 	}
21 21
 
22
-    public static function load_wp_admin_style() {
23
-        FrmAppHelper::load_font_style();
24
-    }
22
+	public static function load_wp_admin_style() {
23
+		FrmAppHelper::load_font_style();
24
+	}
25 25
 
26 26
 	public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
27
-        global $pagenow, $frm_vars;
27
+		global $pagenow, $frm_vars;
28 28
 
29 29
 		$show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
30
-        if ( empty( $show_nav ) ) {
31
-            return;
32
-        }
30
+		if ( empty( $show_nav ) ) {
31
+			return;
32
+		}
33 33
 
34 34
 		$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
35 35
 		if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
36 36
 			$current_page = 'frm_display';
37 37
 		}
38 38
 
39
-        if ( $form ) {
39
+		if ( $form ) {
40 40
 			FrmForm::maybe_get_form( $form );
41 41
 
42
-            if ( is_object( $form ) ) {
43
-                $id = $form->id;
44
-            }
45
-        }
42
+			if ( is_object( $form ) ) {
43
+				$id = $form->id;
44
+			}
45
+		}
46 46
 
47
-        if ( ! isset( $id ) ) {
48
-            $form = $id = false;
49
-        }
47
+		if ( ! isset( $id ) ) {
48
+			$form = $id = false;
49
+		}
50 50
 
51 51
 		$nav_items = self::get_form_nav_items( $id );
52 52
 
53
-        include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
-    }
53
+		include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
54
+	}
55 55
 
56 56
 	private static function get_form_nav_items( $id ) {
57 57
 		$nav_items = array(
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
 		return $nav_items;
83 83
 	}
84 84
 
85
-    // Adds a settings link to the plugins page
86
-    public static function settings_link( $links ) {
85
+	// Adds a settings link to the plugins page
86
+	public static function settings_link( $links ) {
87 87
 		$settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
88
-        array_unshift( $links, $settings );
88
+		array_unshift( $links, $settings );
89 89
 
90
-        return $links;
91
-    }
90
+		return $links;
91
+	}
92 92
 
93
-    public static function pro_get_started_headline() {
93
+	public static function pro_get_started_headline() {
94 94
 		self::maybe_show_upgrade_bar();
95 95
 
96
-        // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
-        if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
-            return;
99
-        }
96
+		// Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
97
+		if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
98
+			return;
99
+		}
100 100
 
101 101
 		if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
102
-            FrmAppHelper::load_admin_wide_js();
102
+			FrmAppHelper::load_admin_wide_js();
103 103
 
104
-            // user is authorized, but running free version
105
-            $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
-        ?>
104
+			// user is authorized, but running free version
105
+			$inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/';
106
+		?>
107 107
 <div class="error" class="frm_previous_install">
108 108
 		<?php
109 109
 		echo wp_kses_post( apply_filters( 'frm_pro_update_msg',
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 		) ); ?>
116 116
 </div>
117 117
 <?php
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121 121
 	private static function maybe_show_upgrade_bar() {
122 122
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 	}
218 218
 
219
-    public static function admin_js() {
219
+	public static function admin_js() {
220 220
 		$version = FrmAppHelper::plugin_version();
221 221
 		FrmAppHelper::load_admin_wide_js( false );
222 222
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			'bootstrap_tooltip', 'bootstrap-multiselect',
228 228
 		), $version, true );
229 229
 		wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
230
-        wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
230
+		wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
231 231
 
232 232
 		// load multselect js
233 233
 		wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true );
@@ -238,78 +238,78 @@  discard block
 block discarded – undo
238 238
 		global $pagenow;
239 239
 		if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
240 240
 
241
-            wp_enqueue_script( 'admin-widgets' );
242
-            wp_enqueue_style( 'widgets' );
243
-            wp_enqueue_script( 'formidable' );
244
-            wp_enqueue_script( 'formidable_admin' );
241
+			wp_enqueue_script( 'admin-widgets' );
242
+			wp_enqueue_style( 'widgets' );
243
+			wp_enqueue_script( 'formidable' );
244
+			wp_enqueue_script( 'formidable_admin' );
245 245
 			FrmAppHelper::localize_script( 'admin' );
246 246
 
247
-            wp_enqueue_style( 'formidable-admin' );
248
-            add_thickbox();
247
+			wp_enqueue_style( 'formidable-admin' );
248
+			add_thickbox();
249 249
 
250
-            wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
250
+			wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' );
251 251
 
252
-        } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
253
-            if ( isset( $_REQUEST['post_type'] ) ) {
254
-                $post_type = sanitize_title( $_REQUEST['post_type'] );
252
+		} else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) {
253
+			if ( isset( $_REQUEST['post_type'] ) ) {
254
+				$post_type = sanitize_title( $_REQUEST['post_type'] );
255 255
 			} else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
256 256
 				$post = get_post( absint( $_REQUEST['post'] ) );
257
-                if ( ! $post ) {
258
-                    return;
259
-                }
260
-                $post_type = $post->post_type;
261
-            } else {
262
-                return;
263
-            }
264
-
265
-            if ( $post_type == 'frm_display' ) {
266
-                wp_enqueue_script( 'jquery-ui-draggable' );
267
-                wp_enqueue_script( 'formidable_admin' );
268
-                wp_enqueue_style( 'formidable-admin' );
257
+				if ( ! $post ) {
258
+					return;
259
+				}
260
+				$post_type = $post->post_type;
261
+			} else {
262
+				return;
263
+			}
264
+
265
+			if ( $post_type == 'frm_display' ) {
266
+				wp_enqueue_script( 'jquery-ui-draggable' );
267
+				wp_enqueue_script( 'formidable_admin' );
268
+				wp_enqueue_style( 'formidable-admin' );
269 269
 				FrmAppHelper::localize_script( 'admin' );
270
-            }
271
-        } else if ( $pagenow == 'widgets.php' ) {
272
-            FrmAppHelper::load_admin_wide_js();
273
-        }
274
-    }
275
-
276
-    public static function wp_admin_body_class( $classes ) {
277
-        global $wp_version;
278
-        //we need this class everywhere in the admin for the menu
279
-        if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
280
-            $classes .= ' frm_38_trigger';
281
-        }
282
-
283
-        return $classes;
284
-    }
285
-
286
-    public static function load_lang() {
287
-        load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
288
-    }
289
-
290
-    /**
291
-     * Filter shortcodes in text widgets
292
-     */
293
-    public static function widget_text_filter( $content ) {
294
-    	$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
295
-    	return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
296
-    }
297
-
298
-    public static function widget_text_filter_callback( $matches ) {
299
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
300
-        return FrmAppHelper::widget_text_filter_callback( $matches );
301
-    }
302
-
303
-    public static function front_head() {
304
-        if ( is_multisite() ) {
305
-            $old_db_version = get_option( 'frm_db_version' );
306
-            $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
307
-            if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
308
-                ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
309
-                self::install( $old_db_version );
310
-            }
311
-        }
312
-    }
270
+			}
271
+		} else if ( $pagenow == 'widgets.php' ) {
272
+			FrmAppHelper::load_admin_wide_js();
273
+		}
274
+	}
275
+
276
+	public static function wp_admin_body_class( $classes ) {
277
+		global $wp_version;
278
+		//we need this class everywhere in the admin for the menu
279
+		if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
280
+			$classes .= ' frm_38_trigger';
281
+		}
282
+
283
+		return $classes;
284
+	}
285
+
286
+	public static function load_lang() {
287
+		load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
288
+	}
289
+
290
+	/**
291
+	 * Filter shortcodes in text widgets
292
+	 */
293
+	public static function widget_text_filter( $content ) {
294
+		$regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/';
295
+		return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
296
+	}
297
+
298
+	public static function widget_text_filter_callback( $matches ) {
299
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
300
+		return FrmAppHelper::widget_text_filter_callback( $matches );
301
+	}
302
+
303
+	public static function front_head() {
304
+		if ( is_multisite() ) {
305
+			$old_db_version = get_option( 'frm_db_version' );
306
+			$pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
307
+			if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
308
+				( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
309
+				self::install( $old_db_version );
310
+			}
311
+		}
312
+	}
313 313
 
314 314
 	public static function localize_script( $location ) {
315 315
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
@@ -369,20 +369,20 @@  discard block
 block discarded – undo
369 369
 		wp_die();
370 370
 	}
371 371
 
372
-    public static function activation_install() {
373
-        FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
374
-        FrmFormActionsController::actions_init();
375
-        self::install();
376
-    }
372
+	public static function activation_install() {
373
+		FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
374
+		FrmFormActionsController::actions_init();
375
+		self::install();
376
+	}
377 377
 
378
-    public static function install( $old_db_version = false ) {
379
-        $frmdb = new FrmDb();
380
-        $frmdb->upgrade( $old_db_version );
381
-    }
378
+	public static function install( $old_db_version = false ) {
379
+		$frmdb = new FrmDb();
380
+		$frmdb->upgrade( $old_db_version );
381
+	}
382 382
 
383
-    public static function uninstall() {
383
+	public static function uninstall() {
384 384
 		FrmAppHelper::permission_check('administrator');
385
-        check_ajax_referer( 'frm_ajax', 'nonce' );
385
+		check_ajax_referer( 'frm_ajax', 'nonce' );
386 386
 
387 387
 		$frmdb = new FrmDb();
388 388
 		$frmdb->uninstall();
@@ -391,48 +391,48 @@  discard block
 block discarded – undo
391 391
 		deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
392 392
 		echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
393 393
 
394
-        wp_die();
395
-    }
394
+		wp_die();
395
+	}
396 396
 
397
-    public static function drop_tables( $tables ) {
398
-        global $wpdb;
399
-        $tables[] = $wpdb->prefix . 'frm_fields';
400
-        $tables[] = $wpdb->prefix . 'frm_forms';
401
-        $tables[] = $wpdb->prefix . 'frm_items';
402
-        $tables[] = $wpdb->prefix . 'frm_item_metas';
403
-        return $tables;
404
-    }
397
+	public static function drop_tables( $tables ) {
398
+		global $wpdb;
399
+		$tables[] = $wpdb->prefix . 'frm_fields';
400
+		$tables[] = $wpdb->prefix . 'frm_forms';
401
+		$tables[] = $wpdb->prefix . 'frm_items';
402
+		$tables[] = $wpdb->prefix . 'frm_item_metas';
403
+		return $tables;
404
+	}
405 405
 
406
-    // Routes for wordpress pages -- we're just replacing content here folks.
407
-    public static function page_route( $content ) {
408
-        global $post;
406
+	// Routes for wordpress pages -- we're just replacing content here folks.
407
+	public static function page_route( $content ) {
408
+		global $post;
409 409
 
410
-        $frm_settings = FrmAppHelper::get_settings();
411
-        if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
412
-            $content = FrmFormsController::page_preview();
413
-        }
410
+		$frm_settings = FrmAppHelper::get_settings();
411
+		if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) {
412
+			$content = FrmFormsController::page_preview();
413
+		}
414 414
 
415
-        return $content;
416
-    }
415
+		return $content;
416
+	}
417 417
 
418
-    public static function deauthorize() {
418
+	public static function deauthorize() {
419 419
 		FrmAppHelper::permission_check('frm_change_settings');
420
-        check_ajax_referer( 'frm_ajax', 'nonce' );
421
-
422
-        delete_option( 'frmpro-credentials' );
423
-        delete_option( 'frmpro-authorized' );
424
-        delete_site_option( 'frmpro-credentials' );
425
-        delete_site_option( 'frmpro-authorized' );
426
-        wp_die();
427
-    }
428
-
429
-    public static function get_form_shortcode( $atts ) {
430
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
431
-        return FrmFormsController::get_form_shortcode( $atts );
432
-    }
433
-
434
-    public static function get_postbox_class() {
435
-        _deprecated_function( __FUNCTION__, '2.0' );
436
-        return 'postbox-container';
437
-    }
420
+		check_ajax_referer( 'frm_ajax', 'nonce' );
421
+
422
+		delete_option( 'frmpro-credentials' );
423
+		delete_option( 'frmpro-authorized' );
424
+		delete_site_option( 'frmpro-credentials' );
425
+		delete_site_option( 'frmpro-authorized' );
426
+		wp_die();
427
+	}
428
+
429
+	public static function get_form_shortcode( $atts ) {
430
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
431
+		return FrmFormsController::get_form_shortcode( $atts );
432
+	}
433
+
434
+	public static function get_postbox_class() {
435
+		_deprecated_function( __FUNCTION__, '2.0' );
436
+		return 'postbox-container';
437
+	}
438 438
 }
Please login to merge, or discard this patch.
classes/helpers/FrmTipsHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -181,13 +181,13 @@
 block discarded – undo
181 181
 			),
182 182
 		);
183 183
 		$random = rand( 0, count( $tips ) - 1 );
184
-		$tip = $tips[ $random ];
184
+		$tip = $tips[$random];
185 185
 		$tip['num'] = $random;
186 186
 		return $tip;
187 187
 	}
188 188
 
189 189
 	public static function get_random_tip( $tips ) {
190 190
 		$random = rand( 0, count( $tips ) - 1 );
191
-		return $tips[ $random ];
191
+		return $tips[$random];
192 192
 	}
193 193
 }
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -2,201 +2,201 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars, $wpdb;
68
+		global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
71
+		$columns[ $form_id .'_id' ] = 'ID';
72 72
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74
-        if ( ! $form_id ) {
75
-            return $columns;
76
-        }
74
+		if ( ! $form_id ) {
75
+			return $columns;
76
+		}
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79 79
 
80
-        foreach ( $form_cols as $form_col ) {
80
+		foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
-                continue;
83
-            }
82
+				continue;
83
+			}
84 84
 
85
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86 86
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87 87
 
88
-                if ( $sub_form_cols ) {
89
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
88
+				if ( $sub_form_cols ) {
89
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
92
-                            continue;
93
-                        }
91
+							unset( $sub_form_cols[ $k ] );
92
+							continue;
93
+						}
94 94
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
96
-                    }
97
-                }
98
-                unset($sub_form_cols);
99
-            } else {
100
-                $col_id = $form_col->field_key;
101
-                if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
103
-                }
104
-
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
111
-
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
115
-
116
-        $frm_vars['cols'] = $columns;
95
+						unset($sub_form_col);
96
+					}
97
+				}
98
+				unset($sub_form_cols);
99
+			} else {
100
+				$col_id = $form_col->field_key;
101
+				if ( $form_col->form_id != $form_id ) {
102
+					$col_id .= '-_-form'. $form_col->form_id;
103
+				}
104
+
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
+					$columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
+				}
108
+				$columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
+			}
110
+		}
111
+
112
+		$columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
+		$columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
+		$columns[ $form_id .'_ip' ] = 'IP';
115
+
116
+		$frm_vars['cols'] = $columns;
117 117
 
118 118
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
119 119
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
120 120
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
121
-        }
121
+		}
122 122
 
123
-        return $columns;
124
-    }
123
+		return $columns;
124
+	}
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128 128
 		$this_page_name = 'manage' .  sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130
-            return $check;
131
-        }
130
+			return $check;
131
+		}
132 132
 
133 133
 		if ( empty( $prev_value ) ) {
134 134
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
135 135
 		}
136 136
 
137
-        global $frm_vars;
138
-        //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+		global $frm_vars;
138
+		//add a check so we don't create a loop
139
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141
-        return $check;
142
-    }
141
+		return $check;
142
+	}
143 143
 
144
-    //add hidden columns back from other forms
144
+	//add hidden columns back from other forms
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148 148
 		$this_page_name = 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150
-            return;
151
-        }
152
-
153
-        global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
-            return; //don't continue if there's no previous value
156
-        }
157
-
158
-        foreach ( $meta_value as $mk => $mv ) {
159
-            //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
162
-            }
163
-        }
164
-
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
167
-        $cur_form_prefix = $cur_form_prefix[0];
168
-        $save = false;
169
-
170
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
150
+			return;
151
+		}
152
+
153
+		global $frm_vars;
154
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
+			return; //don't continue if there's no previous value
156
+		}
157
+
158
+		foreach ( $meta_value as $mk => $mv ) {
159
+			//remove blank values
160
+			if ( empty( $mv )  ) {
161
+				unset( $meta_value[ $mk ] );
162
+			}
163
+		}
164
+
165
+		$cur_form_prefix = reset($meta_value);
166
+		$cur_form_prefix = explode('_', $cur_form_prefix);
167
+		$cur_form_prefix = $cur_form_prefix[0];
168
+		$save = false;
169
+
170
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
171 171
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
172
-                //don't add blank cols or process included cols
173
-                continue;
174
-            }
172
+				//don't add blank cols or process included cols
173
+				continue;
174
+			}
175 175
 
176 176
 			$form_prefix = explode( '_', $prev_hidden );
177
-            $form_prefix = $form_prefix[0];
178
-            if ( $form_prefix == $cur_form_prefix ) {
179
-                //don't add back columns that are meant to be hidden
180
-                continue;
181
-            }
177
+			$form_prefix = $form_prefix[0];
178
+			if ( $form_prefix == $cur_form_prefix ) {
179
+				//don't add back columns that are meant to be hidden
180
+				continue;
181
+			}
182 182
 
183
-            $meta_value[] = $prev_hidden;
184
-            $save = true;
185
-            unset($form_prefix);
186
-        }
183
+			$meta_value[] = $prev_hidden;
184
+			$save = true;
185
+			unset($form_prefix);
186
+		}
187 187
 
188 188
 		if ( $save ) {
189
-            $user = wp_get_current_user();
189
+			$user = wp_get_current_user();
190 190
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
191
-        }
192
-    }
191
+		}
192
+	}
193 193
 
194 194
 	public static function save_per_page( $save, $option, $value ) {
195
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
-            $save = (int) $value;
197
-        }
198
-        return $save;
199
-    }
195
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
+			$save = (int) $value;
197
+		}
198
+		return $save;
199
+	}
200 200
 
201 201
 	public static function sortable_columns() {
202 202
 		$form_id = FrmForm::get_current_form_id();
@@ -222,226 +222,226 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public static function hidden_columns( $result ) {
225
-        global $frm_vars;
225
+		global $frm_vars;
226 226
 
227 227
 		$form_id = FrmForm::get_current_form_id();
228 228
 
229
-        $return = false;
230
-        foreach ( (array) $result as $r ) {
231
-            if ( ! empty( $r ) ) {
232
-                $form_prefix = explode( '_', $r );
233
-                $form_prefix = $form_prefix[0];
229
+		$return = false;
230
+		foreach ( (array) $result as $r ) {
231
+			if ( ! empty( $r ) ) {
232
+				$form_prefix = explode( '_', $r );
233
+				$form_prefix = $form_prefix[0];
234 234
 
235
-                if ( (int) $form_prefix == (int) $form_id ) {
236
-                    $return = true;
237
-                    break;
238
-                }
235
+				if ( (int) $form_prefix == (int) $form_id ) {
236
+					$return = true;
237
+					break;
238
+				}
239 239
 
240
-                unset($form_prefix);
241
-            }
242
-        }
240
+				unset($form_prefix);
241
+			}
242
+		}
243 243
 
244
-        if ( $return ) {
244
+		if ( $return ) {
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
-        $max_columns = 8;
250
-        if ( $i <= $max_columns ) {
248
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
+		$max_columns = 8;
250
+		if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254
-        global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
-        }
254
+		global $frm_vars;
255
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
+		}
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
-            $result = $frm_vars['current_form']->options['hidden_cols'];
261
-        } else {
262
-            $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
259
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
+			$result = $frm_vars['current_form']->options['hidden_cols'];
261
+		} else {
262
+			$cols = $frm_vars['cols'];
263
+			$cols = array_reverse($cols, true);
264 264
 
265
-            $result[] = $form_id .'_id';
266
-            $i--;
265
+			$result[] = $form_id .'_id';
266
+			$i--;
267 267
 
268
-            $result[] = $form_id .'_item_key';
269
-            $i--;
268
+			$result[] = $form_id .'_item_key';
269
+			$i--;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272
-                if ( $i > $max_columns ) {
272
+				if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275
-                //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
278
-            }
279
-        }
275
+				//remove some columns by default
276
+				$i--;
277
+				unset($col_key, $col);
278
+			}
279
+		}
280 280
 
281
-        return $result;
282
-    }
281
+		return $result;
282
+	}
283 283
 
284 284
 	public static function display_list( $message = '', $errors = array() ) {
285
-        global $wpdb, $frm_vars;
285
+		global $wpdb, $frm_vars;
286 286
 
287 287
 		$form = FrmForm::get_current_form();
288 288
 		$params = FrmForm::get_admin_params( $form );
289 289
 
290
-        if ( $form ) {
291
-            $params['form'] = $form->id;
292
-            $frm_vars['current_form'] = $form;
290
+		if ( $form ) {
291
+			$params['form'] = $form->id;
292
+			$frm_vars['current_form'] = $form;
293 293
 
294
-	        if ( 'trash' == $form->status ) {
295
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
-	            unset( $time_to_delete, $delete_timestamp );
299
-	        }
294
+			if ( 'trash' == $form->status ) {
295
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
+				unset( $time_to_delete, $delete_timestamp );
299
+			}
300 300
 		}
301 301
 
302
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
302
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
303 303
 
304
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
304
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
305 305
 
306
-        $pagenum = $wp_list_table->get_pagenum();
306
+		$pagenum = $wp_list_table->get_pagenum();
307 307
 
308
-        $wp_list_table->prepare_items();
308
+		$wp_list_table->prepare_items();
309 309
 
310
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
310
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313
-            if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
315
-            } else {
316
-                wp_redirect( esc_url_raw( $url ) );
317
-            }
318
-            die();
319
-        }
320
-
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
322
-            $message = __( 'Your import is complete', 'formidable' );
323
-        }
324
-
325
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
326
-    }
327
-
328
-    /* Back End CRUD */
313
+			if ( headers_sent() ) {
314
+				echo FrmAppHelper::js_redirect($url);
315
+			} else {
316
+				wp_redirect( esc_url_raw( $url ) );
317
+			}
318
+			die();
319
+		}
320
+
321
+		if ( empty($message) && isset($_GET['import-message']) ) {
322
+			$message = __( 'Your import is complete', 'formidable' );
323
+		}
324
+
325
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
326
+	}
327
+
328
+	/* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+		FrmAppHelper::permission_check('frm_view_entries');
331 331
 
332
-        if ( ! $id ) {
332
+		if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
334 334
 
335
-            if ( ! $id ) {
335
+			if ( ! $id ) {
336 336
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
337
-            }
338
-        }
337
+			}
338
+		}
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+		$entry = FrmEntry::getOne($id, true);
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+		$data = maybe_unserialize($entry->description);
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
346 346
 
347 347
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
348
-        $to_emails = array();
348
+		$to_emails = array();
349 349
 
350
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
351
-    }
350
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
351
+	}
352 352
 
353
-    public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
353
+	public static function destroy() {
354
+		FrmAppHelper::permission_check('frm_delete_entries');
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
-            //unlink entry from post
360
-            global $wpdb;
358
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
359
+			//unlink entry from post
360
+			global $wpdb;
361 361
 			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362
-        }
362
+		}
363 363
 
364
-        $message = '';
365
-        if ( FrmEntry::destroy( $params['id'] ) ) {
366
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
-        }
364
+		$message = '';
365
+		if ( FrmEntry::destroy( $params['id'] ) ) {
366
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
367
+		}
368 368
 
369
-        self::display_list( $message );
370
-    }
369
+		self::display_list( $message );
370
+	}
371 371
 
372
-    public static function destroy_all() {
373
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
-            $frm_settings = FrmAppHelper::get_settings();
375
-            wp_die( $frm_settings->admin_permission );
376
-        }
372
+	public static function destroy_all() {
373
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
374
+			$frm_settings = FrmAppHelper::get_settings();
375
+			wp_die( $frm_settings->admin_permission );
376
+		}
377 377
 
378
-        global $wpdb;
378
+		global $wpdb;
379 379
 		$params = FrmForm::get_admin_params();
380
-        $message = '';
381
-        $errors = array();
382
-        $form_id = (int) $params['form'];
380
+		$message = '';
381
+		$errors = array();
382
+		$form_id = (int) $params['form'];
383 383
 
384
-        if ( $form_id ) {
385
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
384
+		if ( $form_id ) {
385
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
386 386
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
387 387
 
388
-            if ( $action ) {
389
-                // this action takes a while, so only trigger it if there are posts to delete
390
-                foreach ( $entry_ids as $entry_id ) {
391
-                    do_action( 'frm_before_destroy_entry', $entry_id );
392
-                    unset( $entry_id );
393
-                }
394
-            }
395
-
396
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
-            if ( $results ) {
399
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
-            }
401
-        } else {
402
-            $errors = __( 'No entries were specified', 'formidable' );
403
-        }
404
-
405
-        self::display_list( $message, $errors );
406
-    }
407
-
408
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
-        return FrmFormsController::show_form( $id, $key, $title, $description );
411
-    }
412
-
413
-    public static function get_form( $filename, $form, $title, $description ) {
414
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
-        return FrmFormsController::get_form( $form, $title, $description );
416
-    }
417
-
418
-    public static function process_entry( $errors = '', $ajax = false ) {
388
+			if ( $action ) {
389
+				// this action takes a while, so only trigger it if there are posts to delete
390
+				foreach ( $entry_ids as $entry_id ) {
391
+					do_action( 'frm_before_destroy_entry', $entry_id );
392
+					unset( $entry_id );
393
+				}
394
+			}
395
+
396
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
397
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
398
+			if ( $results ) {
399
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
400
+			}
401
+		} else {
402
+			$errors = __( 'No entries were specified', 'formidable' );
403
+		}
404
+
405
+		self::display_list( $message, $errors );
406
+	}
407
+
408
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
409
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
410
+		return FrmFormsController::show_form( $id, $key, $title, $description );
411
+	}
412
+
413
+	public static function get_form( $filename, $form, $title, $description ) {
414
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
415
+		return FrmFormsController::get_form( $form, $title, $description );
416
+	}
417
+
418
+	public static function process_entry( $errors = '', $ajax = false ) {
419 419
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
420 420
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
421
-            return;
422
-        }
421
+			return;
422
+		}
423 423
 
424
-        global $frm_vars;
424
+		global $frm_vars;
425 425
 
426 426
 		$form = FrmForm::getOne( $form_id );
427
-        if ( ! $form ) {
428
-            return;
429
-        }
427
+		if ( ! $form ) {
428
+			return;
429
+		}
430 430
 
431 431
 		$params = FrmForm::get_params( $form );
432 432
 
433
-        if ( ! isset( $frm_vars['form_params'] ) ) {
434
-            $frm_vars['form_params'] = array();
435
-        }
433
+		if ( ! isset( $frm_vars['form_params'] ) ) {
434
+			$frm_vars['form_params'] = array();
435
+		}
436 436
 		$frm_vars['form_params'][ $form->id ] = $params;
437 437
 
438 438
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
439
-            return;
440
-        }
439
+			return;
440
+		}
441 441
 
442
-        if ( $errors == '' ) {
442
+		if ( $errors == '' ) {
443 443
 			$errors = FrmEntryValidate::validate( $_POST );
444
-        }
444
+		}
445 445
 
446 446
 		/**
447 447
 		 * Use this filter to add trigger actions and add errors after
@@ -452,102 +452,102 @@  discard block
 block discarded – undo
452 452
 
453 453
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
454 454
 
455
-        if ( empty( $errors ) ) {
455
+		if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457
-            if ( $params['action'] == 'create' ) {
457
+			if ( $params['action'] == 'create' ) {
458 458
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459 459
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
460
-                }
461
-            }
460
+				}
461
+			}
462 462
 
463
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
463
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
464 464
 			unset( $_POST['frm_skip_cookie'] );
465
-        }
466
-    }
467
-
468
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
-        self::_delete_entry( $atts['id'], $form );
470
-        return $url;
471
-    }
472
-
473
-    //Delete entry if not redirected
474
-    public static function delete_entry_after_save( $atts ) {
475
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
-    }
477
-
478
-    private static function _delete_entry( $entry_id, $form ) {
479
-        if ( ! $form ) {
480
-            return;
481
-        }
482
-
483
-        $form->options = maybe_unserialize( $form->options );
484
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
-            FrmEntry::destroy( $entry_id );
486
-        }
487
-    }
465
+		}
466
+	}
467
+
468
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
469
+		self::_delete_entry( $atts['id'], $form );
470
+		return $url;
471
+	}
472
+
473
+	//Delete entry if not redirected
474
+	public static function delete_entry_after_save( $atts ) {
475
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
476
+	}
477
+
478
+	private static function _delete_entry( $entry_id, $form ) {
479
+		if ( ! $form ) {
480
+			return;
481
+		}
482
+
483
+		$form->options = maybe_unserialize( $form->options );
484
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
485
+			FrmEntry::destroy( $entry_id );
486
+		}
487
+	}
488 488
 
489 489
 	public static function show_entry_shortcode( $atts ) {
490 490
 		return FrmEntryFormat::show_entry( $atts );
491 491
 	}
492 492
 
493
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
495
-        if ( ! $field ) {
496
-            return $value;
497
-        }
493
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
+		$field = FrmField::getOne($meta->field_id);
495
+		if ( ! $field ) {
496
+			return $value;
497
+		}
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
500
-        return $value;
501
-    }
499
+		$value = self::filter_display_value($value, $field, $atts);
500
+		return $value;
501
+	}
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+		$plain_text = add_filter('frm_plain_text_email', true);
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
-            return $value;
509
-        }
507
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
508
+			return $value;
509
+		}
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
512
-    }
511
+		return self::filter_display_value($value, $field, $atts);
512
+	}
513 513
 
514
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
514
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
515
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517
-            return $value;
518
-        }
519
-
520
-        $f_values = $f_labels = array();
521
-
522
-        foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
524
-                continue;
525
-            }
526
-
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
-            }
532
-            unset($opt_key, $opt);
533
-        }
534
-
535
-        if ( ! empty($f_values) ) {
536
-            foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
541
-                    } else {
542
-                        $value = $f_labels[ $opt ];
543
-                    }
544
-                }
545
-                unset($v_key, $val);
546
-            }
547
-        }
548
-
549
-        return $value;
550
-    }
517
+			return $value;
518
+		}
519
+
520
+		$f_values = $f_labels = array();
521
+
522
+		foreach ( $field->options as $opt_key => $opt ) {
523
+			if ( ! is_array($opt) ) {
524
+				continue;
525
+			}
526
+
527
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
531
+			}
532
+			unset($opt_key, $opt);
533
+		}
534
+
535
+		if ( ! empty($f_values) ) {
536
+			foreach ( (array) $value as $v_key => $val ) {
537
+				if ( in_array($val, $f_values) ) {
538
+					$opt = array_search($val, $f_values);
539
+					if ( is_array($value) ) {
540
+						$value[ $v_key ] = $f_labels[ $opt ];
541
+					} else {
542
+						$value = $f_labels[ $opt ];
543
+					}
544
+				}
545
+				unset($v_key, $val);
546
+			}
547
+		}
548
+
549
+		return $value;
550
+	}
551 551
 
552 552
 	public static function get_params( $form = null ) {
553 553
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+		$data = maybe_unserialize($entry->description);
559
+		$date_format = get_option('date_format');
560
+		$time_format = get_option('time_format');
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
564 564
 
565
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
566
-    }
565
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
566
+	}
567 567
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | '. __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
         $screen->add_help_tab( array(
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55
-			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) .'</p> <p>'. esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
55
+			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61
-			'<p><a href="'. esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
61
+			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62 62
     	);
63 63
 
64 64
         return $help;
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
         global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-        $columns[ $form_id .'_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+        $columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
         if ( ! $form_id ) {
75 75
             return $columns;
76 76
         }
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+        $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
79 79
 
80 80
         foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
                 if ( $sub_form_cols ) {
89 89
                     foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
91
+                            unset( $sub_form_cols[$k] );
92 92
                             continue;
93 93
                         }
94
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
94
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
+                        unset( $sub_form_col );
96 96
                     }
97 97
                 }
98
-                unset($sub_form_cols);
98
+                unset( $sub_form_cols );
99 99
             } else {
100 100
                 $col_id = $form_col->field_key;
101 101
                 if ( $form_col->form_id != $form_id ) {
102
-                    $col_id .= '-_-form'. $form_col->form_id;
102
+                    $col_id .= '-_-form' . $form_col->form_id;
103 103
                 }
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106
-                    $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
105
+                if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
106
+                    $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
107 107
                 }
108
-                $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+                $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
109 109
             }
110 110
         }
111 111
 
112
-        $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
113
-        $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
114
-        $columns[ $form_id .'_ip' ] = 'IP';
112
+        $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
113
+        $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
114
+        $columns[$form_id . '_ip'] = 'IP';
115 115
 
116 116
         $frm_vars['cols'] = $columns;
117 117
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128
-		$this_page_name = 'manage' .  sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
128
+		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130 130
             return $check;
131 131
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         global $frm_vars;
138 138
         //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
139
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141 141
         return $check;
142 142
     }
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148
-		$this_page_name = 'manage'.  $sanitized .'_page_formidable-entriescolumnshidden';
148
+		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150 150
             return;
151 151
         }
152 152
 
153 153
         global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
154
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
155 155
             return; //don't continue if there's no previous value
156 156
         }
157 157
 
158 158
         foreach ( $meta_value as $mk => $mv ) {
159 159
             //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
160
+            if ( empty( $mv ) ) {
161
+                unset( $meta_value[$mk] );
162 162
             }
163 163
         }
164 164
 
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
165
+        $cur_form_prefix = reset( $meta_value );
166
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
167 167
         $cur_form_prefix = $cur_form_prefix[0];
168 168
         $save = false;
169 169
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
             $meta_value[] = $prev_hidden;
184 184
             $save = true;
185
-            unset($form_prefix);
185
+            unset( $form_prefix );
186 186
         }
187 187
 
188 188
 		if ( $save ) {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		foreach ( $fields as $field ) {
215 215
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
216 216
 				// Can't sort on checkboxes because they are stored serialized, or post fields
217
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
217
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
218 218
 			}
219 219
 		}
220 220
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                     break;
238 238
                 }
239 239
 
240
-                unset($form_prefix);
240
+                unset( $form_prefix );
241 241
             }
242 242
         }
243 243
 
@@ -245,36 +245,36 @@  discard block
 block discarded – undo
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
248
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
249 249
         $max_columns = 8;
250 250
         if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254 254
         global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
255
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
256
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
257 257
         }
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
259
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) {
260 260
             $result = $frm_vars['current_form']->options['hidden_cols'];
261 261
         } else {
262 262
             $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
263
+            $cols = array_reverse( $cols, true );
264 264
 
265
-            $result[] = $form_id .'_id';
266
-            $i--;
265
+            $result[] = $form_id . '_id';
266
+            $i --;
267 267
 
268
-            $result[] = $form_id .'_item_key';
269
-            $i--;
268
+            $result[] = $form_id . '_item_key';
269
+            $i --;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272 272
                 if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275 275
                 //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
276
+                $i --;
277
+                unset( $col_key, $col );
278 278
             }
279 279
         }
280 280
 
@@ -311,23 +311,23 @@  discard block
 block discarded – undo
311 311
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313 313
             if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
314
+                echo FrmAppHelper::js_redirect( $url );
315 315
             } else {
316 316
                 wp_redirect( esc_url_raw( $url ) );
317 317
             }
318 318
             die();
319 319
         }
320 320
 
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
321
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
322 322
             $message = __( 'Your import is complete', 'formidable' );
323 323
         }
324 324
 
325
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
325
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326 326
     }
327 327
 
328 328
     /* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+        FrmAppHelper::permission_check( 'frm_view_entries' );
331 331
 
332 332
         if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
             }
338 338
         }
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+        $entry = FrmEntry::getOne( $id, true );
341 341
 
342
-        $data = maybe_unserialize($entry->description);
342
+        $data = maybe_unserialize( $entry->description );
343 343
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
344 344
 			$data = array( 'referrer' => $data );
345 345
 		}
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
348 348
         $to_emails = array();
349 349
 
350
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/show.php');
350
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
351 351
     }
352 352
 
353 353
     public static function destroy() {
354
-        FrmAppHelper::permission_check('frm_delete_entries');
354
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
355 355
 
356 356
 		$params = FrmForm::get_admin_params();
357 357
 
358
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
358
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
359 359
             //unlink entry from post
360 360
             global $wpdb;
361
-			$wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
361
+			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
362 362
         }
363 363
 
364 364
         $message = '';
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
         if ( ! isset( $frm_vars['form_params'] ) ) {
434 434
             $frm_vars['form_params'] = array();
435 435
         }
436
-		$frm_vars['form_params'][ $form->id ] = $params;
436
+		$frm_vars['form_params'][$form->id] = $params;
437 437
 
438
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
438
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
439 439
             return;
440 440
         }
441 441
 
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
 		 */
451 451
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
452 452
 
453
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
453
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
454 454
 
455 455
         if ( empty( $errors ) ) {
456 456
 			$_POST['frm_skip_cookie'] = 1;
457 457
             if ( $params['action'] == 'create' ) {
458
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
459
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
458
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
459
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
460 460
                 }
461 461
             }
462 462
 
@@ -491,28 +491,28 @@  discard block
 block discarded – undo
491 491
 	}
492 492
 
493 493
     public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
494
-        $field = FrmField::getOne($meta->field_id);
494
+        $field = FrmField::getOne( $meta->field_id );
495 495
         if ( ! $field ) {
496 496
             return $value;
497 497
         }
498 498
 
499
-        $value = self::filter_display_value($value, $field, $atts);
499
+        $value = self::filter_display_value( $value, $field, $atts );
500 500
         return $value;
501 501
     }
502 502
 
503 503
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
504
-        $plain_text = add_filter('frm_plain_text_email', true);
504
+        $plain_text = add_filter( 'frm_plain_text_email', true );
505 505
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
506 506
 
507
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
507
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
508 508
             return $value;
509 509
         }
510 510
 
511
-        return self::filter_display_value($value, $field, $atts);
511
+        return self::filter_display_value( $value, $field, $atts );
512 512
     }
513 513
 
514 514
     public static function &filter_display_value( $value, $field, $atts = array() ) {
515
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
515
+        $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false;
516 516
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
517 517
             return $value;
518 518
         }
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
         $f_values = $f_labels = array();
521 521
 
522 522
         foreach ( $field->options as $opt_key => $opt ) {
523
-            if ( ! is_array($opt) ) {
523
+            if ( ! is_array( $opt ) ) {
524 524
                 continue;
525 525
             }
526 526
 
527
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
528
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
529
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
530
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
527
+            $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
528
+            $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key];
529
+            if ( $f_labels[$opt_key] == $f_values[$opt_key] ) {
530
+                unset( $f_values[$opt_key], $f_labels[$opt_key] );
531 531
             }
532
-            unset($opt_key, $opt);
532
+            unset( $opt_key, $opt );
533 533
         }
534 534
 
535
-        if ( ! empty($f_values) ) {
535
+        if ( ! empty( $f_values ) ) {
536 536
             foreach ( (array) $value as $v_key => $val ) {
537
-                if ( in_array($val, $f_values) ) {
538
-                    $opt = array_search($val, $f_values);
539
-                    if ( is_array($value) ) {
540
-                        $value[ $v_key ] = $f_labels[ $opt ];
537
+                if ( in_array( $val, $f_values ) ) {
538
+                    $opt = array_search( $val, $f_values );
539
+                    if ( is_array( $value ) ) {
540
+                        $value[$v_key] = $f_labels[$opt];
541 541
                     } else {
542
-                        $value = $f_labels[ $opt ];
542
+                        $value = $f_labels[$opt];
543 543
                     }
544 544
                 }
545
-                unset($v_key, $val);
545
+                unset( $v_key, $val );
546 546
             }
547 547
         }
548 548
 
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function entry_sidebar( $entry ) {
558
-        $data = maybe_unserialize($entry->description);
559
-        $date_format = get_option('date_format');
560
-        $time_format = get_option('time_format');
558
+        $data = maybe_unserialize( $entry->description );
559
+        $date_format = get_option( 'date_format' );
560
+        $time_format = get_option( 'time_format' );
561 561
 		if ( isset( $data['browser'] ) ) {
562 562
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
563 563
 		}
564 564
 
565
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
565
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
566 566
     }
567 567
 }
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +818 added lines, -818 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( 'data' == $type ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( 'data' == $type ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
56
+		}
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+		$fields = array_merge($fields, FrmField::pro_field_selection());
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71
-        return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
-    }
71
+		return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
88
+			$values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
101
+		$values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+		$defaults = self::get_default_field_opts($values['type'], $record, true);
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
108
+		}
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
113
+		}
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+		$values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118
-    }
118
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
132
+		global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+		$form_id = (is_numeric($field)) ? $field : $field->form_id;
135 135
 
136
-        $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
136
+		$key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
137 137
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154
-        $values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
154
+		$values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158 158
 
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163 163
 
164
-    /**
165
-     * @since 2.0
166
-     */
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -180,21 +180,21 @@  discard block
 block discarded – undo
180 180
 		return $msg;
181 181
 	}
182 182
 
183
-    public static function get_form_fields( $form_id, $error = false ) {
184
-        $fields = FrmField::get_all_for_form($form_id);
185
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
186
-        return $fields;
187
-    }
183
+	public static function get_form_fields( $form_id, $error = false ) {
184
+		$fields = FrmField::get_all_for_form($form_id);
185
+		$fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
186
+		return $fields;
187
+	}
188 188
 
189 189
 	public static function get_default_html( $type = 'text' ) {
190 190
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
191 191
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
192
-            $for = '';
192
+			$for = '';
193 193
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
194
-                $for = 'for="field_[key]"';
195
-            }
194
+				$for = 'for="field_[key]"';
195
+			}
196 196
 
197
-            $default_html = <<<DEFAULT_HTML
197
+			$default_html = <<<DEFAULT_HTML
198 198
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
199 199
     <label $for class="frm_primary_label">[field_name]
200 200
         <span class="frm_required">[required_label]</span>
@@ -204,145 +204,145 @@  discard block
 block discarded – undo
204 204
     [if error]<div class="frm_error">[error]</div>[/if error]
205 205
 </div>
206 206
 DEFAULT_HTML;
207
-        } else {
207
+		} else {
208 208
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
209
-        }
209
+		}
210 210
 
211
-        return apply_filters('frm_custom_html', $default_html, $type);
212
-    }
211
+		return apply_filters('frm_custom_html', $default_html, $type);
212
+	}
213 213
 
214 214
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
215
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
-
217
-        $defaults = array(
218
-            'field_name'  => 'item_meta['. $field['id'] .']',
219
-            'field_id'    => $field['id'],
220
-            'field_plus_id' => '',
221
-            'section_id'    => '',
222
-        );
223
-        $args = wp_parse_args($args, $defaults);
224
-        $field_name = $args['field_name'];
225
-        $field_id = $args['field_id'];
226
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
227
-
228
-        if ( FrmField::is_multiple_select($field) ) {
229
-            $field_name .= '[]';
230
-        }
231
-
232
-        //replace [id]
233
-        $html = str_replace('[id]', $field_id, $html);
234
-
235
-        // Remove the for attribute for captcha
236
-        if ( $field['type'] == 'captcha' ) {
237
-            $html = str_replace(' for="field_[key]"', '', $html);
238
-        }
239
-
240
-        // set the label for
241
-        $html = str_replace('field_[key]', $html_id, $html);
242
-
243
-        //replace [key]
244
-        $html = str_replace('[key]', $field['field_key'], $html);
245
-
246
-        //replace [description] and [required_label] and [error]
215
+		$html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
216
+
217
+		$defaults = array(
218
+			'field_name'  => 'item_meta['. $field['id'] .']',
219
+			'field_id'    => $field['id'],
220
+			'field_plus_id' => '',
221
+			'section_id'    => '',
222
+		);
223
+		$args = wp_parse_args($args, $defaults);
224
+		$field_name = $args['field_name'];
225
+		$field_id = $args['field_id'];
226
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
227
+
228
+		if ( FrmField::is_multiple_select($field) ) {
229
+			$field_name .= '[]';
230
+		}
231
+
232
+		//replace [id]
233
+		$html = str_replace('[id]', $field_id, $html);
234
+
235
+		// Remove the for attribute for captcha
236
+		if ( $field['type'] == 'captcha' ) {
237
+			$html = str_replace(' for="field_[key]"', '', $html);
238
+		}
239
+
240
+		// set the label for
241
+		$html = str_replace('field_[key]', $html_id, $html);
242
+
243
+		//replace [key]
244
+		$html = str_replace('[key]', $field['field_key'], $html);
245
+
246
+		//replace [description] and [required_label] and [error]
247 247
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
248
-        if ( ! is_array( $errors ) ) {
249
-            $errors = array();
250
-        }
248
+		if ( ! is_array( $errors ) ) {
249
+			$errors = array();
250
+		}
251 251
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
252 252
 
253
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254
-        if ( $field['type'] == 'divider' ) {
255
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
256
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257
-            } else {
258
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
259
-            }
260
-        }
253
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254
+		if ( $field['type'] == 'divider' ) {
255
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
256
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257
+			} else {
258
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
259
+			}
260
+		}
261 261
 
262 262
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
263
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
264
-        }
263
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
264
+		}
265 265
 
266
-        //replace [required_class]
266
+		//replace [required_class]
267 267
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
268
-        $html = str_replace('[required_class]', $required_class, $html);
268
+		$html = str_replace('[required_class]', $required_class, $html);
269 269
 
270
-        //replace [label_position]
271
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
272
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
270
+		//replace [label_position]
271
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
272
+		$field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273 273
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
274 274
 
275
-        //replace [field_name]
276
-        $html = str_replace('[field_name]', $field['name'], $html);
275
+		//replace [field_name]
276
+		$html = str_replace('[field_name]', $field['name'], $html);
277 277
 
278
-        //replace [error_class]
278
+		//replace [error_class]
279 279
 		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
280 280
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
281 281
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
282 282
 			// there is no error_class shortcode to use for addign fields
283 283
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
284 284
 		}
285
-        $html = str_replace('[error_class]', $error_class, $html);
285
+		$html = str_replace('[error_class]', $error_class, $html);
286 286
 
287
-        //replace [entry_key]
288
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
-        $html = str_replace('[entry_key]', $entry_key, $html);
287
+		//replace [entry_key]
288
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
+		$html = str_replace('[entry_key]', $entry_key, $html);
290 290
 
291
-        //replace [input]
292
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
293
-        global $frm_vars;
294
-        $frm_settings = FrmAppHelper::get_settings();
291
+		//replace [input]
292
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
293
+		global $frm_vars;
294
+		$frm_settings = FrmAppHelper::get_settings();
295 295
 
296
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
297
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
296
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
297
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
298 298
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
299 299
 
300
-            $replace_with = '';
300
+			$replace_with = '';
301 301
 
302
-            if ( $tag == 'input' ) {
303
-                if ( isset($atts['opt']) ) {
304
-                    $atts['opt']--;
305
-                }
302
+			if ( $tag == 'input' ) {
303
+				if ( isset($atts['opt']) ) {
304
+					$atts['opt']--;
305
+				}
306 306
 
307
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
-                if ( isset($atts['class']) ) {
309
-                    unset($atts['class']);
310
-                }
307
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
+				if ( isset($atts['class']) ) {
309
+					unset($atts['class']);
310
+				}
311 311
 
312
-                $field['shortcodes'] = $atts;
313
-                ob_start();
314
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
315
-                $replace_with = ob_get_contents();
316
-                ob_end_clean();
317
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
319
-            }
312
+				$field['shortcodes'] = $atts;
313
+				ob_start();
314
+				include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
315
+				$replace_with = ob_get_contents();
316
+				ob_end_clean();
317
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
319
+			}
320 320
 
321
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
322
-        }
321
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
322
+		}
323 323
 
324 324
 		if ( $form ) {
325
-            $form = (array) $form;
325
+			$form = (array) $form;
326 326
 
327
-            //replace [form_key]
328
-            $html = str_replace('[form_key]', $form['form_key'], $html);
327
+			//replace [form_key]
328
+			$html = str_replace('[form_key]', $form['form_key'], $html);
329 329
 
330
-            //replace [form_name]
331
-            $html = str_replace('[form_name]', $form['name'], $html);
332
-        }
333
-        $html .= "\n";
330
+			//replace [form_name]
331
+			$html = str_replace('[form_name]', $form['name'], $html);
332
+		}
333
+		$html .= "\n";
334 334
 
335
-        //Return html if conf_field to prevent loop
336
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
337
-            return $html;
338
-        }
335
+		//Return html if conf_field to prevent loop
336
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
337
+			return $html;
338
+		}
339 339
 
340
-        //If field is in repeating section
341
-        if ( $args['section_id'] ) {
342
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
343
-        } else {
344
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
345
-        }
340
+		//If field is in repeating section
341
+		if ( $args['section_id'] ) {
342
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
343
+		} else {
344
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
345
+		}
346 346
 
347 347
 		self::remove_collapse_shortcode( $html );
348 348
 
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
 			$html = do_shortcode( $html );
351 351
 		}
352 352
 
353
-        return $html;
354
-    }
353
+		return $html;
354
+	}
355 355
 
356 356
 	/**
357
-	* Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
358
-	*
359
-	* @since 2.0
360
-	* @param $error_class string, pass by reference
361
-	* @param $field array
362
-	* @param $field_id int
363
-	* @param $html string
364
-	*/
357
+	 * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.)
358
+	 *
359
+	 * @since 2.0
360
+	 * @param $error_class string, pass by reference
361
+	 * @param $field array
362
+	 * @param $field_id int
363
+	 * @param $html string
364
+	 */
365 365
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
366 366
 		$error_class .= ' frm_'. $field['label'] .'_container';
367 367
 		if ( $field['id'] != $field_id ) {
@@ -425,46 +425,46 @@  discard block
 block discarded – undo
425 425
 		}
426 426
 	}
427 427
 
428
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429
-        if ( $no_vars ) {
430
-            $html = str_replace( '[if '. $code.']', '', $html );
431
-    	    $html = str_replace( '[/if '. $code.']', '', $html );
432
-        } else {
433
-            $html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
434
-        }
428
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429
+		if ( $no_vars ) {
430
+			$html = str_replace( '[if '. $code.']', '', $html );
431
+			$html = str_replace( '[/if '. $code.']', '', $html );
432
+		} else {
433
+			$html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
434
+		}
435 435
 
436
-        $html = str_replace( '['. $code .']', $replace_with, $html );
437
-    }
436
+		$html = str_replace( '['. $code .']', $replace_with, $html );
437
+	}
438 438
 
439 439
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
440 440
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
441
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
442
-            $args['conditional_check'] = true;
443
-        }
444
-
445
-        $prefix = '';
446
-        if ( $args['conditional_check'] ) {
447
-            if ( $args['conditional'] ) {
448
-                $prefix = 'if ';
449
-            } else if ( $args['foreach'] ) {
450
-                $prefix = 'foreach ';
451
-            }
452
-        }
453
-
454
-        $with_tags = $args['conditional_check'] ? 3 : 2;
455
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
-            $tag = str_replace(']', '', $tag);
458
-            $tags = explode(' ', $tag);
459
-            if ( is_array($tags) ) {
460
-                $tag = $tags[0];
461
-            }
462
-        } else {
463
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
464
-        }
465
-
466
-        return $tag;
467
-    }
441
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
442
+			$args['conditional_check'] = true;
443
+		}
444
+
445
+		$prefix = '';
446
+		if ( $args['conditional_check'] ) {
447
+			if ( $args['conditional'] ) {
448
+				$prefix = 'if ';
449
+			} else if ( $args['foreach'] ) {
450
+				$prefix = 'foreach ';
451
+			}
452
+		}
453
+
454
+		$with_tags = $args['conditional_check'] ? 3 : 2;
455
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
+			$tag = str_replace(']', '', $tag);
458
+			$tags = explode(' ', $tag);
459
+			if ( is_array($tags) ) {
460
+				$tag = $tags[0];
461
+			}
462
+		} else {
463
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
464
+		}
465
+
466
+		return $tag;
467
+	}
468 468
 
469 469
 	/**
470 470
 	 * Remove [collapse_this] if it's still included after all processing
@@ -477,128 +477,128 @@  discard block
 block discarded – undo
477 477
 	}
478 478
 
479 479
 	public static function display_recaptcha( $field ) {
480
-        $frm_settings = FrmAppHelper::get_settings();
481
-        $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
480
+		$frm_settings = FrmAppHelper::get_settings();
481
+		$lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
482 482
 
483
-        $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484
-        if ( $lang != 'en' ) {
485
-            $api_js_url .= '&hl='. $lang;
486
-        }
487
-        $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
483
+		$api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484
+		if ( $lang != 'en' ) {
485
+			$api_js_url .= '&hl='. $lang;
486
+		}
487
+		$api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
488 488
 
489
-        wp_register_script('recaptcha-api', $api_js_url, '', true);
490
-        wp_enqueue_script('recaptcha-api');
489
+		wp_register_script('recaptcha-api', $api_js_url, '', true);
490
+		wp_enqueue_script('recaptcha-api');
491 491
 
492 492
 ?>
493 493
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div>
494 494
 <?php
495
-    }
495
+	}
496 496
 
497 497
 	public static function show_single_option( $field ) {
498
-        $field_name = $field['name'];
499
-        $html_id = self::get_html_id($field);
500
-        foreach ( $field['options'] as $opt_key => $opt ) {
501
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
498
+		$field_name = $field['name'];
499
+		$html_id = self::get_html_id($field);
500
+		foreach ( $field['options'] as $opt_key => $opt ) {
501
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
503 503
 
504
-            // If this is an "Other" option, get the HTML for it
504
+			// If this is an "Other" option, get the HTML for it
505 505
 			if ( self::is_other_opt( $opt_key ) ) {
506
-                // Get string for Other text field, if needed
506
+				// Get string for Other text field, if needed
507 507
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
508
-                require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
509
-            } else {
510
-                require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
511
-            }
512
-        }
513
-    }
508
+				require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
509
+			} else {
510
+				require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
511
+			}
512
+		}
513
+	}
514 514
 
515 515
 	public static function dropdown_categories( $args ) {
516 516
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
517
-        $args = wp_parse_args($args, $defaults);
517
+		$args = wp_parse_args($args, $defaults);
518 518
 
519
-        if ( ! $args['field'] ) {
520
-            return;
521
-        }
519
+		if ( ! $args['field'] ) {
520
+			return;
521
+		}
522 522
 
523
-        if ( ! $args['name'] ) {
524
-            $args['name'] = 'item_meta['. $args['field']['id'] .']';
525
-        }
523
+		if ( ! $args['name'] ) {
524
+			$args['name'] = 'item_meta['. $args['field']['id'] .']';
525
+		}
526 526
 
527
-        $id = self::get_html_id($args['field']);
528
-        $class = $args['field']['type'];
527
+		$id = self::get_html_id($args['field']);
528
+		$class = $args['field']['type'];
529 529
 
530
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
530
+		$exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
+		$exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
532 532
 
533
-        if ( is_array($args['field']['value']) ) {
534
-            if ( ! empty($exclude) ) {
535
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
536
-            }
537
-            $selected = reset($args['field']['value']);
538
-        } else {
539
-            $selected = $args['field']['value'];
540
-        }
533
+		if ( is_array($args['field']['value']) ) {
534
+			if ( ! empty($exclude) ) {
535
+				$args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
536
+			}
537
+			$selected = reset($args['field']['value']);
538
+		} else {
539
+			$selected = $args['field']['value'];
540
+		}
541 541
 
542
-        $tax_atts = array(
543
-            'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
544
-            'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
545
-            'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546
-        );
542
+		$tax_atts = array(
543
+			'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'],
544
+			'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected,
545
+			'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546
+		);
547 547
 
548
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
548
+		$tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
549 549
 
550
-        if ( FrmAppHelper::pro_is_installed() ) {
551
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
553
-            if ( ! $tax_atts['taxonomy'] ) {
554
-                return;
555
-            }
550
+		if ( FrmAppHelper::pro_is_installed() ) {
551
+			$post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
+			$tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
553
+			if ( ! $tax_atts['taxonomy'] ) {
554
+				return;
555
+			}
556 556
 
557
-            // If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
559
-                $tax_atts['exclude_tree'] = $exclude;
560
-            }
561
-        }
557
+			// If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
+			if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
559
+				$tax_atts['exclude_tree'] = $exclude;
560
+			}
561
+		}
562 562
 
563
-        $dropdown = wp_dropdown_categories($tax_atts);
563
+		$dropdown = wp_dropdown_categories($tax_atts);
564 564
 
565
-        $add_html = FrmFieldsController::input_html($args['field'], false);
565
+		$add_html = FrmFieldsController::input_html($args['field'], false);
566 566
 
567
-        if ( FrmAppHelper::pro_is_installed() ) {
568
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
569
-        }
567
+		if ( FrmAppHelper::pro_is_installed() ) {
568
+			$add_html .= FrmProFieldsController::input_html($args['field'], false);
569
+		}
570 570
 
571 571
 		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) ."' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
572 572
 
573
-        if ( is_array($args['field']['value']) ) {
574
-            $skip = true;
575
-            foreach ( $args['field']['value'] as $v ) {
573
+		if ( is_array($args['field']['value']) ) {
574
+			$skip = true;
575
+			foreach ( $args['field']['value'] as $v ) {
576 576
 				if ( $skip ) {
577
-                    $skip = false;
578
-                    continue;
579
-                }
577
+					$skip = false;
578
+					continue;
579
+				}
580 580
 				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
-                unset($v);
582
-            }
583
-        }
581
+				unset($v);
582
+			}
583
+		}
584 584
 
585
-        return $dropdown;
586
-    }
585
+		return $dropdown;
586
+	}
587 587
 
588 588
 	public static function get_term_link( $tax_id ) {
589
-        $tax = get_taxonomy($tax_id);
590
-        if ( ! $tax ) {
591
-            return;
592
-        }
589
+		$tax = get_taxonomy($tax_id);
590
+		if ( ! $tax ) {
591
+			return;
592
+		}
593 593
 
594
-        $link = sprintf(
595
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
-            '<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
597
-        );
598
-        unset($tax);
594
+		$link = sprintf(
595
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
+			'<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
597
+		);
598
+		unset($tax);
599 599
 
600
-        return $link;
601
-    }
600
+		return $link;
601
+	}
602 602
 
603 603
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
604 604
 		// Remove white space from hide_opt
@@ -606,296 +606,296 @@  discard block
 block discarded – undo
606 606
 			$hide_opt = rtrim( $hide_opt );
607 607
 		}
608 608
 
609
-        if ( is_array($observed_value) ) {
610
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
611
-        }
612
-
613
-        $m = false;
614
-        if ( $cond == '==' ) {
615
-            $m = $observed_value == $hide_opt;
616
-        } else if ( $cond == '!=' ) {
617
-            $m = $observed_value != $hide_opt;
618
-        } else if ( $cond == '>' ) {
619
-            $m = $observed_value > $hide_opt;
620
-        } else if ( $cond == '<' ) {
621
-            $m = $observed_value < $hide_opt;
622
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
-            $m = stripos($observed_value, $hide_opt);
624
-            if ( $cond == 'not LIKE' ) {
625
-                $m = ( $m === false ) ? true : false;
626
-            } else {
627
-                $m = ( $m === false ) ? false : true;
628
-            }
629
-        }
630
-        return $m;
631
-    }
609
+		if ( is_array($observed_value) ) {
610
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
611
+		}
612
+
613
+		$m = false;
614
+		if ( $cond == '==' ) {
615
+			$m = $observed_value == $hide_opt;
616
+		} else if ( $cond == '!=' ) {
617
+			$m = $observed_value != $hide_opt;
618
+		} else if ( $cond == '>' ) {
619
+			$m = $observed_value > $hide_opt;
620
+		} else if ( $cond == '<' ) {
621
+			$m = $observed_value < $hide_opt;
622
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
+			$m = stripos($observed_value, $hide_opt);
624
+			if ( $cond == 'not LIKE' ) {
625
+				$m = ( $m === false ) ? true : false;
626
+			} else {
627
+				$m = ( $m === false ) ? false : true;
628
+			}
629
+		}
630
+		return $m;
631
+	}
632 632
 
633 633
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634
-        $m = false;
635
-        if ( $cond == '==' ) {
636
-            if ( is_array($hide_opt) ) {
637
-                $m = array_intersect($hide_opt, $observed_value);
638
-                $m = empty($m) ? false : true;
639
-            } else {
640
-                $m = in_array($hide_opt, $observed_value);
641
-            }
642
-        } else if ( $cond == '!=' ) {
643
-            $m = ! in_array($hide_opt, $observed_value);
644
-        } else if ( $cond == '>' ) {
645
-            $min = min($observed_value);
646
-            $m = $min > $hide_opt;
647
-        } else if ( $cond == '<' ) {
648
-            $max = max($observed_value);
649
-            $m = $max < $hide_opt;
650
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651
-            foreach ( $observed_value as $ob ) {
652
-                $m = strpos($ob, $hide_opt);
653
-                if ( $m !== false ) {
654
-                    $m = true;
655
-                    break;
656
-                }
657
-            }
658
-
659
-            if ( $cond == 'not LIKE' ) {
660
-                $m = ( $m === false ) ? true : false;
661
-            }
662
-        }
663
-
664
-        return $m;
665
-    }
666
-
667
-    /**
668
-     * Replace a few basic shortcodes and field ids
669
-     * @since 2.0
670
-     * @return string
671
-     */
634
+		$m = false;
635
+		if ( $cond == '==' ) {
636
+			if ( is_array($hide_opt) ) {
637
+				$m = array_intersect($hide_opt, $observed_value);
638
+				$m = empty($m) ? false : true;
639
+			} else {
640
+				$m = in_array($hide_opt, $observed_value);
641
+			}
642
+		} else if ( $cond == '!=' ) {
643
+			$m = ! in_array($hide_opt, $observed_value);
644
+		} else if ( $cond == '>' ) {
645
+			$min = min($observed_value);
646
+			$m = $min > $hide_opt;
647
+		} else if ( $cond == '<' ) {
648
+			$max = max($observed_value);
649
+			$m = $max < $hide_opt;
650
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651
+			foreach ( $observed_value as $ob ) {
652
+				$m = strpos($ob, $hide_opt);
653
+				if ( $m !== false ) {
654
+					$m = true;
655
+					break;
656
+				}
657
+			}
658
+
659
+			if ( $cond == 'not LIKE' ) {
660
+				$m = ( $m === false ) ? true : false;
661
+			}
662
+		}
663
+
664
+		return $m;
665
+	}
666
+
667
+	/**
668
+	 * Replace a few basic shortcodes and field ids
669
+	 * @since 2.0
670
+	 * @return string
671
+	 */
672 672
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
673
-        if ( strpos($value, '[sitename]') !== false ) {
674
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
-            $value = str_replace('[sitename]', $new_value, $value);
676
-        }
673
+		if ( strpos($value, '[sitename]') !== false ) {
674
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
+			$value = str_replace('[sitename]', $new_value, $value);
676
+		}
677 677
 
678
-        $value = apply_filters('frm_content', $value, $form, $entry);
679
-        $value = do_shortcode($value);
678
+		$value = apply_filters('frm_content', $value, $form, $entry);
679
+		$value = do_shortcode($value);
680 680
 
681
-        return $value;
682
-    }
681
+		return $value;
682
+	}
683 683
 
684 684
 	public static function get_shortcodes( $content, $form_id ) {
685
-        if ( FrmAppHelper::pro_is_installed() ) {
686
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
687
-        }
685
+		if ( FrmAppHelper::pro_is_installed() ) {
686
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
687
+		}
688 688
 
689
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
689
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
690 690
 
691
-        $tagregexp = self::allowed_shortcodes($fields);
691
+		$tagregexp = self::allowed_shortcodes($fields);
692 692
 
693
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
693
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
694 694
 
695
-        return $matches;
696
-    }
695
+		return $matches;
696
+	}
697 697
 
698 698
 	public static function allowed_shortcodes( $fields = array() ) {
699
-        $tagregexp = array(
700
-            'editlink', 'id', 'key', 'ip',
701
-            'siteurl', 'sitename', 'admin_email',
702
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
699
+		$tagregexp = array(
700
+			'editlink', 'id', 'key', 'ip',
701
+			'siteurl', 'sitename', 'admin_email',
702
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
703 703
 			'parent[-|_]id',
704
-        );
704
+		);
705 705
 
706
-        foreach ( $fields as $field ) {
707
-            $tagregexp[] = $field->id;
708
-            $tagregexp[] = $field->field_key;
709
-        }
706
+		foreach ( $fields as $field ) {
707
+			$tagregexp[] = $field->id;
708
+			$tagregexp[] = $field->field_key;
709
+		}
710 710
 
711
-        $tagregexp = implode('|', $tagregexp);
712
-        return $tagregexp;
713
-    }
711
+		$tagregexp = implode('|', $tagregexp);
712
+		return $tagregexp;
713
+	}
714 714
 
715 715
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
716
-        $shortcode_values = array(
717
-           'id'     => $entry->id,
718
-           'key'    => $entry->item_key,
719
-           'ip'     => $entry->ip,
720
-        );
716
+		$shortcode_values = array(
717
+		   'id'     => $entry->id,
718
+		   'key'    => $entry->item_key,
719
+		   'ip'     => $entry->ip,
720
+		);
721 721
 
722
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
723
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
722
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
723
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
724 724
 
725
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
725
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
726 726
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
727
-                $tags = explode(' ', $tag);
728
-                if ( is_array($tags) ) {
729
-                    $tag = $tags[0];
730
-                }
731
-            } else {
732
-                $tag = $shortcodes[2][ $short_key ];
733
-            }
734
-
735
-            switch ( $tag ) {
736
-                case 'id':
737
-                case 'key':
738
-                case 'ip':
739
-                    $replace_with = $shortcode_values[ $tag ];
740
-                break;
741
-
742
-                case 'user_agent':
743
-                case 'user-agent':
744
-                    $entry->description = maybe_unserialize($entry->description);
727
+				$tags = explode(' ', $tag);
728
+				if ( is_array($tags) ) {
729
+					$tag = $tags[0];
730
+				}
731
+			} else {
732
+				$tag = $shortcodes[2][ $short_key ];
733
+			}
734
+
735
+			switch ( $tag ) {
736
+				case 'id':
737
+				case 'key':
738
+				case 'ip':
739
+					$replace_with = $shortcode_values[ $tag ];
740
+				break;
741
+
742
+				case 'user_agent':
743
+				case 'user-agent':
744
+					$entry->description = maybe_unserialize($entry->description);
745 745
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
746
-                break;
747
-
748
-                case 'created_at':
749
-                case 'created-at':
750
-                case 'updated_at':
751
-                case 'updated-at':
752
-                    if ( isset($atts['format']) ) {
753
-                        $time_format = ' ';
754
-                    } else {
755
-                        $atts['format'] = get_option('date_format');
756
-                        $time_format = '';
757
-                    }
758
-
759
-                    $this_tag = str_replace('-', '_', $tag);
760
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
-                    unset($this_tag);
762
-                break;
763
-
764
-                case 'created_by':
765
-                case 'created-by':
766
-                case 'updated_by':
767
-                case 'updated-by':
768
-                    $this_tag = str_replace('-', '_', $tag);
769
-					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
-                    unset($this_tag);
771
-                break;
746
+				break;
747
+
748
+				case 'created_at':
749
+				case 'created-at':
750
+				case 'updated_at':
751
+				case 'updated-at':
752
+					if ( isset($atts['format']) ) {
753
+						$time_format = ' ';
754
+					} else {
755
+						$atts['format'] = get_option('date_format');
756
+						$time_format = '';
757
+					}
772 758
 
773
-                case 'admin_email':
774
-                case 'siteurl':
775
-                case 'frmurl':
776
-                case 'sitename':
777
-                case 'get':
778
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
779
-                break;
759
+					$this_tag = str_replace('-', '_', $tag);
760
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
+					unset($this_tag);
762
+				break;
780 763
 
781
-                default:
782
-                    $field = FrmField::getOne( $tag );
783
-                    if ( ! $field ) {
784
-                        break;
785
-                    }
764
+				case 'created_by':
765
+				case 'created-by':
766
+				case 'updated_by':
767
+				case 'updated-by':
768
+					$this_tag = str_replace('-', '_', $tag);
769
+					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
+					unset($this_tag);
771
+				break;
772
+
773
+				case 'admin_email':
774
+				case 'siteurl':
775
+				case 'frmurl':
776
+				case 'sitename':
777
+				case 'get':
778
+					$replace_with = self::dynamic_default_values( $tag, $atts );
779
+				break;
780
+
781
+				default:
782
+					$field = FrmField::getOne( $tag );
783
+					if ( ! $field ) {
784
+						break;
785
+					}
786 786
 
787
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
787
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
788 788
 
789
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
789
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790 790
 
791
-                    $atts['entry_id'] = $entry->id;
792
-                    $atts['entry_key'] = $entry->item_key;
793
-                    //$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
791
+					$atts['entry_id'] = $entry->id;
792
+					$atts['entry_key'] = $entry->item_key;
793
+					//$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
794 794
 
795
-                    if ( is_array($replace_with) ) {
796
-                        $replace_with = implode($sep, $replace_with);
797
-                    }
795
+					if ( is_array($replace_with) ) {
796
+						$replace_with = implode($sep, $replace_with);
797
+					}
798 798
 
799
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
800
-                        $replace_with = $field->name;
801
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
802
-                        $replace_with = $field->description;
803
-                    } else if ( empty($replace_with) && $replace_with != '0' ) {
804
-                        $replace_with = '';
805
-                    } else {
806
-                        $replace_with = self::get_display_value($replace_with, $field, $atts);
807
-                    }
799
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
800
+						$replace_with = $field->name;
801
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
802
+						$replace_with = $field->description;
803
+					} else if ( empty($replace_with) && $replace_with != '0' ) {
804
+						$replace_with = '';
805
+					} else {
806
+						$replace_with = self::get_display_value($replace_with, $field, $atts);
807
+					}
808 808
 
809
-                    unset($field);
810
-                break;
811
-            }
809
+					unset($field);
810
+				break;
811
+			}
812 812
 
813
-            if ( isset($replace_with) ) {
814
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
815
-            }
813
+			if ( isset($replace_with) ) {
814
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
815
+			}
816 816
 
817
-            unset($atts, $conditional, $replace_with);
817
+			unset($atts, $conditional, $replace_with);
818 818
 		}
819 819
 
820 820
 		return $content;
821
-    }
822
-
823
-    /**
824
-     * Get the value to replace a few standard shortcodes
825
-     *
826
-     * @since 2.0
827
-     * @return string
828
-     */
829
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
830
-        $new_value = '';
831
-        switch ( $tag ) {
832
-            case 'admin_email':
833
-                $new_value = get_option('admin_email');
834
-                break;
835
-            case 'siteurl':
836
-                $new_value = FrmAppHelper::site_url();
837
-                break;
838
-            case 'frmurl':
839
-                $new_value = FrmAppHelper::plugin_url();
840
-                break;
841
-            case 'sitename':
842
-                $new_value = FrmAppHelper::site_name();
843
-                break;
844
-            case 'get':
845
-                $new_value = self::process_get_shortcode( $atts, $return_array );
846
-                break;
847
-        }
848
-
849
-        return $new_value;
850
-    }
851
-
852
-    /**
853
-     * Process the [get] shortcode
854
-     *
855
-     * @since 2.0
856
-     * @return string|array
857
-     */
858
-    public static function process_get_shortcode( $atts, $return_array = false ) {
859
-        if ( ! isset($atts['param']) ) {
860
-            return '';
861
-        }
862
-
863
-        if ( strpos($atts['param'], '&#91;') ) {
864
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
866
-        }
867
-
868
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
869
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870
-
871
-        if ( $new_value == '' ) {
872
-            if ( ! isset($atts['prev_val']) ) {
873
-                $atts['prev_val'] = '';
874
-            }
875
-
876
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
877
-        }
878
-
879
-        if ( is_array($new_value) && ! $return_array ) {
880
-            $new_value = implode(', ', $new_value);
881
-        }
882
-
883
-        return $new_value;
884
-    }
821
+	}
822
+
823
+	/**
824
+	 * Get the value to replace a few standard shortcodes
825
+	 *
826
+	 * @since 2.0
827
+	 * @return string
828
+	 */
829
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
830
+		$new_value = '';
831
+		switch ( $tag ) {
832
+			case 'admin_email':
833
+				$new_value = get_option('admin_email');
834
+				break;
835
+			case 'siteurl':
836
+				$new_value = FrmAppHelper::site_url();
837
+				break;
838
+			case 'frmurl':
839
+				$new_value = FrmAppHelper::plugin_url();
840
+				break;
841
+			case 'sitename':
842
+				$new_value = FrmAppHelper::site_name();
843
+				break;
844
+			case 'get':
845
+				$new_value = self::process_get_shortcode( $atts, $return_array );
846
+				break;
847
+		}
848
+
849
+		return $new_value;
850
+	}
851
+
852
+	/**
853
+	 * Process the [get] shortcode
854
+	 *
855
+	 * @since 2.0
856
+	 * @return string|array
857
+	 */
858
+	public static function process_get_shortcode( $atts, $return_array = false ) {
859
+		if ( ! isset($atts['param']) ) {
860
+			return '';
861
+		}
862
+
863
+		if ( strpos($atts['param'], '&#91;') ) {
864
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
866
+		}
867
+
868
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
869
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870
+
871
+		if ( $new_value == '' ) {
872
+			if ( ! isset($atts['prev_val']) ) {
873
+				$atts['prev_val'] = '';
874
+			}
875
+
876
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
877
+		}
878
+
879
+		if ( is_array($new_value) && ! $return_array ) {
880
+			$new_value = implode(', ', $new_value);
881
+		}
882
+
883
+		return $new_value;
884
+	}
885 885
 
886 886
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
887 887
 		$atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
888 888
 
889 889
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
890 890
 
891
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
892
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
893
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
894
-                if ( is_array($replace_with) ) {
895
-                    $replace_with = implode("\n", $replace_with);
896
-                }
897
-                $replace_with = wpautop($replace_with);
898
-            }
891
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
892
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
893
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
894
+				if ( is_array($replace_with) ) {
895
+					$replace_with = implode("\n", $replace_with);
896
+				}
897
+				$replace_with = wpautop($replace_with);
898
+			}
899 899
 			unset( $autop );
900 900
 		} else if ( is_array( $replace_with ) ) {
901 901
 			$replace_with = implode( $atts['sep'], $replace_with );
@@ -905,57 +905,57 @@  discard block
 block discarded – undo
905 905
 	}
906 906
 
907 907
 	public static function get_field_types( $type ) {
908
-        $single_input = array(
909
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
910
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
911
-            'user_id', 'tag', 'password',
912
-        );
908
+		$single_input = array(
909
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
910
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
911
+			'user_id', 'tag', 'password',
912
+		);
913 913
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale' );
914 914
 		$other_type = array( 'divider', 'html', 'break' );
915 915
 
916 916
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
917 917
 
918
-        $field_types = array();
919
-        if ( in_array($type, $single_input) ) {
920
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
921
-        } else if ( in_array($type, $multiple_input) ) {
922
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
923
-        } else if ( in_array($type, $other_type) ) {
924
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
918
+		$field_types = array();
919
+		if ( in_array($type, $single_input) ) {
920
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
921
+		} else if ( in_array($type, $multiple_input) ) {
922
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
923
+		} else if ( in_array($type, $other_type) ) {
924
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
925 925
 		} else if ( isset( $field_selection[ $type ] ) ) {
926
-            $field_types[ $type ] = $field_selection[ $type ];
927
-        }
928
-
929
-        return $field_types;
930
-    }
931
-
932
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
933
-        foreach ( $inputs as $input ) {
934
-            $field_types[ $input ] = $fields[ $input ];
935
-            unset($input);
936
-        }
937
-    }
938
-
939
-    /**
940
-    * Check if current field option is an "other" option
941
-    *
942
-    * @since 2.0.6
943
-    *
944
-    * @param string $opt_key
945
-    * @return boolean Returns true if current field option is an "Other" option
946
-    */
947
-    public static function is_other_opt( $opt_key ) {
948
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
949
-    }
950
-
951
-    /**
952
-    * Get value that belongs in "Other" text box
953
-    *
954
-    * @since 2.0.6
955
-    *
956
-    * @param array $args
957
-    */
958
-    public static function get_other_val( $args ) {
926
+			$field_types[ $type ] = $field_selection[ $type ];
927
+		}
928
+
929
+		return $field_types;
930
+	}
931
+
932
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
933
+		foreach ( $inputs as $input ) {
934
+			$field_types[ $input ] = $fields[ $input ];
935
+			unset($input);
936
+		}
937
+	}
938
+
939
+	/**
940
+	 * Check if current field option is an "other" option
941
+	 *
942
+	 * @since 2.0.6
943
+	 *
944
+	 * @param string $opt_key
945
+	 * @return boolean Returns true if current field option is an "Other" option
946
+	 */
947
+	public static function is_other_opt( $opt_key ) {
948
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
949
+	}
950
+
951
+	/**
952
+	 * Get value that belongs in "Other" text box
953
+	 *
954
+	 * @since 2.0.6
955
+	 *
956
+	 * @param array $args
957
+	 */
958
+	public static function get_other_val( $args ) {
959 959
 		$defaults = array(
960 960
 			'opt_key' => 0, 'field' => array(),
961 961
 			'parent' => false, 'pointer' => false,
@@ -1031,20 +1031,20 @@  discard block
 block discarded – undo
1031 1031
 		}
1032 1032
 
1033 1033
 		return $other_val;
1034
-    }
1035
-
1036
-    /**
1037
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1038
-    * Intended for front-end use
1039
-    *
1040
-    * @since 2.0.6
1041
-    *
1042
-    * @param array $args should include field, opt_key and field name
1043
-    * @param boolean $other_opt
1044
-    * @param string $checked
1045
-    * @return string $other_val
1046
-    */
1047
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1034
+	}
1035
+
1036
+	/**
1037
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
1038
+	 * Intended for front-end use
1039
+	 *
1040
+	 * @since 2.0.6
1041
+	 *
1042
+	 * @param array $args should include field, opt_key and field name
1043
+	 * @param boolean $other_opt
1044
+	 * @param string $checked
1045
+	 * @return string $other_val
1046
+	 */
1047
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
1048 1048
 		//Check if this is an "Other" option
1049 1049
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
1050 1050
 			return;
@@ -1060,8 +1060,8 @@  discard block
 block discarded – undo
1060 1060
 			$checked = 'checked="checked" ';
1061 1061
 		}
1062 1062
 
1063
-        return $other_args;
1064
-    }
1063
+		return $other_args;
1064
+	}
1065 1065
 
1066 1066
 	/**
1067 1067
 	 * @param array $args
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 	 * @since 2.0.6
1111 1111
 	 */
1112 1112
 	public static function include_other_input( $args ) {
1113
-        if ( ! $args['other_opt'] ) {
1114
-        	return;
1113
+		if ( ! $args['other_opt'] ) {
1114
+			return;
1115 1115
 		}
1116 1116
 
1117 1117
 		$classes = array( 'frm_other_input' );
@@ -1132,15 +1132,15 @@  discard block
 block discarded – undo
1132 1132
 	}
1133 1133
 
1134 1134
 	/**
1135
-	* Get the HTML id for an "Other" text field
1136
-	* Note: This does not affect fields in repeating sections
1137
-	*
1138
-	* @since 2.0.08
1139
-	* @param string $type - field type
1140
-	* @param string $html_id
1141
-	* @param string|boolean $opt_key
1142
-	* @return string $other_id
1143
-	*/
1135
+	 * Get the HTML id for an "Other" text field
1136
+	 * Note: This does not affect fields in repeating sections
1137
+	 *
1138
+	 * @since 2.0.08
1139
+	 * @param string $type - field type
1140
+	 * @param string $html_id
1141
+	 * @param string|boolean $opt_key
1142
+	 * @return string $other_id
1143
+	 */
1144 1144
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1145 1145
 		$other_id = $html_id;
1146 1146
 
@@ -1195,171 +1195,171 @@  discard block
 block discarded – undo
1195 1195
 	}
1196 1196
 
1197 1197
 	public static function switch_field_ids( $val ) {
1198
-        global $frm_duplicate_ids;
1199
-        $replace = array();
1200
-        $replace_with = array();
1201
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1202
-            $replace[] = '[if '. $old .']';
1203
-            $replace_with[] = '[if '. $new .']';
1204
-            $replace[] = '[if '. $old .' ';
1205
-            $replace_with[] = '[if '. $new .' ';
1206
-            $replace[] = '[/if '. $old .']';
1207
-            $replace_with[] = '[/if '. $new .']';
1208
-            $replace[] = '[foreach '. $old .']';
1209
-            $replace_with[] = '[foreach '. $new .']';
1210
-            $replace[] = '[/foreach '. $old .']';
1211
-            $replace_with[] = '[/foreach '. $new .']';
1212
-            $replace[] = '['. $old .']';
1213
-            $replace_with[] = '['. $new .']';
1214
-            $replace[] = '['. $old .' ';
1215
-            $replace_with[] = '['. $new .' ';
1216
-            unset($old, $new);
1217
-        }
1198
+		global $frm_duplicate_ids;
1199
+		$replace = array();
1200
+		$replace_with = array();
1201
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1202
+			$replace[] = '[if '. $old .']';
1203
+			$replace_with[] = '[if '. $new .']';
1204
+			$replace[] = '[if '. $old .' ';
1205
+			$replace_with[] = '[if '. $new .' ';
1206
+			$replace[] = '[/if '. $old .']';
1207
+			$replace_with[] = '[/if '. $new .']';
1208
+			$replace[] = '[foreach '. $old .']';
1209
+			$replace_with[] = '[foreach '. $new .']';
1210
+			$replace[] = '[/foreach '. $old .']';
1211
+			$replace_with[] = '[/foreach '. $new .']';
1212
+			$replace[] = '['. $old .']';
1213
+			$replace_with[] = '['. $new .']';
1214
+			$replace[] = '['. $old .' ';
1215
+			$replace_with[] = '['. $new .' ';
1216
+			unset($old, $new);
1217
+		}
1218 1218
 		if ( is_array( $val ) ) {
1219 1219
 			foreach ( $val as $k => $v ) {
1220
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1221
-                unset($k, $v);
1222
-            }
1223
-        } else {
1224
-            $val = str_replace($replace, $replace_with, $val);
1225
-        }
1226
-
1227
-        return $val;
1228
-    }
1229
-
1230
-    public static function get_us_states() {
1231
-        return apply_filters( 'frm_us_states', array(
1232
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1233
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1234
-            'DC' => 'District of Columbia',
1235
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1236
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1237
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1238
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1239
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1240
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1241
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1242
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1243
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1244
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1245
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1246
-        ) );
1247
-    }
1248
-
1249
-    public static function get_countries() {
1250
-        return apply_filters( 'frm_countries', array(
1251
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1252
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1253
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1254
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1255
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1256
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1257
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1258
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1259
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1260
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1261
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1262
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1263
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1264
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1265
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1266
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1267
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1268
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1269
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1270
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1271
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1272
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1273
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1274
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1275
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1276
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1277
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1278
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1279
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1280
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1281
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1282
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1283
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1284
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1285
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1286
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1287
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1288
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1289
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1290
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1291
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1292
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1293
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1294
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1295
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1296
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1297
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1298
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1299
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1300
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1301
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1302
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1303
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1304
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1305
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1306
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1307
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1308
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1309
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1310
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1311
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1312
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1313
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1314
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1315
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1316
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1317
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1318
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1319
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1320
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1321
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1322
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1323
-            __( 'Zimbabwe', 'formidable' ),
1324
-        ) );
1325
-    }
1220
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1221
+				unset($k, $v);
1222
+			}
1223
+		} else {
1224
+			$val = str_replace($replace, $replace_with, $val);
1225
+		}
1226
+
1227
+		return $val;
1228
+	}
1229
+
1230
+	public static function get_us_states() {
1231
+		return apply_filters( 'frm_us_states', array(
1232
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1233
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1234
+			'DC' => 'District of Columbia',
1235
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1236
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1237
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1238
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1239
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1240
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1241
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1242
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1243
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1244
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1245
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1246
+		) );
1247
+	}
1248
+
1249
+	public static function get_countries() {
1250
+		return apply_filters( 'frm_countries', array(
1251
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1252
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1253
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1254
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1255
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1256
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1257
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1258
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1259
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1260
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1261
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1262
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1263
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1264
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1265
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1266
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1267
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1268
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1269
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1270
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1271
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1272
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1273
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1274
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1275
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1276
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1277
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1278
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1279
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1280
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1281
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1282
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1283
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1284
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1285
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1286
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1287
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1288
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1289
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1290
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1291
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1292
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1293
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1294
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1295
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1296
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1297
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1298
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1299
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1300
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1301
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1302
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1303
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1304
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1305
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1306
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1307
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1308
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1309
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1310
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1311
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1312
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1313
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1314
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1315
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1316
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1317
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1318
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1319
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1320
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1321
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1322
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1323
+			__( 'Zimbabwe', 'formidable' ),
1324
+		) );
1325
+	}
1326 1326
 
1327 1327
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1328 1328
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1329 1329
 
1330
-        $states = FrmFieldsHelper::get_us_states();
1331
-        $state_abv = array_keys($states);
1332
-        sort($state_abv);
1330
+		$states = FrmFieldsHelper::get_us_states();
1331
+		$state_abv = array_keys($states);
1332
+		sort($state_abv);
1333 1333
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1334 1334
 
1335
-        $states = array_values($states);
1336
-        sort($states);
1335
+		$states = array_values($states);
1336
+		sort($states);
1337 1337
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1338
-        unset($state_abv, $states);
1338
+		unset($state_abv, $states);
1339 1339
 
1340 1340
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1341
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1342
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1343
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1344
-        );
1341
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1342
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1343
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1344
+		);
1345 1345
 
1346 1346
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1347
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1348
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1349
-        );
1347
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1348
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1349
+		);
1350 1350
 
1351 1351
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1352
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1353
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1354
-        );
1352
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1353
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1354
+		);
1355 1355
 
1356 1356
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1357
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1358
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1359
-        );
1357
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1358
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1359
+		);
1360 1360
 
1361 1361
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1362
-    }
1362
+	}
1363 1363
 
1364 1364
 	public static function field_selection() {
1365 1365
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
 		return FrmField::is_required( $field );
1397 1397
 	}
1398 1398
 
1399
-    public static function maybe_get_field( &$field ) {
1399
+	public static function maybe_get_field( &$field ) {
1400 1400
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1401 1401
 		FrmField::maybe_get_field( $field );
1402
-    }
1402
+	}
1403 1403
 }
Please login to merge, or discard this patch.
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public static function setup_new_vars( $type = '', $form_id = '' ) {
9 9
 
10
-        if ( strpos($type, '|') ) {
11
-            list($type, $setting) = explode('|', $type);
10
+        if ( strpos( $type, '|' ) ) {
11
+            list( $type, $setting ) = explode( '|', $type );
12 12
         }
13 13
 
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
14
+        $defaults = self::get_default_field_opts( $type, $form_id );
15
+        $defaults['field_options']['custom_html'] = self::get_default_html( $type );
16 16
 
17 17
         $values = array();
18 18
 
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
             if ( $var == 'field_options' ) {
21 21
                 $values['field_options'] = array();
22 22
                 foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
23
+                    $values['field_options'][$opt_var] = $opt_default;
24
+                    unset( $opt_var, $opt_default );
25 25
                 }
26 26
             } else {
27
-                $values[ $var ] = $default;
27
+                $values[$var] = $default;
28 28
             }
29
-            unset($var, $default);
29
+            unset( $var, $default );
30 30
         }
31 31
 
32 32
         if ( isset( $setting ) && ! empty( $setting ) ) {
33 33
             if ( 'data' == $type ) {
34 34
                 $values['field_options']['data_type'] = $setting;
35 35
             } else {
36
-                $values['field_options'][ $setting ] = 1;
36
+                $values['field_options'][$setting] = 1;
37 37
             }
38 38
         }
39 39
 
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
 		$fields = FrmField::field_selection();
59
-        $fields = array_merge($fields, FrmField::pro_field_selection());
59
+        $fields = array_merge( $fields, FrmField::pro_field_selection() );
60 60
 
61
-        if ( isset( $fields[ $type ] ) ) {
62
-            $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
61
+        if ( isset( $fields[$type] ) ) {
62
+            $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type];
63 63
         }
64 64
 
65
-        unset($fields);
65
+        unset( $fields );
66 66
 
67 67
         return $values;
68 68
     }
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71
-        return apply_filters('frm_field_html_id', 'field_'. $field['field_key'] . $plus, $field);
71
+        return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72 72
     }
73 73
 
74 74
     public static function setup_edit_vars( $record, $doing_ajax = false ) {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             $values['form_name'] = '';
89 89
 		} else {
90 90
 			foreach ( $defaults as $var => $default ) {
91
-                $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
-                unset($var, $default);
91
+                $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+                unset( $var, $default );
93 93
             }
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $values['options'] = $record->options;
101 101
         $values['field_options'] = $record->field_options;
102 102
 
103
-        $defaults = self::get_default_field_opts($values['type'], $record, true);
103
+        $defaults = self::get_default_field_opts( $values['type'], $record, true );
104 104
 
105 105
 		if ( $values['type'] == 'captcha' ) {
106 106
             $frm_settings = FrmAppHelper::get_settings();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
 		foreach ( $defaults as $opt => $default ) {
111
-            $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
-            unset($opt, $default);
111
+            $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default;
112
+            unset( $opt, $default );
113 113
         }
114 114
 
115
-        $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type);
115
+        $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type );
116 116
 
117 117
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
118 118
     }
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 
132 132
         global $wpdb;
133 133
 
134
-        $form_id = (is_numeric($field)) ? $field : $field->form_id;
134
+        $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id;
135 135
 
136
-        $key = is_numeric($field) ? FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_fields', 'field_key') : $field->field_key;
136
+        $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key;
137 137
 
138 138
         $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
     public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152 152
         global $wpdb;
153 153
 
154
-        $values['field_key'] = FrmAppHelper::get_unique_key($new_key, $wpdb->prefix .'frm_fields', 'field_key');
154
+        $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155 155
         $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
156
+        $values['options'] = maybe_serialize( $field->options );
157
+        $values['default_value'] = maybe_serialize( $field->default_value );
158 158
 
159 159
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
160
+            $values[$col] = $field->{$col};
161 161
         }
162 162
     }
163 163
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		$field_name = is_array( $field ) ? $field['name'] : $field->name;
171 171
 
172 172
 		$defaults = array(
173
-			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ),
174
-			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ),
173
+			'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ),
174
+			'invalid'   => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ),
175 175
 			'blank'     => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ),
176 176
 		);
177 177
 
178 178
 		$msg = FrmField::get_option( $field, $error );
179
-		$msg = ( $msg == $defaults[ $error ]['full'] || empty( $msg ) ) ? $defaults[ $error ]['part'] : $msg;
179
+		$msg = ( $msg == $defaults[$error]['full'] || empty( $msg ) ) ? $defaults[$error]['part'] : $msg;
180 180
 		return $msg;
181 181
 	}
182 182
 
183 183
     public static function get_form_fields( $form_id, $error = false ) {
184
-        $fields = FrmField::get_all_for_form($form_id);
185
-        $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error);
184
+        $fields = FrmField::get_all_for_form( $form_id );
185
+        $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error );
186 186
         return $fields;
187 187
     }
188 188
 
@@ -205,57 +205,57 @@  discard block
 block discarded – undo
205 205
 </div>
206 206
 DEFAULT_HTML;
207 207
         } else {
208
-			$default_html = apply_filters('frm_other_custom_html', '', $type);
208
+			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
209 209
         }
210 210
 
211
-        return apply_filters('frm_custom_html', $default_html, $type);
211
+        return apply_filters( 'frm_custom_html', $default_html, $type );
212 212
     }
213 213
 
214 214
 	public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) {
215
-        $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
215
+        $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form );
216 216
 
217 217
         $defaults = array(
218
-            'field_name'  => 'item_meta['. $field['id'] .']',
218
+            'field_name'  => 'item_meta[' . $field['id'] . ']',
219 219
             'field_id'    => $field['id'],
220 220
             'field_plus_id' => '',
221 221
             'section_id'    => '',
222 222
         );
223
-        $args = wp_parse_args($args, $defaults);
223
+        $args = wp_parse_args( $args, $defaults );
224 224
         $field_name = $args['field_name'];
225 225
         $field_id = $args['field_id'];
226
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
226
+        $html_id = self::get_html_id( $field, $args['field_plus_id'] );
227 227
 
228
-        if ( FrmField::is_multiple_select($field) ) {
228
+        if ( FrmField::is_multiple_select( $field ) ) {
229 229
             $field_name .= '[]';
230 230
         }
231 231
 
232 232
         //replace [id]
233
-        $html = str_replace('[id]', $field_id, $html);
233
+        $html = str_replace( '[id]', $field_id, $html );
234 234
 
235 235
         // Remove the for attribute for captcha
236 236
         if ( $field['type'] == 'captcha' ) {
237
-            $html = str_replace(' for="field_[key]"', '', $html);
237
+            $html = str_replace( ' for="field_[key]"', '', $html );
238 238
         }
239 239
 
240 240
         // set the label for
241
-        $html = str_replace('field_[key]', $html_id, $html);
241
+        $html = str_replace( 'field_[key]', $html_id, $html );
242 242
 
243 243
         //replace [key]
244
-        $html = str_replace('[key]', $field['field_key'], $html);
244
+        $html = str_replace( '[key]', $field['field_key'], $html );
245 245
 
246 246
         //replace [description] and [required_label] and [error]
247 247
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
248 248
         if ( ! is_array( $errors ) ) {
249 249
             $errors = array();
250 250
         }
251
-		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
251
+		$error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false;
252 252
 
253 253
         //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
254 254
         if ( $field['type'] == 'divider' ) {
255 255
             if ( FrmField::is_option_true( $field, 'description' ) ) {
256 256
                 $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
257 257
             } else {
258
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
258
+                $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html );
259 259
             }
260 260
         }
261 261
 
@@ -265,83 +265,83 @@  discard block
 block discarded – undo
265 265
 
266 266
         //replace [required_class]
267 267
 		$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
268
-        $html = str_replace('[required_class]', $required_class, $html);
268
+        $html = str_replace( '[required_class]', $required_class, $html );
269 269
 
270 270
         //replace [label_position]
271
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
271
+        $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form );
272 272
         $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273 273
 		$html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html );
274 274
 
275 275
         //replace [field_name]
276
-        $html = str_replace('[field_name]', $field['name'], $html);
276
+        $html = str_replace( '[field_name]', $field['name'], $html );
277 277
 
278 278
         //replace [error_class]
279
-		$error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
279
+		$error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
280 280
 		self::get_more_field_classes( $error_class, $field, $field_id, $html );
281 281
 		if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) {
282 282
 			// there is no error_class shortcode to use for addign fields
283 283
 			$html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html );
284 284
 		}
285
-        $html = str_replace('[error_class]', $error_class, $html);
285
+        $html = str_replace( '[error_class]', $error_class, $html );
286 286
 
287 287
         //replace [entry_key]
288 288
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
289
-        $html = str_replace('[entry_key]', $entry_key, $html);
289
+        $html = str_replace( '[entry_key]', $entry_key, $html );
290 290
 
291 291
         //replace [input]
292
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
292
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
293 293
         global $frm_vars;
294 294
         $frm_settings = FrmAppHelper::get_settings();
295 295
 
296 296
         foreach ( $shortcodes[0] as $short_key => $tag ) {
297
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
297
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
298 298
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
299 299
 
300 300
             $replace_with = '';
301 301
 
302 302
             if ( $tag == 'input' ) {
303
-                if ( isset($atts['opt']) ) {
304
-                    $atts['opt']--;
303
+                if ( isset( $atts['opt'] ) ) {
304
+                    $atts['opt'] --;
305 305
                 }
306 306
 
307
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
308
-                if ( isset($atts['class']) ) {
309
-                    unset($atts['class']);
307
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
308
+                if ( isset( $atts['class'] ) ) {
309
+                    unset( $atts['class'] );
310 310
                 }
311 311
 
312 312
                 $field['shortcodes'] = $atts;
313 313
                 ob_start();
314
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/input.php');
314
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
315 315
                 $replace_with = ob_get_contents();
316 316
                 ob_end_clean();
317 317
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
318
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
318
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
319 319
             }
320 320
 
321
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
321
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
322 322
         }
323 323
 
324 324
 		if ( $form ) {
325 325
             $form = (array) $form;
326 326
 
327 327
             //replace [form_key]
328
-            $html = str_replace('[form_key]', $form['form_key'], $html);
328
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
329 329
 
330 330
             //replace [form_name]
331
-            $html = str_replace('[form_name]', $form['name'], $html);
331
+            $html = str_replace( '[form_name]', $form['name'], $html );
332 332
         }
333 333
         $html .= "\n";
334 334
 
335 335
         //Return html if conf_field to prevent loop
336
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
336
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
337 337
             return $html;
338 338
         }
339 339
 
340 340
         //If field is in repeating section
341 341
         if ( $args['section_id'] ) {
342
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ));
342
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) );
343 343
         } else {
344
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
344
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
345 345
         }
346 346
 
347 347
 		self::remove_collapse_shortcode( $html );
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
 	* @param $html string
364 364
 	*/
365 365
 	private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) {
366
-		$error_class .= ' frm_'. $field['label'] .'_container';
366
+		$error_class .= ' frm_' . $field['label'] . '_container';
367 367
 		if ( $field['id'] != $field_id ) {
368 368
 			// add a class for repeating/embedded fields
369
-			$error_class .= ' frm_field_'. $field['id'] .'_container';
369
+			$error_class .= ' frm_field_' . $field['id'] . '_container';
370 370
 		}
371 371
 
372 372
 		// Add class to embedded form field
@@ -418,22 +418,22 @@  discard block
 block discarded – undo
418 418
 
419 419
 		//insert custom CSS classes
420 420
 		if ( ! empty( $field['classes'] ) ) {
421
-			if ( ! strpos( $html, 'frm_form_field ') ) {
421
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
422 422
 				$error_class .= ' frm_form_field';
423 423
 			}
424
-			$error_class .= ' '. $field['classes'];
424
+			$error_class .= ' ' . $field['classes'];
425 425
 		}
426 426
 	}
427 427
 
428 428
     public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
429 429
         if ( $no_vars ) {
430
-            $html = str_replace( '[if '. $code.']', '', $html );
431
-    	    $html = str_replace( '[/if '. $code.']', '', $html );
430
+            $html = str_replace( '[if ' . $code . ']', '', $html );
431
+    	    $html = str_replace( '[/if ' . $code . ']', '', $html );
432 432
         } else {
433
-            $html = preg_replace( '/(\[if\s+'. $code .'\])(.*?)(\[\/if\s+'. $code .'\])/mis', '', $html );
433
+            $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
434 434
         }
435 435
 
436
-        $html = str_replace( '['. $code .']', $replace_with, $html );
436
+        $html = str_replace( '[' . $code . ']', $replace_with, $html );
437 437
     }
438 438
 
439 439
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
         }
453 453
 
454 454
         $with_tags = $args['conditional_check'] ? 3 : 2;
455
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
456
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
457
-            $tag = str_replace(']', '', $tag);
458
-            $tags = explode(' ', $tag);
459
-            if ( is_array($tags) ) {
455
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
456
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
457
+            $tag = str_replace( ']', '', $tag );
458
+            $tags = explode( ' ', $tag );
459
+            if ( is_array( $tags ) ) {
460 460
                 $tag = $tags[0];
461 461
             }
462 462
         } else {
463
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
463
+            $tag = $shortcodes[$with_tags - 1][$short_key];
464 464
         }
465 465
 
466 466
         return $tag;
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 
479 479
 	public static function display_recaptcha( $field ) {
480 480
         $frm_settings = FrmAppHelper::get_settings();
481
-        $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field);
481
+        $lang = apply_filters( 'frm_recaptcha_lang', $frm_settings->re_lang, $field );
482 482
 
483 483
         $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit';
484 484
         if ( $lang != 'en' ) {
485
-            $api_js_url .= '&hl='. $lang;
485
+            $api_js_url .= '&hl=' . $lang;
486 486
         }
487
-        $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url);
487
+        $api_js_url = apply_filters( 'frm_recpatcha_js_url', $api_js_url );
488 488
 
489
-        wp_register_script('recaptcha-api', $api_js_url, '', true);
490
-        wp_enqueue_script('recaptcha-api');
489
+        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
490
+        wp_enqueue_script( 'recaptcha-api' );
491 491
 
492 492
 ?>
493 493
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div>
@@ -496,45 +496,45 @@  discard block
 block discarded – undo
496 496
 
497 497
 	public static function show_single_option( $field ) {
498 498
         $field_name = $field['name'];
499
-        $html_id = self::get_html_id($field);
499
+        $html_id = self::get_html_id( $field );
500 500
         foreach ( $field['options'] as $opt_key => $opt ) {
501
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
502
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
501
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
502
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
503 503
 
504 504
             // If this is an "Other" option, get the HTML for it
505 505
 			if ( self::is_other_opt( $opt_key ) ) {
506 506
                 // Get string for Other text field, if needed
507 507
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
508
-                require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php');
508
+                require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
509 509
             } else {
510
-                require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
510
+                require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
511 511
             }
512 512
         }
513 513
     }
514 514
 
515 515
 	public static function dropdown_categories( $args ) {
516 516
 		$defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' );
517
-        $args = wp_parse_args($args, $defaults);
517
+        $args = wp_parse_args( $args, $defaults );
518 518
 
519 519
         if ( ! $args['field'] ) {
520 520
             return;
521 521
         }
522 522
 
523 523
         if ( ! $args['name'] ) {
524
-            $args['name'] = 'item_meta['. $args['field']['id'] .']';
524
+            $args['name'] = 'item_meta[' . $args['field']['id'] . ']';
525 525
         }
526 526
 
527
-        $id = self::get_html_id($args['field']);
527
+        $id = self::get_html_id( $args['field'] );
528 528
         $class = $args['field']['type'];
529 529
 
530
-        $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat'];
531
-        $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']);
530
+        $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat'];
531
+        $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] );
532 532
 
533
-        if ( is_array($args['field']['value']) ) {
534
-            if ( ! empty($exclude) ) {
535
-                $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude));
533
+        if ( is_array( $args['field']['value'] ) ) {
534
+            if ( ! empty( $exclude ) ) {
535
+                $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) );
536 536
             }
537
-            $selected = reset($args['field']['value']);
537
+            $selected = reset( $args['field']['value'] );
538 538
         } else {
539 539
             $selected = $args['field']['value'];
540 540
         }
@@ -545,40 +545,40 @@  discard block
 block discarded – undo
545 545
             'hide_empty' => false, 'echo' => 0, 'orderby' => 'name',
546 546
         );
547 547
 
548
-        $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']);
548
+        $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] );
549 549
 
550 550
         if ( FrmAppHelper::pro_is_installed() ) {
551
-            $post_type = FrmProFormsHelper::post_type($args['field']['form_id']);
552
-            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']);
551
+            $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] );
552
+            $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] );
553 553
             if ( ! $tax_atts['taxonomy'] ) {
554 554
                 return;
555 555
             }
556 556
 
557 557
             // If field type is dropdown (not Dynamic), exclude children when parent is excluded
558
-            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) {
558
+            if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) {
559 559
                 $tax_atts['exclude_tree'] = $exclude;
560 560
             }
561 561
         }
562 562
 
563
-        $dropdown = wp_dropdown_categories($tax_atts);
563
+        $dropdown = wp_dropdown_categories( $tax_atts );
564 564
 
565
-        $add_html = FrmFieldsController::input_html($args['field'], false);
565
+        $add_html = FrmFieldsController::input_html( $args['field'], false );
566 566
 
567 567
         if ( FrmAppHelper::pro_is_installed() ) {
568
-            $add_html .= FrmProFieldsController::input_html($args['field'], false);
568
+            $add_html .= FrmProFieldsController::input_html( $args['field'], false );
569 569
         }
570 570
 
571
-		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) ."' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
571
+		$dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown );
572 572
 
573
-        if ( is_array($args['field']['value']) ) {
573
+        if ( is_array( $args['field']['value'] ) ) {
574 574
             $skip = true;
575 575
             foreach ( $args['field']['value'] as $v ) {
576 576
 				if ( $skip ) {
577 577
                     $skip = false;
578 578
                     continue;
579 579
                 }
580
-				$dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
-                unset($v);
580
+				$dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown );
581
+                unset( $v );
582 582
             }
583 583
         }
584 584
 
@@ -586,16 +586,16 @@  discard block
 block discarded – undo
586 586
     }
587 587
 
588 588
 	public static function get_term_link( $tax_id ) {
589
-        $tax = get_taxonomy($tax_id);
589
+        $tax = get_taxonomy( $tax_id );
590 590
         if ( ! $tax ) {
591 591
             return;
592 592
         }
593 593
 
594 594
         $link = sprintf(
595 595
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
596
-            '<a href="'. esc_url( admin_url( 'edit-tags.php?taxonomy='. $tax->name ) ) .'" target="_blank">'. ( empty($tax->labels->name) ? __( 'Categories' ) : $tax->labels->name ) .'</a>'
596
+            '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
597 597
         );
598
-        unset($tax);
598
+        unset( $tax );
599 599
 
600 600
         return $link;
601 601
     }
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
 			$hide_opt = rtrim( $hide_opt );
607 607
 		}
608 608
 
609
-        if ( is_array($observed_value) ) {
610
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
609
+        if ( is_array( $observed_value ) ) {
610
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
611 611
         }
612 612
 
613 613
         $m = false;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         } else if ( $cond == '<' ) {
621 621
             $m = $observed_value < $hide_opt;
622 622
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
623
-            $m = stripos($observed_value, $hide_opt);
623
+            $m = stripos( $observed_value, $hide_opt );
624 624
             if ( $cond == 'not LIKE' ) {
625 625
                 $m = ( $m === false ) ? true : false;
626 626
             } else {
@@ -633,23 +633,23 @@  discard block
 block discarded – undo
633 633
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
634 634
         $m = false;
635 635
         if ( $cond == '==' ) {
636
-            if ( is_array($hide_opt) ) {
637
-                $m = array_intersect($hide_opt, $observed_value);
638
-                $m = empty($m) ? false : true;
636
+            if ( is_array( $hide_opt ) ) {
637
+                $m = array_intersect( $hide_opt, $observed_value );
638
+                $m = empty( $m ) ? false : true;
639 639
             } else {
640
-                $m = in_array($hide_opt, $observed_value);
640
+                $m = in_array( $hide_opt, $observed_value );
641 641
             }
642 642
         } else if ( $cond == '!=' ) {
643
-            $m = ! in_array($hide_opt, $observed_value);
643
+            $m = ! in_array( $hide_opt, $observed_value );
644 644
         } else if ( $cond == '>' ) {
645
-            $min = min($observed_value);
645
+            $min = min( $observed_value );
646 646
             $m = $min > $hide_opt;
647 647
         } else if ( $cond == '<' ) {
648
-            $max = max($observed_value);
648
+            $max = max( $observed_value );
649 649
             $m = $max < $hide_opt;
650 650
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
651 651
             foreach ( $observed_value as $ob ) {
652
-                $m = strpos($ob, $hide_opt);
652
+                $m = strpos( $ob, $hide_opt );
653 653
                 if ( $m !== false ) {
654 654
                     $m = true;
655 655
                     break;
@@ -670,27 +670,27 @@  discard block
 block discarded – undo
670 670
      * @return string
671 671
      */
672 672
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
673
-        if ( strpos($value, '[sitename]') !== false ) {
673
+        if ( strpos( $value, '[sitename]' ) !== false ) {
674 674
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
675
-            $value = str_replace('[sitename]', $new_value, $value);
675
+            $value = str_replace( '[sitename]', $new_value, $value );
676 676
         }
677 677
 
678
-        $value = apply_filters('frm_content', $value, $form, $entry);
679
-        $value = do_shortcode($value);
678
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
679
+        $value = do_shortcode( $value );
680 680
 
681 681
         return $value;
682 682
     }
683 683
 
684 684
 	public static function get_shortcodes( $content, $form_id ) {
685 685
         if ( FrmAppHelper::pro_is_installed() ) {
686
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
686
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
687 687
         }
688 688
 
689 689
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
690 690
 
691
-        $tagregexp = self::allowed_shortcodes($fields);
691
+        $tagregexp = self::allowed_shortcodes( $fields );
692 692
 
693
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
693
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
694 694
 
695 695
         return $matches;
696 696
     }
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
             $tagregexp[] = $field->field_key;
709 709
         }
710 710
 
711
-        $tagregexp = implode('|', $tagregexp);
711
+        $tagregexp = implode( '|', $tagregexp );
712 712
         return $tagregexp;
713 713
     }
714 714
 
@@ -720,28 +720,28 @@  discard block
 block discarded – undo
720 720
         );
721 721
 
722 722
         foreach ( $shortcodes[0] as $short_key => $tag ) {
723
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
723
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
724 724
 
725
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
726
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
727
-                $tags = explode(' ', $tag);
728
-                if ( is_array($tags) ) {
725
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
726
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
727
+                $tags = explode( ' ', $tag );
728
+                if ( is_array( $tags ) ) {
729 729
                     $tag = $tags[0];
730 730
                 }
731 731
             } else {
732
-                $tag = $shortcodes[2][ $short_key ];
732
+                $tag = $shortcodes[2][$short_key];
733 733
             }
734 734
 
735 735
             switch ( $tag ) {
736 736
                 case 'id':
737 737
                 case 'key':
738 738
                 case 'ip':
739
-                    $replace_with = $shortcode_values[ $tag ];
739
+                    $replace_with = $shortcode_values[$tag];
740 740
                 break;
741 741
 
742 742
                 case 'user_agent':
743 743
                 case 'user-agent':
744
-                    $entry->description = maybe_unserialize($entry->description);
744
+                    $entry->description = maybe_unserialize( $entry->description );
745 745
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
746 746
                 break;
747 747
 
@@ -749,25 +749,25 @@  discard block
 block discarded – undo
749 749
                 case 'created-at':
750 750
                 case 'updated_at':
751 751
                 case 'updated-at':
752
-                    if ( isset($atts['format']) ) {
752
+                    if ( isset( $atts['format'] ) ) {
753 753
                         $time_format = ' ';
754 754
                     } else {
755
-                        $atts['format'] = get_option('date_format');
755
+                        $atts['format'] = get_option( 'date_format' );
756 756
                         $time_format = '';
757 757
                     }
758 758
 
759
-                    $this_tag = str_replace('-', '_', $tag);
760
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
761
-                    unset($this_tag);
759
+                    $this_tag = str_replace( '-', '_', $tag );
760
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
761
+                    unset( $this_tag );
762 762
                 break;
763 763
 
764 764
                 case 'created_by':
765 765
                 case 'created-by':
766 766
                 case 'updated_by':
767 767
                 case 'updated-by':
768
-                    $this_tag = str_replace('-', '_', $tag);
768
+                    $this_tag = str_replace( '-', '_', $tag );
769 769
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
770
-                    unset($this_tag);
770
+                    unset( $this_tag );
771 771
                 break;
772 772
 
773 773
                 case 'admin_email':
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
                         break;
785 785
                     }
786 786
 
787
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
787
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
788 788
 
789 789
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
790 790
 
@@ -792,29 +792,29 @@  discard block
 block discarded – undo
792 792
                     $atts['entry_key'] = $entry->item_key;
793 793
                     //$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
794 794
 
795
-                    if ( is_array($replace_with) ) {
796
-                        $replace_with = implode($sep, $replace_with);
795
+                    if ( is_array( $replace_with ) ) {
796
+                        $replace_with = implode( $sep, $replace_with );
797 797
                     }
798 798
 
799
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
799
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
800 800
                         $replace_with = $field->name;
801
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
801
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
802 802
                         $replace_with = $field->description;
803
-                    } else if ( empty($replace_with) && $replace_with != '0' ) {
803
+                    } else if ( empty( $replace_with ) && $replace_with != '0' ) {
804 804
                         $replace_with = '';
805 805
                     } else {
806
-                        $replace_with = self::get_display_value($replace_with, $field, $atts);
806
+                        $replace_with = self::get_display_value( $replace_with, $field, $atts );
807 807
                     }
808 808
 
809
-                    unset($field);
809
+                    unset( $field );
810 810
                 break;
811 811
             }
812 812
 
813
-            if ( isset($replace_with) ) {
814
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
813
+            if ( isset( $replace_with ) ) {
814
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
815 815
             }
816 816
 
817
-            unset($atts, $conditional, $replace_with);
817
+            unset( $atts, $conditional, $replace_with );
818 818
 		}
819 819
 
820 820
 		return $content;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
         $new_value = '';
831 831
         switch ( $tag ) {
832 832
             case 'admin_email':
833
-                $new_value = get_option('admin_email');
833
+                $new_value = get_option( 'admin_email' );
834 834
                 break;
835 835
             case 'siteurl':
836 836
                 $new_value = FrmAppHelper::site_url();
@@ -856,28 +856,28 @@  discard block
 block discarded – undo
856 856
      * @return string|array
857 857
      */
858 858
     public static function process_get_shortcode( $atts, $return_array = false ) {
859
-        if ( ! isset($atts['param']) ) {
859
+        if ( ! isset( $atts['param'] ) ) {
860 860
             return '';
861 861
         }
862 862
 
863
-        if ( strpos($atts['param'], '&#91;') ) {
864
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
865
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
863
+        if ( strpos( $atts['param'], '&#91;' ) ) {
864
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
865
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
866 866
         }
867 867
 
868
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
868
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
869 869
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
870 870
 
871 871
         if ( $new_value == '' ) {
872
-            if ( ! isset($atts['prev_val']) ) {
872
+            if ( ! isset( $atts['prev_val'] ) ) {
873 873
                 $atts['prev_val'] = '';
874 874
             }
875 875
 
876
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
876
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
877 877
         }
878 878
 
879
-        if ( is_array($new_value) && ! $return_array ) {
880
-            $new_value = implode(', ', $new_value);
879
+        if ( is_array( $new_value ) && ! $return_array ) {
880
+            $new_value = implode( ', ', $new_value );
881 881
         }
882 882
 
883 883
         return $new_value;
@@ -889,12 +889,12 @@  discard block
 block discarded – undo
889 889
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
890 890
 
891 891
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
892
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
893
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
894
-                if ( is_array($replace_with) ) {
895
-                    $replace_with = implode("\n", $replace_with);
892
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
893
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
894
+                if ( is_array( $replace_with ) ) {
895
+                    $replace_with = implode( "\n", $replace_with );
896 896
                 }
897
-                $replace_with = wpautop($replace_with);
897
+                $replace_with = wpautop( $replace_with );
898 898
             }
899 899
 			unset( $autop );
900 900
 		} else if ( is_array( $replace_with ) ) {
@@ -916,14 +916,14 @@  discard block
 block discarded – undo
916 916
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
917 917
 
918 918
         $field_types = array();
919
-        if ( in_array($type, $single_input) ) {
919
+        if ( in_array( $type, $single_input ) ) {
920 920
             self::field_types_for_input( $single_input, $field_selection, $field_types );
921
-        } else if ( in_array($type, $multiple_input) ) {
921
+        } else if ( in_array( $type, $multiple_input ) ) {
922 922
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
923
-        } else if ( in_array($type, $other_type) ) {
923
+        } else if ( in_array( $type, $other_type ) ) {
924 924
             self::field_types_for_input( $other_type, $field_selection, $field_types );
925
-		} else if ( isset( $field_selection[ $type ] ) ) {
926
-            $field_types[ $type ] = $field_selection[ $type ];
925
+		} else if ( isset( $field_selection[$type] ) ) {
926
+            $field_types[$type] = $field_selection[$type];
927 927
         }
928 928
 
929 929
         return $field_types;
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 
932 932
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
933 933
         foreach ( $inputs as $input ) {
934
-            $field_types[ $input ] = $fields[ $input ];
935
-            unset($input);
934
+            $field_types[$input] = $fields[$input];
935
+            unset( $input );
936 936
         }
937 937
     }
938 938
 
@@ -977,21 +977,21 @@  discard block
 block discarded – undo
977 977
 		// Check posted vals before checking saved values
978 978
 
979 979
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
980
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
980
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
981 981
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
982
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
982
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
983 983
 			} else {
984
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
984
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
985 985
 			}
986 986
 			return $other_val;
987 987
 
988
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
988
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
989 989
 			// For normal fields
990 990
 
991 991
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
992
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
992
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
993 993
 			} else {
994
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
994
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
995 995
 			}
996 996
 			return $other_val;
997 997
 		}
@@ -1000,8 +1000,8 @@  discard block
 block discarded – undo
1000 1000
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
1001 1001
 			// Check if there is an "other" val in saved value and make sure the
1002 1002
 			// "other" val is not equal to the Other checkbox option
1003
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
1004
-				$other_val = $field['value'][ $opt_key ];
1003
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
1004
+				$other_val = $field['value'][$opt_key];
1005 1005
 			}
1006 1006
 		} else {
1007 1007
 			/**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 				// Multi-select dropdowns - key is not preserved
1014 1014
 				if ( is_array( $field['value'] ) ) {
1015 1015
 					$o_key = array_search( $temp_val, $field['value'] );
1016
-					if ( isset( $field['value'][ $o_key ] ) ) {
1017
-						unset( $field['value'][ $o_key ], $o_key );
1016
+					if ( isset( $field['value'][$o_key] ) ) {
1017
+						unset( $field['value'][$o_key], $o_key );
1018 1018
 					}
1019 1019
 				} else if ( $temp_val == $field['value'] ) {
1020 1020
 					// For radio and regular dropdowns
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	private static function set_other_name( $args, &$other_args ) {
1072 1072
 		//Set up name for other field
1073 1073
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1074
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1074
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1075 1075
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1076 1076
 
1077 1077
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		// Count should only be greater than 3 if inside of a repeating section
1098 1098
 		if ( count( $temp_array ) > 3 ) {
1099 1099
 			$parent = str_replace( ']', '', $temp_array[1] );
1100
-			$pointer = str_replace( ']', '', $temp_array[2]);
1100
+			$pointer = str_replace( ']', '', $temp_array[2] );
1101 1101
 		}
1102 1102
 
1103 1103
 		// Get text for "other" text field
@@ -1199,29 +1199,29 @@  discard block
 block discarded – undo
1199 1199
         $replace = array();
1200 1200
         $replace_with = array();
1201 1201
         foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1202
-            $replace[] = '[if '. $old .']';
1203
-            $replace_with[] = '[if '. $new .']';
1204
-            $replace[] = '[if '. $old .' ';
1205
-            $replace_with[] = '[if '. $new .' ';
1206
-            $replace[] = '[/if '. $old .']';
1207
-            $replace_with[] = '[/if '. $new .']';
1208
-            $replace[] = '[foreach '. $old .']';
1209
-            $replace_with[] = '[foreach '. $new .']';
1210
-            $replace[] = '[/foreach '. $old .']';
1211
-            $replace_with[] = '[/foreach '. $new .']';
1212
-            $replace[] = '['. $old .']';
1213
-            $replace_with[] = '['. $new .']';
1214
-            $replace[] = '['. $old .' ';
1215
-            $replace_with[] = '['. $new .' ';
1216
-            unset($old, $new);
1202
+            $replace[] = '[if ' . $old . ']';
1203
+            $replace_with[] = '[if ' . $new . ']';
1204
+            $replace[] = '[if ' . $old . ' ';
1205
+            $replace_with[] = '[if ' . $new . ' ';
1206
+            $replace[] = '[/if ' . $old . ']';
1207
+            $replace_with[] = '[/if ' . $new . ']';
1208
+            $replace[] = '[foreach ' . $old . ']';
1209
+            $replace_with[] = '[foreach ' . $new . ']';
1210
+            $replace[] = '[/foreach ' . $old . ']';
1211
+            $replace_with[] = '[/foreach ' . $new . ']';
1212
+            $replace[] = '[' . $old . ']';
1213
+            $replace_with[] = '[' . $new . ']';
1214
+            $replace[] = '[' . $old . ' ';
1215
+            $replace_with[] = '[' . $new . ' ';
1216
+            unset( $old, $new );
1217 1217
         }
1218 1218
 		if ( is_array( $val ) ) {
1219 1219
 			foreach ( $val as $k => $v ) {
1220
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1221
-                unset($k, $v);
1220
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1221
+                unset( $k, $v );
1222 1222
             }
1223 1223
         } else {
1224
-            $val = str_replace($replace, $replace_with, $val);
1224
+            $val = str_replace( $replace, $replace_with, $val );
1225 1225
         }
1226 1226
 
1227 1227
         return $val;
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
             'DC' => 'District of Columbia',
1235 1235
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1236 1236
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1237
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1237
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1238 1238
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1239 1239
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1240 1240
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1325,35 +1325,35 @@  discard block
 block discarded – undo
1325 1325
     }
1326 1326
 
1327 1327
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1328
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1328
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1329 1329
 
1330 1330
         $states = FrmFieldsHelper::get_us_states();
1331
-        $state_abv = array_keys($states);
1332
-        sort($state_abv);
1333
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1331
+        $state_abv = array_keys( $states );
1332
+        sort( $state_abv );
1333
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1334 1334
 
1335
-        $states = array_values($states);
1336
-        sort($states);
1337
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1338
-        unset($state_abv, $states);
1335
+        $states = array_values( $states );
1336
+        sort( $states );
1337
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1338
+        unset( $state_abv, $states );
1339 1339
 
1340
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1340
+		$prepop[__( 'Age', 'formidable' )] = array(
1341 1341
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1342 1342
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1343 1343
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1344 1344
         );
1345 1345
 
1346
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1346
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1347 1347
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1348 1348
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1349 1349
         );
1350 1350
 
1351
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1351
+		$prepop[__( 'Importance', 'formidable' )] = array(
1352 1352
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1353 1353
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1354 1354
         );
1355 1355
 
1356
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1356
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1357 1357
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1358 1358
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1359 1359
         );
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +628 added lines, -628 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,127 +24,127 @@  discard block
 block discarded – undo
24 24
 		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
28
+		wp_enqueue_script('formidable-editinplace');
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+			return self::create($values);
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
63
-            $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
62
+			$values = FrmFormsHelper::setup_new_vars($values);
63
+			$id = FrmForm::create( $values );
64
+			$form = FrmForm::getOne($id);
65 65
 
66
-            // add default email notification
67
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
66
+			// add default email notification
67
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
68
+			$action_control->create($form->id);
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72
-            $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
-        }
75
-    }
72
+			$values['id'] = $id;
73
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
74
+		}
75
+	}
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+		FrmAppHelper::permission_check('frm_edit_forms');
79 79
 
80
-        global $frm_vars;
81
-        if ( empty( $values ) ) {
82
-            $values = $_POST;
83
-        }
80
+		global $frm_vars;
81
+		if ( empty( $values ) ) {
82
+			$values = $_POST;
83
+		}
84 84
 
85
-        //Set radio button and checkbox meta equal to "other" value
86
-        if ( FrmAppHelper::pro_is_installed() ) {
87
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
88
-        }
85
+		//Set radio button and checkbox meta equal to "other" value
86
+		if ( FrmAppHelper::pro_is_installed() ) {
87
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
88
+		}
89 89
 
90 90
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
-            $frm_settings = FrmAppHelper::get_settings();
94
-            $errors = array( 'form' => $frm_settings->admin_permission );
95
-        } else {
96
-            $errors = FrmForm::validate($values);
97
-        }
92
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93
+			$frm_settings = FrmAppHelper::get_settings();
94
+			$errors = array( 'form' => $frm_settings->admin_permission );
95
+		} else {
96
+			$errors = FrmForm::validate($values);
97
+		}
98 98
 
99
-        if ( count($errors) > 0 ) {
100
-            $hide_preview = true;
99
+		if ( count($errors) > 0 ) {
100
+			$hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102
-            $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
102
+			$form = FrmForm::getOne( $id );
103
+			$fields = FrmField::get_all_for_form($id);
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
-        } else {
110
-            FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
-        }
113
-    }
108
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
109
+		} else {
110
+			FrmForm::update( $id, $values, true );
111
+			die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
112
+		}
113
+	}
114 114
 
115
-    public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
115
+	public static function edit( $values = false ) {
116
+		FrmAppHelper::permission_check('frm_edit_forms');
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
120
-    }
119
+		return self::get_edit_vars($id);
120
+	}
121 121
 
122
-    public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
122
+	public static function settings( $id = false, $message = '' ) {
123
+		FrmAppHelper::permission_check('frm_edit_forms');
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+		if ( ! $id || ! is_numeric($id) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127
-        }
127
+		}
128 128
 		return self::get_settings_vars( $id, array(), $message );
129
-    }
129
+	}
130 130
 
131
-    public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function update_settings() {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
139
-        }
136
+		$errors = FrmForm::validate($_POST);
137
+		if ( count($errors) > 0 ) {
138
+			return self::get_settings_vars($id, $errors);
139
+		}
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+		do_action('frm_before_update_form_settings', $id);
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
145
-        $message = __( 'Settings Successfully Updated', 'formidable' );
145
+		$message = __( 'Settings Successfully Updated', 'formidable' );
146 146
 		return self::get_settings_vars( $id, array(), $message );
147
-    }
147
+	}
148 148
 
149 149
 	public static function edit_key() {
150 150
 		$values = self::edit_in_place_value( 'form_key' );
@@ -174,43 +174,43 @@  discard block
 block discarded – undo
174 174
 
175 175
 	public static function update( $values = array() ) {
176 176
 		if ( empty( $values ) ) {
177
-            $values = $_POST;
178
-        }
177
+			$values = $_POST;
178
+		}
179 179
 
180
-        //Set radio button and checkbox meta equal to "other" value
181
-        if ( FrmAppHelper::pro_is_installed() ) {
182
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
183
-        }
180
+		//Set radio button and checkbox meta equal to "other" value
181
+		if ( FrmAppHelper::pro_is_installed() ) {
182
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
183
+		}
184 184
 
185
-        $errors = FrmForm::validate( $values );
186
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
-        if ( $permission_error !== false ) {
188
-            $errors['form'] = $permission_error;
189
-        }
185
+		$errors = FrmForm::validate( $values );
186
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
187
+		if ( $permission_error !== false ) {
188
+			$errors['form'] = $permission_error;
189
+		}
190 190
 
191 191
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
192 192
 
193 193
 		if ( count( $errors ) > 0 ) {
194
-            return self::get_edit_vars( $id, $errors );
194
+			return self::get_edit_vars( $id, $errors );
195 195
 		} else {
196
-            FrmForm::update( $id, $values );
197
-            $message = __( 'Form was Successfully Updated', 'formidable' );
198
-            if ( defined( 'DOING_AJAX' ) ) {
196
+			FrmForm::update( $id, $values );
197
+			$message = __( 'Form was Successfully Updated', 'formidable' );
198
+			if ( defined( 'DOING_AJAX' ) ) {
199 199
 				wp_die( $message );
200
-            }
200
+			}
201 201
 			return self::get_edit_vars( $id, array(), $message );
202
-        }
203
-    }
202
+		}
203
+	}
204 204
 
205
-    public static function bulk_create_template( $ids ) {
206
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
205
+	public static function bulk_create_template( $ids ) {
206
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
207 207
 
208
-        foreach ( $ids as $id ) {
209
-            FrmForm::duplicate( $id, true, true );
210
-        }
208
+		foreach ( $ids as $id ) {
209
+			FrmForm::duplicate( $id, true, true );
210
+		}
211 211
 
212
-        return __( 'Form template was Successfully Created', 'formidable' );
213
-    }
212
+		return __( 'Form template was Successfully Created', 'formidable' );
213
+	}
214 214
 
215 215
 	/**
216 216
 	 * Redirect to the url for creating from a template
@@ -232,45 +232,45 @@  discard block
 block discarded – undo
232 232
 		wp_die();
233 233
 	}
234 234
 
235
-    public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
235
+	public static function duplicate() {
236
+		FrmAppHelper::permission_check('frm_edit_forms');
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
-        if ( $form ) {
239
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241
+		if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243
-        } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
-        }
246
-    }
243
+		} else {
244
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
245
+		}
246
+	}
247 247
 
248
-    public static function page_preview() {
248
+	public static function page_preview() {
249 249
 		$params = FrmForm::list_page_params();
250
-        if ( ! $params['form'] ) {
251
-            return;
252
-        }
253
-
254
-        $form = FrmForm::getOne( $params['form'] );
255
-        if ( ! $form ) {
256
-            return;
257
-        }
258
-        return self::show_form( $form->id, '', true, true );
259
-    }
260
-
261
-    public static function preview() {
262
-        do_action( 'frm_wp' );
263
-
264
-        global $frm_vars;
265
-        $frm_vars['preview'] = true;
266
-
267
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
-            global $wp;
269
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
271
-            $wp->init();
272
-            $wp->register_globals();
273
-        }
250
+		if ( ! $params['form'] ) {
251
+			return;
252
+		}
253
+
254
+		$form = FrmForm::getOne( $params['form'] );
255
+		if ( ! $form ) {
256
+			return;
257
+		}
258
+		return self::show_form( $form->id, '', true, true );
259
+	}
260
+
261
+	public static function preview() {
262
+		do_action( 'frm_wp' );
263
+
264
+		global $frm_vars;
265
+		$frm_vars['preview'] = true;
266
+
267
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268
+			global $wp;
269
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
+			include_once( $root.'/wp-config.php' );
271
+			$wp->init();
272
+			$wp->register_globals();
273
+		}
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
285 285
 		if ( empty( $form ) ) {
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287
-        }
287
+		}
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
-        wp_die();
291
-    }
289
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
290
+		wp_die();
291
+	}
292 292
 
293 293
 	public static function register_pro_scripts() {
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
@@ -298,22 +298,22 @@  discard block
 block discarded – undo
298 298
 		}
299 299
 	}
300 300
 
301
-    public static function untrash() {
301
+	public static function untrash() {
302 302
 		self::change_form_status( 'untrash' );
303
-    }
303
+	}
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+		FrmAppHelper::permission_check('frm_edit_forms');
307 307
 
308
-        $count = FrmForm::set_status( $ids, 'published' );
308
+		$count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
-        return $message;
312
-    }
310
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311
+		return $message;
312
+	}
313 313
 
314
-    public static function trash() {
314
+	public static function trash() {
315 315
 		self::change_form_status( 'trash' );
316
-    }
316
+	}
317 317
 
318 318
 	/**
319 319
 	 * @param string $status
@@ -351,68 +351,68 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+		FrmAppHelper::permission_check('frm_delete_forms');
355 355
 
356
-        $count = 0;
357
-        foreach ( $ids as $id ) {
358
-            if ( FrmForm::trash( $id ) ) {
359
-                $count++;
360
-            }
361
-        }
356
+		$count = 0;
357
+		foreach ( $ids as $id ) {
358
+			if ( FrmForm::trash( $id ) ) {
359
+				$count++;
360
+			}
361
+		}
362 362
 
363
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
363
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
+		$message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
365 365
 
366
-        return $message;
367
-    }
366
+		return $message;
367
+	}
368 368
 
369
-    public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
369
+	public static function destroy() {
370
+		FrmAppHelper::permission_check('frm_delete_forms');
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374
-        //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
374
+		//check nonce url
375
+		check_admin_referer('destroy_form_' . $params['id']);
376 376
 
377
-        $count = 0;
378
-        if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
380
-        }
377
+		$count = 0;
378
+		if ( FrmForm::destroy( $params['id'] ) ) {
379
+			$count++;
380
+		}
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385
-    }
385
+	}
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+		FrmAppHelper::permission_check('frm_delete_forms');
389 389
 
390
-        $count = 0;
391
-        foreach ( $ids as $id ) {
392
-            $d = FrmForm::destroy( $id );
393
-            if ( $d ) {
394
-                $count++;
395
-            }
396
-        }
390
+		$count = 0;
391
+		foreach ( $ids as $id ) {
392
+			$d = FrmForm::destroy( $id );
393
+			if ( $d ) {
394
+				$count++;
395
+			}
396
+		}
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
399 399
 
400
-        return $message;
401
-    }
400
+		return $message;
401
+	}
402 402
 
403
-    private static function delete_all() {
404
-        //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
-        if ( $permission_error !== false ) {
403
+	private static function delete_all() {
404
+		//check nonce url
405
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
406
+		if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408
-            return;
409
-        }
408
+			return;
409
+		}
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415
-    }
415
+	}
416 416
 
417 417
 	public static function scheduled_delete( $delete_timestamp = '' ) {
418 418
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	}
421 421
 
422 422
 	/**
423
-	* Inserts Formidable button
424
-	* Hook exists since 2.5.0
425
-	*
426
-	* @since 2.0.15
427
-	*/
423
+	 * Inserts Formidable button
424
+	 * Hook exists since 2.5.0
425
+	 *
426
+	 * @since 2.0.15
427
+	 */
428 428
 	public static function insert_form_button() {
429 429
 		if ( current_user_can('frm_view_forms') ) {
430 430
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -435,49 +435,49 @@  discard block
 block discarded – undo
435 435
 		}
436 436
 	}
437 437
 
438
-    public static function insert_form_popup() {
438
+	public static function insert_form_popup() {
439 439
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
440 440
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
441
-            return;
442
-        }
441
+			return;
442
+		}
443 443
 
444
-        FrmAppHelper::load_admin_wide_js();
444
+		FrmAppHelper::load_admin_wide_js();
445 445
 
446
-        $shortcodes = array(
446
+		$shortcodes = array(
447 447
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
448
-        );
448
+		);
449 449
 
450
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
450
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
451 451
 
452
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
453
-    }
452
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
453
+	}
454 454
 
455
-    public static function get_shortcode_opts() {
455
+	public static function get_shortcode_opts() {
456 456
 		FrmAppHelper::permission_check('frm_view_forms');
457
-        check_ajax_referer( 'frm_ajax', 'nonce' );
457
+		check_ajax_referer( 'frm_ajax', 'nonce' );
458 458
 
459 459
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
460
-        if ( empty($shortcode) ) {
461
-            wp_die();
462
-        }
460
+		if ( empty($shortcode) ) {
461
+			wp_die();
462
+		}
463 463
 
464
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464
+		echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
+		echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
466 466
 
467
-        $form_id = '';
468
-        $opts = array();
467
+		$form_id = '';
468
+		$opts = array();
469 469
 		switch ( $shortcode ) {
470
-            case 'formidable':
471
-                $opts = array(
470
+			case 'formidable':
471
+				$opts = array(
472 472
 					'form_id'       => 'id',
473
-                    //'key' => ',
473
+					//'key' => ',
474 474
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
475 475
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
476 476
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
477
-                );
478
-            break;
479
-        }
480
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
477
+				);
478
+			break;
479
+		}
480
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
481 481
 
482 482
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
483 483
 			// allow other shortcodes to use the required form id option
@@ -485,63 +485,63 @@  discard block
 block discarded – undo
485 485
 			unset( $opts['form_id'] );
486 486
 		}
487 487
 
488
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
488
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
489 489
 
490
-        echo '</div>';
490
+		echo '</div>';
491 491
 
492
-        wp_die();
493
-    }
492
+		wp_die();
493
+	}
494 494
 
495 495
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
496
-        FrmAppHelper::permission_check( 'frm_view_forms' );
496
+		FrmAppHelper::permission_check( 'frm_view_forms' );
497 497
 		if ( ! empty( $deprecated_errors ) ) {
498 498
 			$errors = $deprecated_errors;
499 499
 			_deprecated_argument( 'errors', '2.0.8' );
500 500
 		}
501 501
 
502
-        global $wpdb, $frm_vars;
502
+		global $wpdb, $frm_vars;
503 503
 
504 504
 		if ( empty( $params ) ) {
505 505
 			$params = FrmForm::list_page_params();
506
-        }
506
+		}
507 507
 
508
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
508
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
509 509
 
510
-        $pagenum = $wp_list_table->get_pagenum();
510
+		$pagenum = $wp_list_table->get_pagenum();
511 511
 
512
-        $wp_list_table->prepare_items();
512
+		$wp_list_table->prepare_items();
513 513
 
514
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
515
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
514
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
515
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
516 516
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
517
-            die();
518
-        }
517
+			die();
518
+		}
519 519
 
520
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
521
-    }
520
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
521
+	}
522 522
 
523 523
 	public static function get_columns( $columns ) {
524
-	    $columns['cb'] = '<input type="checkbox" />';
525
-	    $columns['id'] = 'ID';
524
+		$columns['cb'] = '<input type="checkbox" />';
525
+		$columns['id'] = 'ID';
526 526
 
527
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
527
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published';
528 528
 
529
-        if ( 'template' == $type ) {
530
-            $columns['name']        = __( 'Template Name', 'formidable' );
531
-            $columns['type']        = __( 'Type', 'formidable' );
532
-            $columns['form_key']    = __( 'Key', 'formidable' );
533
-        } else {
534
-            $columns['name']        = __( 'Form Title', 'formidable' );
535
-            $columns['entries']     = __( 'Entries', 'formidable' );
536
-            $columns['form_key']    = __( 'Key', 'formidable' );
537
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
538
-        }
529
+		if ( 'template' == $type ) {
530
+			$columns['name']        = __( 'Template Name', 'formidable' );
531
+			$columns['type']        = __( 'Type', 'formidable' );
532
+			$columns['form_key']    = __( 'Key', 'formidable' );
533
+		} else {
534
+			$columns['name']        = __( 'Form Title', 'formidable' );
535
+			$columns['entries']     = __( 'Entries', 'formidable' );
536
+			$columns['form_key']    = __( 'Key', 'formidable' );
537
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
538
+		}
539 539
 
540
-        $columns['created_at'] = __( 'Date', 'formidable' );
540
+		$columns['created_at'] = __( 'Date', 'formidable' );
541 541
 
542 542
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
543 543
 
544
-        return $columns;
544
+		return $columns;
545 545
 	}
546 546
 
547 547
 	public static function get_sortable_columns() {
@@ -555,110 +555,110 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	public static function hidden_columns( $result ) {
558
-        $return = false;
559
-        foreach ( (array) $result as $r ) {
560
-            if ( ! empty( $r ) ) {
561
-                $return = true;
562
-                break;
563
-            }
564
-        }
558
+		$return = false;
559
+		foreach ( (array) $result as $r ) {
560
+			if ( ! empty( $r ) ) {
561
+				$return = true;
562
+				break;
563
+			}
564
+		}
565 565
 
566
-        if ( $return ) {
567
-            return $result;
566
+		if ( $return ) {
567
+			return $result;
568 568
 		}
569 569
 
570
-        $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
570
+		$type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
571 571
 
572
-        $result[] = 'created_at';
573
-        if ( $type == 'template' ) {
574
-            $result[] = 'id';
575
-            $result[] = 'form_key';
576
-        }
572
+		$result[] = 'created_at';
573
+		if ( $type == 'template' ) {
574
+			$result[] = 'id';
575
+			$result[] = 'form_key';
576
+		}
577 577
 
578
-        return $result;
579
-    }
578
+		return $result;
579
+	}
580 580
 
581 581
 	public static function save_per_page( $save, $option, $value ) {
582
-        if ( $option == 'formidable_page_formidable_per_page' ) {
583
-            $save = (int) $value;
584
-        }
585
-        return $save;
586
-    }
582
+		if ( $option == 'formidable_page_formidable_per_page' ) {
583
+			$save = (int) $value;
584
+		}
585
+		return $save;
586
+	}
587 587
 
588 588
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
589
-        global $frm_vars;
589
+		global $frm_vars;
590 590
 
591
-        $form = FrmForm::getOne( $id );
592
-        if ( ! $form ) {
593
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
-        }
591
+		$form = FrmForm::getOne( $id );
592
+		if ( ! $form ) {
593
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
594
+		}
595 595
 
596
-        if ( $form->parent_form_id ) {
596
+		if ( $form->parent_form_id ) {
597 597
 			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' ));
598
-        }
598
+		}
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+		$fields = FrmField::get_all_for_form($form->id);
602 602
 
603
-        // Automatically add end section fields if they don't exist (2.0 migration)
604
-        $reset_fields = false;
605
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
603
+		// Automatically add end section fields if they don't exist (2.0 migration)
604
+		$reset_fields = false;
605
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
606 606
 
607
-        if ( $reset_fields ) {
608
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
-        }
607
+		if ( $reset_fields ) {
608
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609
+		}
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+		unset($end_section_values, $last_order, $open, $reset_fields);
612 612
 
613
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
613
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
614 614
 
615
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
616
-        if ( $form->is_template && $message == $edit_message ) {
617
-            $message = __( 'Template was Successfully Updated', 'formidable' );
618
-        }
615
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
616
+		if ( $form->is_template && $message == $edit_message ) {
617
+			$message = __( 'Template was Successfully Updated', 'formidable' );
618
+		}
619 619
 
620 620
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
621 621
 
622
-        if ( $form->default_template ) {
623
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
624
-        } else if ( defined('DOING_AJAX') ) {
625
-            wp_die();
626
-        } else if ( $create_link ) {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
628
-        } else {
629
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
630
-        }
631
-    }
622
+		if ( $form->default_template ) {
623
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
624
+		} else if ( defined('DOING_AJAX') ) {
625
+			wp_die();
626
+		} else if ( $create_link ) {
627
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
628
+		} else {
629
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
630
+		}
631
+	}
632 632
 
633 633
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
634 634
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
635 635
 
636
-        global $frm_vars;
636
+		global $frm_vars;
637 637
 
638
-        $form = FrmForm::getOne( $id );
638
+		$form = FrmForm::getOne( $id );
639 639
 
640
-        $fields = FrmField::get_all_for_form($id);
641
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640
+		$fields = FrmField::get_all_for_form($id);
641
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
642 642
 
643
-        if ( isset($values['default_template']) && $values['default_template'] ) {
644
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
645
-        }
643
+		if ( isset($values['default_template']) && $values['default_template'] ) {
644
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
645
+		}
646 646
 
647
-        $action_controls = FrmFormActionsController::get_form_actions();
647
+		$action_controls = FrmFormActionsController::get_form_actions();
648 648
 
649
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
650
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
649
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
650
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
651 651
 
652
-        $styles = apply_filters('frm_get_style_opts', array());
652
+		$styles = apply_filters('frm_get_style_opts', array());
653 653
 
654
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
655
-    }
654
+		require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
655
+	}
656 656
 
657
-    public static function mb_tags_box( $form_id, $class = '' ) {
658
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
659
-        $linked_forms = array();
660
-        $col = 'one';
661
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
657
+	public static function mb_tags_box( $form_id, $class = '' ) {
658
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
659
+		$linked_forms = array();
660
+		$col = 'one';
661
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
662 662
 
663 663
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
664 664
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
667 667
 
668 668
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
669
-    }
669
+	}
670 670
 
671 671
 	/**
672 672
 	 * Get an array of the options to display in the advanced tab
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 			''          => '',
708 708
 			'siteurl'   => __( 'Site URL', 'formidable' ),
709 709
 			'sitename'  => __( 'Site Name', 'formidable' ),
710
-        );
710
+		);
711 711
 
712 712
 		if ( ! FrmAppHelper::pro_is_installed() ) {
713 713
 			unset( $entry_shortcodes['post_id'] );
@@ -734,39 +734,39 @@  discard block
 block discarded – undo
734 734
 		return $entry_shortcodes;
735 735
 	}
736 736
 
737
-    // Insert the form class setting into the form
737
+	// Insert the form class setting into the form
738 738
 	public static function form_classes( $form ) {
739
-        if ( isset($form->options['form_class']) ) {
739
+		if ( isset($form->options['form_class']) ) {
740 740
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
741
-        }
742
-    }
741
+		}
742
+	}
743 743
 
744
-    public static function get_email_html() {
744
+	public static function get_email_html() {
745 745
 		FrmAppHelper::permission_check('frm_view_forms');
746
-        check_ajax_referer( 'frm_ajax', 'nonce' );
746
+		check_ajax_referer( 'frm_ajax', 'nonce' );
747 747
 		echo FrmEntryFormat::show_entry( array(
748 748
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
749
-	        'default_email' => true,
749
+			'default_email' => true,
750 750
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
751
-	    ) );
752
-	    wp_die();
751
+		) );
752
+		wp_die();
753 753
 	}
754 754
 
755
-    public static function filter_content( $content, $form, $entry = false ) {
755
+	public static function filter_content( $content, $form, $entry = false ) {
756 756
 		self::get_entry_by_param( $entry );
757
-        if ( ! $entry ) {
758
-            return $content;
759
-        }
757
+		if ( ! $entry ) {
758
+			return $content;
759
+		}
760 760
 
761
-        if ( is_object( $form ) ) {
762
-            $form = $form->id;
763
-        }
761
+		if ( is_object( $form ) ) {
762
+			$form = $form->id;
763
+		}
764 764
 
765
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
766
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
765
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
766
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
767 767
 
768
-        return $content;
769
-    }
768
+		return $content;
769
+	}
770 770
 
771 771
 	private static function get_entry_by_param( &$entry ) {
772 772
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -778,287 +778,287 @@  discard block
 block discarded – undo
778 778
 		}
779 779
 	}
780 780
 
781
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
782
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
783
-    }
781
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
782
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
783
+	}
784 784
 
785
-    public static function process_bulk_form_actions( $errors ) {
786
-        if ( ! $_REQUEST ) {
787
-            return $errors;
788
-        }
785
+	public static function process_bulk_form_actions( $errors ) {
786
+		if ( ! $_REQUEST ) {
787
+			return $errors;
788
+		}
789 789
 
790 790
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
791
-        if ( $bulkaction == -1 ) {
791
+		if ( $bulkaction == -1 ) {
792 792
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
793
-        }
794
-
795
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
796
-            FrmAppHelper::remove_get_action();
797
-
798
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
799
-        }
800
-
801
-        $ids = FrmAppHelper::get_param( 'item-action', '' );
802
-        if ( empty( $ids ) ) {
803
-            $errors[] = __( 'No forms were specified', 'formidable' );
804
-            return $errors;
805
-        }
806
-
807
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
808
-        if ( $permission_error !== false ) {
809
-            $errors[] = $permission_error;
810
-            return $errors;
811
-        }
812
-
813
-        if ( ! is_array( $ids ) ) {
814
-            $ids = explode( ',', $ids );
815
-        }
816
-
817
-        switch ( $bulkaction ) {
818
-            case 'delete':
819
-                $message = self::bulk_destroy( $ids );
820
-            break;
821
-            case 'trash':
822
-                $message = self::bulk_trash( $ids );
823
-            break;
824
-            case 'untrash':
825
-                $message = self::bulk_untrash( $ids );
826
-            break;
827
-            case 'create_template':
828
-                $message = self::bulk_create_template( $ids );
829
-            break;
830
-        }
831
-
832
-        if ( isset( $message ) && ! empty( $message ) ) {
793
+		}
794
+
795
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
796
+			FrmAppHelper::remove_get_action();
797
+
798
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
799
+		}
800
+
801
+		$ids = FrmAppHelper::get_param( 'item-action', '' );
802
+		if ( empty( $ids ) ) {
803
+			$errors[] = __( 'No forms were specified', 'formidable' );
804
+			return $errors;
805
+		}
806
+
807
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
808
+		if ( $permission_error !== false ) {
809
+			$errors[] = $permission_error;
810
+			return $errors;
811
+		}
812
+
813
+		if ( ! is_array( $ids ) ) {
814
+			$ids = explode( ',', $ids );
815
+		}
816
+
817
+		switch ( $bulkaction ) {
818
+			case 'delete':
819
+				$message = self::bulk_destroy( $ids );
820
+			break;
821
+			case 'trash':
822
+				$message = self::bulk_trash( $ids );
823
+			break;
824
+			case 'untrash':
825
+				$message = self::bulk_untrash( $ids );
826
+			break;
827
+			case 'create_template':
828
+				$message = self::bulk_create_template( $ids );
829
+			break;
830
+		}
831
+
832
+		if ( isset( $message ) && ! empty( $message ) ) {
833 833
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>';
834
-        }
834
+		}
835 835
 
836
-        return $errors;
837
-    }
836
+		return $errors;
837
+	}
838 838
 
839
-    public static function add_default_templates( $path, $default = true, $template = true ) {
840
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
839
+	public static function add_default_templates( $path, $default = true, $template = true ) {
840
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
841 841
 
842
-        $path = untrailingslashit(trim($path));
843
-        $templates = glob( $path .'/*.php' );
842
+		$path = untrailingslashit(trim($path));
843
+		$templates = glob( $path .'/*.php' );
844 844
 
845 845
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
846
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
846
+			$filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
847 847
 			$template_query = array( 'form_key' => $filename );
848
-            if ( $template ) {
849
-                $template_query['is_template'] = 1;
850
-            }
851
-            if ( $default ) {
852
-                $template_query['default_template'] = 1;
853
-            }
848
+			if ( $template ) {
849
+				$template_query['is_template'] = 1;
850
+			}
851
+			if ( $default ) {
852
+				$template_query['default_template'] = 1;
853
+			}
854 854
 			$form = FrmForm::getAll( $template_query, '', 1 );
855 855
 
856
-            $values = FrmFormsHelper::setup_new_vars();
857
-            $values['form_key'] = $filename;
858
-            $values['is_template'] = $template;
859
-            $values['status'] = 'published';
860
-            if ( $default ) {
861
-                $values['default_template'] = 1;
862
-            }
863
-
864
-            include( $templates[ $i ] );
865
-
866
-            //get updated form
867
-            if ( isset($form) && ! empty($form) ) {
868
-                $old_id = $form->id;
869
-                $form = FrmForm::getOne($form->id);
870
-            } else {
871
-                $old_id = false;
856
+			$values = FrmFormsHelper::setup_new_vars();
857
+			$values['form_key'] = $filename;
858
+			$values['is_template'] = $template;
859
+			$values['status'] = 'published';
860
+			if ( $default ) {
861
+				$values['default_template'] = 1;
862
+			}
863
+
864
+			include( $templates[ $i ] );
865
+
866
+			//get updated form
867
+			if ( isset($form) && ! empty($form) ) {
868
+				$old_id = $form->id;
869
+				$form = FrmForm::getOne($form->id);
870
+			} else {
871
+				$old_id = false;
872 872
 				$form = FrmForm::getAll( $template_query, '', 1 );
873
-            }
873
+			}
874 874
 
875
-            if ( $form ) {
875
+			if ( $form ) {
876 876
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
877
-            }
878
-        }
879
-    }
877
+			}
878
+		}
879
+	}
880 880
 
881
-    public static function route() {
882
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
883
-        $vars = array();
881
+	public static function route() {
882
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
883
+		$vars = array();
884 884
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
885 885
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
886 886
 
887
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
-            $json_vars = json_decode($json_vars, true);
889
-            if ( empty($json_vars) ) {
890
-                // json decoding failed so we should return an error message
887
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
+			$json_vars = json_decode($json_vars, true);
889
+			if ( empty($json_vars) ) {
890
+				// json decoding failed so we should return an error message
891 891
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
892
-                if ( 'edit' == $action ) {
893
-                    $action = 'update';
894
-                }
895
-
896
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
897
-            } else {
898
-                $vars = FrmAppHelper::json_to_array($json_vars);
899
-                $action = $vars[ $action ];
892
+				if ( 'edit' == $action ) {
893
+					$action = 'update';
894
+				}
895
+
896
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
897
+			} else {
898
+				$vars = FrmAppHelper::json_to_array($json_vars);
899
+				$action = $vars[ $action ];
900 900
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
901 901
 				$_REQUEST = array_merge( $_REQUEST, $vars );
902 902
 				$_POST = array_merge( $_POST, $_REQUEST );
903
-            }
904
-        } else {
903
+			}
904
+		} else {
905 905
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
906
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
907
-                // override the action for this page
908
-    			$action = 'delete_all';
909
-            }
910
-        }
906
+			if ( isset( $_REQUEST['delete_all'] ) ) {
907
+				// override the action for this page
908
+				$action = 'delete_all';
909
+			}
910
+		}
911 911
 
912 912
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
913
-        FrmAppHelper::trigger_hook_load( 'form' );
914
-
915
-        switch ( $action ) {
916
-            case 'new':
917
-                return self::new_form($vars);
918
-            case 'create':
919
-            case 'edit':
920
-            case 'update':
921
-            case 'duplicate':
922
-            case 'trash':
923
-            case 'untrash':
924
-            case 'destroy':
925
-            case 'delete_all':
926
-            case 'settings':
927
-            case 'update_settings':
913
+		FrmAppHelper::trigger_hook_load( 'form' );
914
+
915
+		switch ( $action ) {
916
+			case 'new':
917
+				return self::new_form($vars);
918
+			case 'create':
919
+			case 'edit':
920
+			case 'update':
921
+			case 'duplicate':
922
+			case 'trash':
923
+			case 'untrash':
924
+			case 'destroy':
925
+			case 'delete_all':
926
+			case 'settings':
927
+			case 'update_settings':
928 928
 				return self::$action( $vars );
929
-            default:
930
-                do_action('frm_form_action_'. $action);
931
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
932
-                    return;
933
-                }
929
+			default:
930
+				do_action('frm_form_action_'. $action);
931
+				if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
932
+					return;
933
+				}
934 934
 
935 935
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
936
-                if ( $action == -1 ) {
936
+				if ( $action == -1 ) {
937 937
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
938
-                }
938
+				}
939 939
 
940
-                if ( strpos($action, 'bulk_') === 0 ) {
941
-                    FrmAppHelper::remove_get_action();
942
-                    return self::list_form();
943
-                }
940
+				if ( strpos($action, 'bulk_') === 0 ) {
941
+					FrmAppHelper::remove_get_action();
942
+					return self::list_form();
943
+				}
944 944
 
945
-                return self::display_forms_list();
946
-        }
947
-    }
945
+				return self::display_forms_list();
946
+		}
947
+	}
948 948
 
949
-    public static function json_error( $errors ) {
950
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
951
-        return $errors;
952
-    }
949
+	public static function json_error( $errors ) {
950
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
951
+		return $errors;
952
+	}
953 953
 
954 954
 
955
-    /* FRONT-END FORMS */
956
-    public static function admin_bar_css() {
955
+	/* FRONT-END FORMS */
956
+	public static function admin_bar_css() {
957 957
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
958
-            return;
959
-        }
958
+			return;
959
+		}
960 960
 
961 961
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
962 962
 		FrmAppHelper::load_font_style();
963 963
 	}
964 964
 
965 965
 	public static function admin_bar_configure() {
966
-        global $frm_vars;
967
-        if ( empty($frm_vars['forms_loaded']) ) {
968
-            return;
969
-        }
970
-
971
-        $actions = array();
972
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
973
-            if ( is_object($form) ) {
974
-                $actions[ $form->id ] = $form->name;
975
-            }
976
-            unset($form);
977
-        }
978
-
979
-        if ( empty($actions) ) {
980
-            return;
981
-        }
982
-
983
-        asort($actions);
984
-
985
-        global $wp_admin_bar;
986
-
987
-        if ( count($actions) == 1 ) {
988
-            $wp_admin_bar->add_menu( array(
989
-                'title' => 'Edit Form',
990
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
991
-                'id'    => 'frm-forms',
992
-            ) );
993
-        } else {
994
-            $wp_admin_bar->add_menu( array(
995
-        		'id'    => 'frm-forms',
996
-        		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
998
-        		'meta'  => array(
966
+		global $frm_vars;
967
+		if ( empty($frm_vars['forms_loaded']) ) {
968
+			return;
969
+		}
970
+
971
+		$actions = array();
972
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
973
+			if ( is_object($form) ) {
974
+				$actions[ $form->id ] = $form->name;
975
+			}
976
+			unset($form);
977
+		}
978
+
979
+		if ( empty($actions) ) {
980
+			return;
981
+		}
982
+
983
+		asort($actions);
984
+
985
+		global $wp_admin_bar;
986
+
987
+		if ( count($actions) == 1 ) {
988
+			$wp_admin_bar->add_menu( array(
989
+				'title' => 'Edit Form',
990
+				'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
991
+				'id'    => 'frm-forms',
992
+			) );
993
+		} else {
994
+			$wp_admin_bar->add_menu( array(
995
+				'id'    => 'frm-forms',
996
+				'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
+				'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
998
+				'meta'  => array(
999 999
 					'title' => __( 'Edit Forms', 'formidable' ),
1000
-        		),
1001
-        	) );
1000
+				),
1001
+			) );
1002 1002
 
1003
-        	foreach ( $actions as $form_id => $name ) {
1003
+			foreach ( $actions as $form_id => $name ) {
1004 1004
 
1005
-        		$wp_admin_bar->add_menu( array(
1006
-        			'parent'    => 'frm-forms',
1007
-        			'id'        => 'edit_form_'. $form_id,
1008
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1005
+				$wp_admin_bar->add_menu( array(
1006
+					'parent'    => 'frm-forms',
1007
+					'id'        => 'edit_form_'. $form_id,
1008
+					'title'     => empty($name) ? __( '(no title)') : $name,
1009 1009
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1010
-        		) );
1011
-        	}
1012
-        }
1013
-    }
1010
+				) );
1011
+			}
1012
+		}
1013
+	}
1014 1014
 
1015
-    //formidable shortcode
1015
+	//formidable shortcode
1016 1016
 	public static function get_form_shortcode( $atts ) {
1017
-        global $frm_vars;
1018
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1019
-            $sc = '[formidable';
1017
+		global $frm_vars;
1018
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1019
+			$sc = '[formidable';
1020 1020
 			if ( ! empty( $atts ) ) {
1021 1021
 				foreach ( $atts as $k => $v ) {
1022 1022
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1023 1023
 				}
1024 1024
 			}
1025
-            return $sc .']';
1026
-        }
1027
-
1028
-        $shortcode_atts = shortcode_atts( array(
1029
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031
-            'exclude_fields' => array(), 'minimize' => false,
1032
-        ), $atts);
1033
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1034
-
1035
-        return self::show_form(
1036
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1037
-            $shortcode_atts['description'], $atts
1038
-        );
1039
-    }
1040
-
1041
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1042
-        if ( empty( $id ) ) {
1043
-            $id = $key;
1044
-        }
1045
-
1046
-        // no form id or key set
1047
-        if ( empty( $id ) ) {
1048
-            return __( 'Please select a valid form', 'formidable' );
1049
-        }
1050
-
1051
-        $form = FrmForm::getOne( $id );
1052
-        if ( ! $form || $form->parent_form_id ) {
1053
-            return __( 'Please select a valid form', 'formidable' );
1054
-        }
1025
+			return $sc .']';
1026
+		}
1027
+
1028
+		$shortcode_atts = shortcode_atts( array(
1029
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031
+			'exclude_fields' => array(), 'minimize' => false,
1032
+		), $atts);
1033
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1034
+
1035
+		return self::show_form(
1036
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1037
+			$shortcode_atts['description'], $atts
1038
+		);
1039
+	}
1040
+
1041
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1042
+		if ( empty( $id ) ) {
1043
+			$id = $key;
1044
+		}
1045
+
1046
+		// no form id or key set
1047
+		if ( empty( $id ) ) {
1048
+			return __( 'Please select a valid form', 'formidable' );
1049
+		}
1050
+
1051
+		$form = FrmForm::getOne( $id );
1052
+		if ( ! $form || $form->parent_form_id ) {
1053
+			return __( 'Please select a valid form', 'formidable' );
1054
+		}
1055 1055
 
1056 1056
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1057
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1057
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1058 1058
 
1059
-        $form = apply_filters( 'frm_pre_display_form', $form );
1059
+		$form = apply_filters( 'frm_pre_display_form', $form );
1060 1060
 
1061
-        $frm_settings = FrmAppHelper::get_settings();
1061
+		$frm_settings = FrmAppHelper::get_settings();
1062 1062
 
1063 1063
 		if ( self::is_viewable_draft_form( $form ) ) {
1064 1064
 			// don't show a draft form on a page
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		}
1080 1080
 
1081 1081
 		return $form;
1082
-    }
1082
+	}
1083 1083
 
1084 1084
 	private static function is_viewable_draft_form( $form ) {
1085 1085
 		global $post;
@@ -1095,98 +1095,98 @@  discard block
 block discarded – undo
1095 1095
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1096 1096
 	}
1097 1097
 
1098
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1099
-        ob_start();
1098
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1099
+		ob_start();
1100 1100
 
1101
-        self::get_form_contents( $form, $title, $description, $atts );
1101
+		self::get_form_contents( $form, $title, $description, $atts );
1102 1102
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1103 1103
 
1104
-        $contents = ob_get_contents();
1105
-        ob_end_clean();
1104
+		$contents = ob_get_contents();
1105
+		ob_end_clean();
1106 1106
 
1107 1107
 		self::maybe_minimize_form( $atts, $contents );
1108 1108
 
1109
-        return $contents;
1110
-    }
1109
+		return $contents;
1110
+	}
1111 1111
 
1112 1112
 	public static function enqueue_scripts( $params ) {
1113 1113
 		do_action( 'frm_enqueue_form_scripts', $params );
1114 1114
 	}
1115 1115
 
1116 1116
 	public static function get_form_contents( $form, $title, $description, $atts ) {
1117
-        global $frm_vars;
1117
+		global $frm_vars;
1118 1118
 
1119
-        $frm_settings = FrmAppHelper::get_settings();
1119
+		$frm_settings = FrmAppHelper::get_settings();
1120 1120
 
1121
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1121
+		$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122 1122
 
1123
-        $user_ID = get_current_user_id();
1123
+		$user_ID = get_current_user_id();
1124 1124
 		$params = FrmForm::get_params( $form );
1125
-        $message = $errors = '';
1125
+		$message = $errors = '';
1126 1126
 
1127
-        if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1129
-        }
1127
+		if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
+			$errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1129
+		}
1130 1130
 
1131 1131
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1132
-        $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133
-
1134
-        if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1139
-            }
1140
-            return;
1141
-        }
1142
-
1143
-        if ( ! empty($errors) ) {
1144
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1146
-            return;
1147
-        }
1148
-
1149
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1151
-            return;
1152
-        }
1153
-
1154
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
-
1158
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1132
+		$fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133
+
1134
+		if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
+			do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
+			if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
+				$values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
+				include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1139
+			}
1140
+			return;
1141
+		}
1142
+
1143
+		if ( ! empty($errors) ) {
1144
+			$values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1146
+			return;
1147
+		}
1148
+
1149
+		do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
+		if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1151
+			return;
1152
+		}
1153
+
1154
+		$values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
+		$created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
+		$conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1157
+
1158
+		if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
+			do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1160 1160
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1161
-            return;
1162
-        }
1161
+			return;
1162
+		}
1163 1163
 
1164
-        if ( $created && is_numeric($created) ) {
1165
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166
-            $class = 'frm_message';
1167
-        } else {
1168
-            $message = $frm_settings->failed_msg;
1169
-            $class = 'frm_error_style';
1170
-        }
1164
+		if ( $created && is_numeric($created) ) {
1165
+			$message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166
+			$class = 'frm_message';
1167
+		} else {
1168
+			$message = $frm_settings->failed_msg;
1169
+			$class = 'frm_error_style';
1170
+		}
1171 1171
 
1172 1172
 		$message = FrmFormsHelper::get_success_message( array(
1173 1173
 			'message' => $message, 'form' => $form,
1174 1174
 			'entry_id' => $created, 'class' => $class,
1175 1175
 		) );
1176
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1176
+		$message = apply_filters('frm_main_feedback', $message, $form, $created);
1177 1177
 
1178
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1180
-        } else {
1181
-            global $frm_vars;
1178
+		if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
+			require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1180
+		} else {
1181
+			global $frm_vars;
1182 1182
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1183 1183
 
1184
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1186
-        }
1184
+			$include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
+			include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1186
+		}
1187 1187
 
1188 1188
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1189
-    }
1189
+	}
1190 1190
 
1191 1191
 	public static function front_head() {
1192 1192
 		$version = FrmAppHelper::plugin_version();
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
 	}
1216 1216
 
1217 1217
 	public static function defer_script_loading( $tag, $handle ) {
1218
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1219
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1218
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1219
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1220 1220
 		}
1221
-	    return $tag;
1221
+		return $tag;
1222 1222
 	}
1223 1223
 
1224 1224
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | '. $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
10
+		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13 13
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,49 +33,49 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-            return self::create($values);
59
+            return self::create( $values );
60 60
 		} else if ( $action == 'new' ) {
61 61
 			$frm_field_selection = FrmField::field_selection();
62
-            $values = FrmFormsHelper::setup_new_vars($values);
62
+            $values = FrmFormsHelper::setup_new_vars( $values );
63 63
             $id = FrmForm::create( $values );
64
-            $form = FrmForm::getOne($id);
64
+            $form = FrmForm::getOne( $id );
65 65
 
66 66
             // add default email notification
67 67
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
68
-            $action_control->create($form->id);
68
+            $action_control->create( $form->id );
69 69
 
70 70
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
71 71
 
72 72
             $values['id'] = $id;
73
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
73
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
74 74
         }
75 75
     }
76 76
 
77 77
 	public static function create( $values = array() ) {
78
-        FrmAppHelper::permission_check('frm_edit_forms');
78
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
79 79
 
80 80
         global $frm_vars;
81 81
         if ( empty( $values ) ) {
@@ -87,58 +87,58 @@  discard block
 block discarded – undo
87 87
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
88 88
         }
89 89
 
90
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
90
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
91 91
 
92 92
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
93 93
             $frm_settings = FrmAppHelper::get_settings();
94 94
             $errors = array( 'form' => $frm_settings->admin_permission );
95 95
         } else {
96
-            $errors = FrmForm::validate($values);
96
+            $errors = FrmForm::validate( $values );
97 97
         }
98 98
 
99
-        if ( count($errors) > 0 ) {
99
+        if ( count( $errors ) > 0 ) {
100 100
             $hide_preview = true;
101 101
 			$frm_field_selection = FrmField::field_selection();
102 102
             $form = FrmForm::getOne( $id );
103
-            $fields = FrmField::get_all_for_form($id);
103
+            $fields = FrmField::get_all_for_form( $id );
104 104
 
105
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
105
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
106 106
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
107 107
 
108
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
108
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
109 109
         } else {
110 110
             FrmForm::update( $id, $values, true );
111
-            die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
111
+            die( FrmAppHelper::js_redirect( admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ) ) );
112 112
         }
113 113
     }
114 114
 
115 115
     public static function edit( $values = false ) {
116
-        FrmAppHelper::permission_check('frm_edit_forms');
116
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
117 117
 
118 118
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
119
-        return self::get_edit_vars($id);
119
+        return self::get_edit_vars( $id );
120 120
     }
121 121
 
122 122
     public static function settings( $id = false, $message = '' ) {
123
-        FrmAppHelper::permission_check('frm_edit_forms');
123
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
124 124
 
125
-        if ( ! $id || ! is_numeric($id) ) {
125
+        if ( ! $id || ! is_numeric( $id ) ) {
126 126
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
127 127
         }
128 128
 		return self::get_settings_vars( $id, array(), $message );
129 129
     }
130 130
 
131 131
     public static function update_settings() {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
133 133
 
134 134
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135 135
 
136
-        $errors = FrmForm::validate($_POST);
137
-        if ( count($errors) > 0 ) {
138
-            return self::get_settings_vars($id, $errors);
136
+        $errors = FrmForm::validate( $_POST );
137
+        if ( count( $errors ) > 0 ) {
138
+            return self::get_settings_vars( $id, $errors );
139 139
         }
140 140
 
141
-        do_action('frm_before_update_form_settings', $id);
141
+        do_action( 'frm_before_update_form_settings', $id );
142 142
 
143 143
 		FrmForm::update( $id, $_POST );
144 144
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
 	private static function edit_in_place_value( $field ) {
162 162
 		check_ajax_referer( 'frm_ajax', 'nonce' );
163
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
163
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
164 164
 
165 165
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
166 166
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @since 2.0
219 219
 	 */
220 220
 	public static function _create_from_template() {
221
-		FrmAppHelper::permission_check('frm_edit_forms');
221
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
222 222
 		check_ajax_referer( 'frm_ajax', 'nonce' );
223 223
 
224 224
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 
235 235
     public static function duplicate() {
236
-        FrmAppHelper::permission_check('frm_edit_forms');
236
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
237 237
 
238 238
 		$params = FrmForm::list_page_params();
239 239
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
240
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
240
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
241 241
         if ( $form ) {
242 242
 			return self::get_edit_vars( $form, array(), $message, true );
243 243
         } else {
244
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
244
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
245 245
         }
246 246
     }
247 247
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
         if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
268 268
             global $wp;
269 269
             $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
270
-            include_once( $root.'/wp-config.php' );
270
+            include_once( $root . '/wp-config.php' );
271 271
             $wp->init();
272 272
             $wp->register_globals();
273 273
         }
274 274
 
275 275
 		self::register_pro_scripts();
276 276
 
277
-		header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
277
+		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
278 278
 
279 279
 		$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
280 280
 		if ( $key == '' ) {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			$form = FrmForm::getAll( array(), '', 1 );
287 287
         }
288 288
 
289
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
289
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
290 290
         wp_die();
291 291
     }
292 292
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		if ( FrmAppHelper::pro_is_installed() ) {
295 295
 			wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
296 296
 			wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
297
-			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', true );
297
+			wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.5.1', true );
298 298
 		}
299 299
 	}
300 300
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
     }
304 304
 
305 305
 	public static function bulk_untrash( $ids ) {
306
-        FrmAppHelper::permission_check('frm_edit_forms');
306
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
307 307
 
308 308
         $count = FrmForm::set_status( $ids, 'published' );
309 309
 
310
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
310
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
311 311
         return $message;
312 312
     }
313 313
 
@@ -326,90 +326,90 @@  discard block
 block discarded – undo
326 326
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
327 327
 		);
328 328
 
329
-		if ( ! isset( $available_status[ $status ] ) ) {
329
+		if ( ! isset( $available_status[$status] ) ) {
330 330
 			return;
331 331
 		}
332 332
 
333
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
333
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
334 334
 
335 335
 		$params = FrmForm::list_page_params();
336 336
 
337 337
 		//check nonce url
338
-		check_admin_referer($status .'_form_' . $params['id']);
338
+		check_admin_referer( $status . '_form_' . $params['id'] );
339 339
 
340 340
 		$count = 0;
341
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
342
-			$count++;
341
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
342
+			$count ++;
343 343
 		}
344 344
 
345
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
-		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
345
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
346
+		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
347 347
 
348
-		$message = $available_status[ $status ]['message'];
348
+		$message = $available_status[$status]['message'];
349 349
 
350 350
 		self::display_forms_list( $params, $message );
351 351
 	}
352 352
 
353 353
 	public static function bulk_trash( $ids ) {
354
-        FrmAppHelper::permission_check('frm_delete_forms');
354
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
355 355
 
356 356
         $count = 0;
357 357
         foreach ( $ids as $id ) {
358 358
             if ( FrmForm::trash( $id ) ) {
359
-                $count++;
359
+                $count ++;
360 360
             }
361 361
         }
362 362
 
363 363
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
364
-        $message = sprintf(_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="'. esc_url(wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type='. $current_page .'&item-action[]='. implode('item-action[]=', $ids), 'bulk-toplevel_page_formidable' )) .'">', '</a>' );
364
+        $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action[]=' . implode( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
365 365
 
366 366
         return $message;
367 367
     }
368 368
 
369 369
     public static function destroy() {
370
-        FrmAppHelper::permission_check('frm_delete_forms');
370
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
371 371
 
372 372
 		$params = FrmForm::list_page_params();
373 373
 
374 374
         //check nonce url
375
-        check_admin_referer('destroy_form_' . $params['id']);
375
+        check_admin_referer( 'destroy_form_' . $params['id'] );
376 376
 
377 377
         $count = 0;
378 378
         if ( FrmForm::destroy( $params['id'] ) ) {
379
-            $count++;
379
+            $count ++;
380 380
         }
381 381
 
382
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
382
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
383 383
 
384 384
 		self::display_forms_list( $params, $message );
385 385
     }
386 386
 
387 387
 	public static function bulk_destroy( $ids ) {
388
-        FrmAppHelper::permission_check('frm_delete_forms');
388
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
389 389
 
390 390
         $count = 0;
391 391
         foreach ( $ids as $id ) {
392 392
             $d = FrmForm::destroy( $id );
393 393
             if ( $d ) {
394
-                $count++;
394
+                $count ++;
395 395
             }
396 396
         }
397 397
 
398
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
398
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
399 399
 
400 400
         return $message;
401 401
     }
402 402
 
403 403
     private static function delete_all() {
404 404
         //check nonce url
405
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
405
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
406 406
         if ( $permission_error !== false ) {
407 407
 			self::display_forms_list( array(), '', array( $permission_error ) );
408 408
             return;
409 409
         }
410 410
 
411 411
 		$count = FrmForm::scheduled_delete( time() );
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
413 413
 
414 414
 		self::display_forms_list( array(), $message );
415 415
     }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 	* @since 2.0.15
427 427
 	*/
428 428
 	public static function insert_form_button() {
429
-		if ( current_user_can('frm_view_forms') ) {
429
+		if ( current_user_can( 'frm_view_forms' ) ) {
430 430
 			$menu_name = FrmAppHelper::get_menu_name();
431 431
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
432 432
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> '.
433
-				$menu_name .'</a>';
433
+				$menu_name . '</a>';
434 434
 			echo wp_kses_post( $content );
435 435
 		}
436 436
 	}
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
448 448
         );
449 449
 
450
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
450
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
451 451
 
452
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/insert_form_popup.php');
452
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
453 453
     }
454 454
 
455 455
     public static function get_shortcode_opts() {
456
-		FrmAppHelper::permission_check('frm_view_forms');
456
+		FrmAppHelper::permission_check( 'frm_view_forms' );
457 457
         check_ajax_referer( 'frm_ajax', 'nonce' );
458 458
 
459 459
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
460
-        if ( empty($shortcode) ) {
460
+        if ( empty( $shortcode ) ) {
461 461
             wp_die();
462 462
         }
463 463
 
464
-        echo '<div id="sc-opts-'. esc_attr( $shortcode ) .'" class="frm_shortcode_option">';
465
-        echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" class="frm_hidden" />';
464
+        echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
465
+        echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
466 466
 
467 467
         $form_id = '';
468 468
         $opts = array();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 );
478 478
             break;
479 479
         }
480
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
480
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
481 481
 
482 482
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
483 483
 			// allow other shortcodes to use the required form id option
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			unset( $opts['form_id'] );
486 486
 		}
487 487
 
488
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
488
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
489 489
 
490 490
         echo '</div>';
491 491
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             die();
518 518
         }
519 519
 
520
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/list.php');
520
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
521 521
     }
522 522
 
523 523
 	public static function get_columns( $columns ) {
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
         }
595 595
 
596 596
         if ( $form->parent_form_id ) {
597
-			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id='. $form->parent_form_id ) ) . '">', '</a>' ));
597
+			wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
598 598
         }
599 599
 
600 600
 		$frm_field_selection = FrmField::field_selection();
601
-        $fields = FrmField::get_all_for_form($form->id);
601
+        $fields = FrmField::get_all_for_form( $form->id );
602 602
 
603 603
         // Automatically add end section fields if they don't exist (2.0 migration)
604 604
         $reset_fields = false;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
609 609
         }
610 610
 
611
-        unset($end_section_values, $last_order, $open, $reset_fields);
611
+        unset( $end_section_values, $last_order, $open, $reset_fields );
612 612
 
613
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
613
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
614 614
 
615 615
         $edit_message = __( 'Form was Successfully Updated', 'formidable' );
616 616
         if ( $form->is_template && $message == $edit_message ) {
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
621 621
 
622 622
         if ( $form->default_template ) {
623
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
624
-        } else if ( defined('DOING_AJAX') ) {
623
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
624
+        } else if ( defined( 'DOING_AJAX' ) ) {
625 625
             wp_die();
626 626
         } else if ( $create_link ) {
627
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new.php');
627
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
628 628
         } else {
629
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/edit.php');
629
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
630 630
         }
631 631
     }
632 632
 
@@ -637,28 +637,28 @@  discard block
 block discarded – undo
637 637
 
638 638
         $form = FrmForm::getOne( $id );
639 639
 
640
-        $fields = FrmField::get_all_for_form($id);
641
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
640
+        $fields = FrmField::get_all_for_form( $id );
641
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
642 642
 
643
-        if ( isset($values['default_template']) && $values['default_template'] ) {
644
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
643
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
644
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
645 645
         }
646 646
 
647 647
         $action_controls = FrmFormActionsController::get_form_actions();
648 648
 
649
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
649
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
650 650
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
651 651
 
652
-        $styles = apply_filters('frm_get_style_opts', array());
652
+        $styles = apply_filters( 'frm_get_style_opts', array() );
653 653
 
654
-        require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/settings.php');
654
+        require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
655 655
     }
656 656
 
657 657
     public static function mb_tags_box( $form_id, $class = '' ) {
658
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
658
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
659 659
         $linked_forms = array();
660 660
         $col = 'one';
661
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
661
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
662 662
 
663 663
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
664 664
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 
737 737
     // Insert the form class setting into the form
738 738
 	public static function form_classes( $form ) {
739
-        if ( isset($form->options['form_class']) ) {
739
+        if ( isset( $form->options['form_class'] ) ) {
740 740
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
741 741
         }
742 742
     }
743 743
 
744 744
     public static function get_email_html() {
745
-		FrmAppHelper::permission_check('frm_view_forms');
745
+		FrmAppHelper::permission_check( 'frm_view_forms' );
746 746
         check_ajax_referer( 'frm_ajax', 'nonce' );
747 747
 		echo FrmEntryFormat::show_entry( array(
748 748
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
     public static function add_default_templates( $path, $default = true, $template = true ) {
840 840
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
841 841
 
842
-        $path = untrailingslashit(trim($path));
843
-        $templates = glob( $path .'/*.php' );
842
+        $path = untrailingslashit( trim( $path ) );
843
+        $templates = glob( $path . '/*.php' );
844 844
 
845
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
846
-            $filename = str_replace( '.php', '', str_replace( $path.'/', '', $templates[ $i ] ) );
845
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
846
+            $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
847 847
 			$template_query = array( 'form_key' => $filename );
848 848
             if ( $template ) {
849 849
                 $template_query['is_template'] = 1;
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
                 $values['default_template'] = 1;
862 862
             }
863 863
 
864
-            include( $templates[ $i ] );
864
+            include( $templates[$i] );
865 865
 
866 866
             //get updated form
867
-            if ( isset($form) && ! empty($form) ) {
867
+            if ( isset( $form ) && ! empty( $form ) ) {
868 868
                 $old_id = $form->id;
869
-                $form = FrmForm::getOne($form->id);
869
+                $form = FrmForm::getOne( $form->id );
870 870
             } else {
871 871
                 $old_id = false;
872 872
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -879,24 +879,24 @@  discard block
 block discarded – undo
879 879
     }
880 880
 
881 881
     public static function route() {
882
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
882
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
883 883
         $vars = array();
884 884
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
885 885
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
886 886
 
887
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
888
-            $json_vars = json_decode($json_vars, true);
889
-            if ( empty($json_vars) ) {
887
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
888
+            $json_vars = json_decode( $json_vars, true );
889
+            if ( empty( $json_vars ) ) {
890 890
                 // json decoding failed so we should return an error message
891 891
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
892 892
                 if ( 'edit' == $action ) {
893 893
                     $action = 'update';
894 894
                 }
895 895
 
896
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
896
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
897 897
             } else {
898
-                $vars = FrmAppHelper::json_to_array($json_vars);
899
-                $action = $vars[ $action ];
898
+                $vars = FrmAppHelper::json_to_array( $json_vars );
899
+                $action = $vars[$action];
900 900
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
901 901
 				$_REQUEST = array_merge( $_REQUEST, $vars );
902 902
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 
915 915
         switch ( $action ) {
916 916
             case 'new':
917
-                return self::new_form($vars);
917
+                return self::new_form( $vars );
918 918
             case 'create':
919 919
             case 'edit':
920 920
             case 'update':
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
             case 'update_settings':
928 928
 				return self::$action( $vars );
929 929
             default:
930
-                do_action('frm_form_action_'. $action);
931
-                if ( apply_filters('frm_form_stop_action_'. $action, false) ) {
930
+                do_action( 'frm_form_action_' . $action );
931
+                if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
932 932
                     return;
933 933
                 }
934 934
 
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
938 938
                 }
939 939
 
940
-                if ( strpos($action, 'bulk_') === 0 ) {
940
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
941 941
                     FrmAppHelper::remove_get_action();
942 942
                     return self::list_form();
943 943
                 }
@@ -964,37 +964,37 @@  discard block
 block discarded – undo
964 964
 
965 965
 	public static function admin_bar_configure() {
966 966
         global $frm_vars;
967
-        if ( empty($frm_vars['forms_loaded']) ) {
967
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
968 968
             return;
969 969
         }
970 970
 
971 971
         $actions = array();
972 972
         foreach ( $frm_vars['forms_loaded'] as $form ) {
973
-            if ( is_object($form) ) {
974
-                $actions[ $form->id ] = $form->name;
973
+            if ( is_object( $form ) ) {
974
+                $actions[$form->id] = $form->name;
975 975
             }
976
-            unset($form);
976
+            unset( $form );
977 977
         }
978 978
 
979
-        if ( empty($actions) ) {
979
+        if ( empty( $actions ) ) {
980 980
             return;
981 981
         }
982 982
 
983
-        asort($actions);
983
+        asort( $actions );
984 984
 
985 985
         global $wp_admin_bar;
986 986
 
987
-        if ( count($actions) == 1 ) {
987
+        if ( count( $actions ) == 1 ) {
988 988
             $wp_admin_bar->add_menu( array(
989 989
                 'title' => 'Edit Form',
990
-                'href'  => admin_url('admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) )),
990
+                'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
991 991
                 'id'    => 'frm-forms',
992 992
             ) );
993 993
         } else {
994 994
             $wp_admin_bar->add_menu( array(
995 995
         		'id'    => 'frm-forms',
996 996
         		'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>',
997
-        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id='. current( array_keys( $actions ) ) ),
997
+        		'href'  => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ),
998 998
         		'meta'  => array(
999 999
 					'title' => __( 'Edit Forms', 'formidable' ),
1000 1000
         		),
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
         		$wp_admin_bar->add_menu( array(
1006 1006
         			'parent'    => 'frm-forms',
1007
-        			'id'        => 'edit_form_'. $form_id,
1008
-        			'title'     => empty($name) ? __( '(no title)') : $name,
1007
+        			'id'        => 'edit_form_' . $form_id,
1008
+        			'title'     => empty( $name ) ? __( '(no title)' ) : $name,
1009 1009
 					'href'      => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
1010 1010
         		) );
1011 1011
         	}
@@ -1015,22 +1015,22 @@  discard block
 block discarded – undo
1015 1015
     //formidable shortcode
1016 1016
 	public static function get_form_shortcode( $atts ) {
1017 1017
         global $frm_vars;
1018
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1018
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1019 1019
             $sc = '[formidable';
1020 1020
 			if ( ! empty( $atts ) ) {
1021 1021
 				foreach ( $atts as $k => $v ) {
1022 1022
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1023 1023
 				}
1024 1024
 			}
1025
-            return $sc .']';
1025
+            return $sc . ']';
1026 1026
         }
1027 1027
 
1028 1028
         $shortcode_atts = shortcode_atts( array(
1029 1029
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1030 1030
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1031 1031
             'exclude_fields' => array(), 'minimize' => false,
1032
-        ), $atts);
1033
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1032
+        ), $atts );
1033
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1034 1034
 
1035 1035
         return self::show_form(
1036 1036
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1118,51 +1118,51 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
         $frm_settings = FrmAppHelper::get_settings();
1120 1120
 
1121
-        $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
1121
+        $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
1122 1122
 
1123 1123
         $user_ID = get_current_user_id();
1124 1124
 		$params = FrmForm::get_params( $form );
1125 1125
         $message = $errors = '';
1126 1126
 
1127 1127
         if ( $params['posted_form_id'] == $form->id && $_POST ) {
1128
-            $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array();
1128
+            $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array();
1129 1129
         }
1130 1130
 
1131 1131
 		$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
1132 1132
         $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) );
1133 1133
 
1134 1134
         if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) {
1135
-            do_action('frm_display_form_action', $params, $fields, $form, $title, $description);
1136
-            if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) {
1137
-                $values = FrmEntriesHelper::setup_new_vars($fields, $form);
1138
-                include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1135
+            do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
1136
+            if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
1137
+                $values = FrmEntriesHelper::setup_new_vars( $fields, $form );
1138
+                include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1139 1139
             }
1140 1140
             return;
1141 1141
         }
1142 1142
 
1143
-        if ( ! empty($errors) ) {
1144
-            $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array();
1145
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1143
+        if ( ! empty( $errors ) ) {
1144
+            $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array();
1145
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1146 1146
             return;
1147 1147
         }
1148 1148
 
1149
-        do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description);
1150
-        if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) {
1149
+        do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
1150
+        if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
1151 1151
             return;
1152 1152
         }
1153 1153
 
1154
-        $values = FrmEntriesHelper::setup_new_vars($fields, $form, true);
1155
-        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0;
1156
-        $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create');
1154
+        $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true );
1155
+        $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0;
1156
+        $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' );
1157 1157
 
1158
-        if ( $created && is_numeric($created) && $conf_method != 'message' ) {
1159
-            do_action('frm_success_action', $conf_method, $form, $form->options, $created);
1158
+        if ( $created && is_numeric( $created ) && $conf_method != 'message' ) {
1159
+            do_action( 'frm_success_action', $conf_method, $form, $form->options, $created );
1160 1160
 			do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
1161 1161
             return;
1162 1162
         }
1163 1163
 
1164
-        if ( $created && is_numeric($created) ) {
1165
-            $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1164
+        if ( $created && is_numeric( $created ) ) {
1165
+            $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg;
1166 1166
             $class = 'frm_message';
1167 1167
         } else {
1168 1168
             $message = $frm_settings->failed_msg;
@@ -1173,16 +1173,16 @@  discard block
 block discarded – undo
1173 1173
 			'message' => $message, 'form' => $form,
1174 1174
 			'entry_id' => $created, 'class' => $class,
1175 1175
 		) );
1176
-        $message = apply_filters('frm_main_feedback', $message, $form, $created);
1176
+        $message = apply_filters( 'frm_main_feedback', $message, $form, $created );
1177 1177
 
1178
-        if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1179
-            require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1178
+        if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) {
1179
+            require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' );
1180 1180
         } else {
1181 1181
             global $frm_vars;
1182 1182
 			self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
1183 1183
 
1184
-            $include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
1185
-            include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
1184
+            $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values );
1185
+            include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
1186 1186
         }
1187 1187
 
1188 1188
 		do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
Please login to merge, or discard this patch.