Completed
Push — master ( 9cac82...322699 )
by Jamie
03:49
created
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmFormsListHelper extends FrmListHelper {
7
-    var $status = '';
7
+	var $status = '';
8 8
 
9 9
 	public function __construct( $args ) {
10 10
 		$this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function prepare_items() {
16
-	    global $wpdb, $per_page, $mode;
16
+		global $wpdb, $per_page, $mode;
17 17
 
18
-	    $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
18
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
19 19
 
20 20
 		$default_orderby = 'name';
21 21
 		$default_order = 'ASC';
22 22
 
23
-        $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
23
+		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
24 24
 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order;
25 25
 
26 26
 		$page = $this->get_pagenum();
@@ -28,40 +28,40 @@  discard block
 block discarded – undo
28 28
 
29 29
 		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
30 30
 
31
-        $s_query = array();
32
-        $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
31
+		$s_query = array();
32
+		$s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
33 33
 		switch ( $this->status ) {
34
-		    case 'template':
35
-                $s_query['is_template'] = 1;
36
-                $s_query['status !'] = 'trash';
37
-		        break;
38
-		    case 'draft':
39
-                $s_query['is_template'] = 0;
40
-                $s_query['status'] = 'draft';
41
-		        break;
42
-		    case 'trash':
43
-                $s_query['status'] = 'trash';
44
-		        break;
45
-		    default:
46
-                $s_query['is_template'] = 0;
47
-                $s_query['status !'] = 'trash';
48
-		        break;
34
+			case 'template':
35
+				$s_query['is_template'] = 1;
36
+				$s_query['status !'] = 'trash';
37
+				break;
38
+			case 'draft':
39
+				$s_query['is_template'] = 0;
40
+				$s_query['status'] = 'draft';
41
+				break;
42
+			case 'trash':
43
+				$s_query['status'] = 'trash';
44
+				break;
45
+			default:
46
+				$s_query['is_template'] = 0;
47
+				$s_query['status !'] = 'trash';
48
+				break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
-	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
55
-	        foreach ( (array) $search_terms as $term ) {
56
-                $s_query[] = array(
57
-                    'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
-                );
59
-	            unset($term);
60
-            }
61
-	    }
51
+		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
+		if ( $s != '' ) {
53
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
+			$search_terms = array_map('trim', $matches[0]);
55
+			foreach ( (array) $search_terms as $term ) {
56
+				$s_query[] = array(
57
+					'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
+				);
59
+				unset($term);
60
+			}
61
+		}
62 62
 
63 63
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
64
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
64
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -70,69 +70,69 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	public function no_items() {
73
-	    if ( 'template' == $this->status ) {
74
-            _e( 'No Templates Found.', 'formidable' ) ?>
73
+		if ( 'template' == $this->status ) {
74
+			_e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77 77
                 <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
81
-            _e( 'No Forms Found.', 'formidable' ) ?>
81
+			_e( 'No Forms Found.', 'formidable' ) ?>
82 82
             <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a>
83 83
 <?php   }
84 84
 	}
85 85
 
86 86
 	public function get_bulk_actions() {
87
-	    $actions = array();
87
+		$actions = array();
88 88
 
89 89
 		if ( in_array( $this->status, array( '', 'published' ) ) ) {
90
-	        $actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
-	    }
92
-
93
-	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
95
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
-	        }
97
-
98
-	        if ( current_user_can('frm_delete_forms') ) {
99
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
-	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
105
-	    }
106
-
107
-        return $actions;
108
-    }
90
+			$actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
+		}
92
+
93
+		if ( 'trash' == $this->status ) {
94
+			if ( current_user_can('frm_edit_forms') ) {
95
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
+			}
97
+
98
+			if ( current_user_can('frm_delete_forms') ) {
99
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
+			}
101
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
+		} else if ( current_user_can('frm_delete_forms') ) {
104
+			$actions['bulk_delete'] = __( 'Delete');
105
+		}
106
+
107
+		return $actions;
108
+	}
109 109
 
110 110
 	public function extra_tablenav( $which ) {
111
-        if ( 'top' != $which ) {
112
-            return;
113
-        }
111
+		if ( 'top' != $which ) {
112
+			return;
113
+		}
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
119 119
             </div>
120 120
 <?php
121
-            return;
122
-        }
121
+			return;
122
+		}
123 123
 
124
-        if ( 'template' != $this->status ) {
125
-            return;
126
-        }
124
+		if ( 'template' != $this->status ) {
125
+			return;
126
+		}
127 127
 
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
132
-        $args = array(
133
-            'frm_action'    => 'duplicate',
134
-            'template'      => true,
135
-        );
131
+		$base = admin_url('admin.php?page=formidable&form_type=template');
132
+		$args = array(
133
+			'frm_action'    => 'duplicate',
134
+			'template'      => true,
135
+		);
136 136
 
137 137
 ?>
138 138
     <div class="alignleft actions frm_visible_overflow">
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
         <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
141 141
 		<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
142 142
 		<?php
143
-        if ( empty( $forms ) ) { ?>
143
+		if ( empty( $forms ) ) { ?>
144 144
             <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li>
145 145
         <?php
146
-        } else {
147
-            foreach ( $forms as $form ) {
148
-		        $args['id'] = $form->id; ?>
146
+		} else {
147
+			foreach ( $forms as $form ) {
148
+				$args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+				unset($form);
152 152
 			}
153
-        }
154
-        ?>
153
+		}
154
+		?>
155 155
 		</ul>
156 156
 	</div>
157 157
 	</div>
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 	public function get_views() {
162 162
 
163 163
 		$statuses = array(
164
-		    'published' => __( 'My Forms', 'formidable' ),
165
-		    'template'  => __( 'Templates', 'formidable' ),
166
-		    'draft'     => __( 'Drafts', 'formidable' ),
167
-		    'trash'     => __( 'Trash', 'formidable' ),
164
+			'published' => __( 'My Forms', 'formidable' ),
165
+			'template'  => __( 'Templates', 'formidable' ),
166
+			'draft'     => __( 'Drafts', 'formidable' ),
167
+			'trash'     => __( 'Trash', 'formidable' ),
168 168
 		);
169 169
 
170
-	    $links = array();
171
-	    $counts = FrmForm::get_count();
172
-        $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
170
+		$links = array();
171
+		$counts = FrmForm::get_count();
172
+		$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
173 173
 
174
-	    foreach ( $statuses as $status => $name ) {
174
+		foreach ( $statuses as $status => $name ) {
175 175
 
176
-	        if ( $status == $form_type ) {
177
-    			$class = ' class="current"';
178
-    		} else {
179
-    		    $class = '';
180
-    		}
176
+			if ( $status == $form_type ) {
177
+				$class = ' class="current"';
178
+			} else {
179
+				$class = '';
180
+			}
181 181
 
182
-    		if ( $counts->{$status} || 'published' == $status ) {
182
+			if ( $counts->{$status} || 'published' == $status ) {
183 183
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184
-		    }
184
+			}
185 185
 
186
-		    unset($status, $name);
187
-	    }
186
+			unset($status, $name);
187
+		}
188 188
 
189 189
 		return $links;
190 190
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public function single_row( $item, $style = '' ) {
203
-	    global $frm_vars, $mode;
203
+		global $frm_vars, $mode;
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+		$this->get_actions($actions, $item, $edit_link, $duplicate_link);
211 211
 
212
-        $action_links = $this->row_actions( $actions );
212
+		$action_links = $this->row_actions( $actions );
213 213
 
214 214
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
215 215
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 		list( $columns, $hidden ) = $this->get_column_info();
220 220
 
221
-        $format = 'Y/m/d';
222
-        if ( 'list' != $mode ) {
223
-            $format .= ' \<\b\r \/\> g:i:s a';
221
+		$format = 'Y/m/d';
222
+		if ( 'list' != $mode ) {
223
+			$format .= ' \<\b\r \/\> g:i:s a';
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
231
-                $class .= ' frm_hidden';
231
+				$class .= ' frm_hidden';
232 232
 			}
233 233
 
234 234
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
244
-				    $val = $item->{$column_name};
245
-				    break;
244
+					$val = $item->{$column_name};
245
+					break;
246 246
 				case 'name':
247
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
-			        $val .= $action_links;
247
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
+					$val .= $action_links;
249 249
 
250
-				    break;
250
+					break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+					$date = date($format, strtotime($item->created_at));
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
256 256
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
257
-				    if ( 'excerpt' == $mode ) {
257
+					if ( 'excerpt' == $mode ) {
258 258
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
259
-				    }
260
-			        break;
261
-			    case 'entries':
259
+					}
260
+					break;
261
+				case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263 263
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
264
-			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
264
+					} else {
265
+						$text = FrmEntry::getRecordCount($item->id);
266 266
 						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
268
-                    }
269
-			        break;
270
-                case 'type':
271
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
-                    break;
267
+						unset($text);
268
+					}
269
+					break;
270
+				case 'type':
271
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
+					break;
273 273
 			}
274 274
 
275 275
 			if ( isset($val) ) {
276
-			    $r .= "<td $attributes>";
277
-			    $r .= $val;
278
-			    $r .= '</td>';
276
+				$r .= "<td $attributes>";
277
+				$r .= $val;
278
+				$r .= '</td>';
279 279
 			}
280 280
 			unset($val);
281 281
 		}
@@ -284,38 +284,38 @@  discard block
 block discarded – undo
284 284
 		return $r;
285 285
 	}
286 286
 
287
-    /**
288
-     * @param string $edit_link
289
-     * @param string $duplicate_link
290
-     */
291
-    private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287
+	/**
288
+	 * @param string $edit_link
289
+	 * @param string $duplicate_link
290
+	 */
291
+	private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293 293
 			if ( current_user_can('frm_edit_forms') ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+			if ( current_user_can('frm_delete_forms') ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) .'" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300
-    		}
301
-            return;
300
+			}
301
+			return;
302 302
 		}
303 303
 
304 304
 		if ( current_user_can('frm_edit_forms') ) {
305
-            if ( ! $item->is_template || ! $item->default_template ) {
305
+			if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307
-            }
307
+			}
308 308
 
309
-		    if ( $item->is_template ) {
309
+			if ( $item->is_template ) {
310 310
 				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
311
-            } else {
311
+			} else {
312 312
 				$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
313 313
 
314
-    		    if ( FrmAppHelper::pro_is_installed() ) {
314
+				if ( FrmAppHelper::pro_is_installed() ) {
315 315
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
316
-        	    }
317
-        	}
318
-        }
316
+				}
317
+			}
318
+		}
319 319
 
320 320
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
321 321
 		if ( empty( $actions['trash'] ) ) {
@@ -324,52 +324,52 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 
326 326
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
327
-    }
327
+	}
328 328
 
329
-    /**
330
-     * @param string $edit_link
331
-     */
329
+	/**
330
+	 * @param string $edit_link
331
+	 */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333
-        $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
336
-        }
333
+		$form_name = $item->name;
334
+		if ( trim($form_name) == '' ) {
335
+			$form_name = __( '(no title)');
336
+		}
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
339 339
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
340 340
 		}
341 341
 
342
-        $val = '<strong>';
343
-        if ( 'trash' == $this->status ) {
344
-            $val .= $form_name;
345
-        } else {
342
+		$val = '<strong>';
343
+		if ( 'trash' == $this->status ) {
344
+			$val .= $form_name;
345
+		} else {
346 346
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
347
-        }
347
+		}
348 348
 
349
-        $this->add_draft_label( $item, $val );
350
-        $val .= '</strong>';
349
+		$this->add_draft_label( $item, $val );
350
+		$val .= '</strong>';
351 351
 
352
-        $this->add_form_description( $item, $val );
352
+		$this->add_form_description( $item, $val );
353 353
 
354
-        return $val;
355
-    }
354
+		return $val;
355
+	}
356 356
 
357
-    /**
358
-     * @param string $val
359
-     */
360
-    private function add_draft_label( $item, &$val ) {
361
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
357
+	/**
358
+	 * @param string $val
359
+	 */
360
+	private function add_draft_label( $item, &$val ) {
361
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
362 362
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
363
-        }
364
-    }
365
-
366
-    /**
367
-     * @param string $val
368
-     */
369
-    private function add_form_description( $item, &$val ) {
370
-        global $mode;
371
-        if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
-        }
374
-    }
363
+		}
364
+	}
365
+
366
+	/**
367
+	 * @param string $val
368
+	 */
369
+	private function add_form_description( $item, &$val ) {
370
+		global $mode;
371
+		if ( 'excerpt' == $mode ) {
372
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
+		}
374
+	}
375 375
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$page = $this->get_pagenum();
27 27
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
28 28
 
29
-		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
29
+		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page );
30 30
 
31 31
         $s_query = array();
32 32
         $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
 		        break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
51
+        $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
52 52
 	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
53
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
54
+		    $search_terms = array_map( 'trim', $matches[0] );
55 55
 	        foreach ( (array) $search_terms as $term ) {
56 56
                 $s_query[] = array(
57 57
                     'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58 58
                 );
59
-	            unset($term);
59
+	            unset( $term );
60 60
             }
61 61
 	    }
62 62
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             _e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77
-                <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
77
+                <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	    }
92 92
 
93 93
 	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
94
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
95 95
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96 96
 	        }
97 97
 
98
-	        if ( current_user_can('frm_delete_forms') ) {
98
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
99 99
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100 100
 	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
101
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
102 102
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
103
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
104
+	        $actions['bulk_delete'] = __( 'Delete' );
105 105
 	    }
106 106
 
107 107
         return $actions;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return;
113 113
         }
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
131
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
132 132
         $args = array(
133 133
             'frm_action'    => 'duplicate',
134 134
             'template'      => true,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		        $args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+			    unset( $form );
152 152
 			}
153 153
         }
154 154
         ?>
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
     		}
181 181
 
182 182
     		if ( $counts->{$status} || 'published' == $status ) {
183
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
183
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184 184
 		    }
185 185
 
186
-		    unset($status, $name);
186
+		    unset( $status, $name );
187 187
 	    }
188 188
 
189 189
 		return $links;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208 208
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+        $this->get_actions( $actions, $item, $edit_link, $duplicate_link );
211 211
 
212 212
         $action_links = $this->row_actions( $actions );
213 213
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				    break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+				    $date = date( $format, strtotime( $item->created_at ) );
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			        break;
261 261
 			    case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>';
263
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>';
264 264
 			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
266
-						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
-                        unset($text);
265
+			            $text = FrmEntry::getRecordCount( $item->id );
266
+						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
267
+                        unset( $text );
268 268
                     }
269 269
 			        break;
270 270
                 case 'type':
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                     break;
273 273
 			}
274 274
 
275
-			if ( isset($val) ) {
275
+			if ( isset( $val ) ) {
276 276
 			    $r .= "<td $attributes>";
277 277
 			    $r .= $val;
278 278
 			    $r .= '</td>';
279 279
 			}
280
-			unset($val);
280
+			unset( $val );
281 281
 		}
282 282
 		$r .= '</tr>';
283 283
 
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
      */
291 291
     private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293
-			if ( current_user_can('frm_edit_forms') ) {
293
+			if ( current_user_can( 'frm_edit_forms' ) ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
297
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
298 298
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
299 299
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
300 300
     		}
301 301
             return;
302 302
 		}
303 303
 
304
-		if ( current_user_can('frm_edit_forms') ) {
304
+		if ( current_user_can( 'frm_edit_forms' ) ) {
305 305
             if ( ! $item->is_template || ! $item->default_template ) {
306 306
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
307 307
             }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			unset( $actions['trash'] );
324 324
 		}
325 325
 
326
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
326
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
327 327
     }
328 328
 
329 329
     /**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
      */
332 332
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
333 333
         $form_name = $item->name;
334
-        if ( trim($form_name) == '' ) {
335
-            $form_name = __( '(no title)');
334
+        if ( trim( $form_name ) == '' ) {
335
+            $form_name = __( '(no title)' );
336 336
         }
337 337
 		$form_name = FrmAppHelper::kses( $form_name );
338 338
 		if ( 'excerpt' != $mode ) {
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     private function add_form_description( $item, &$val ) {
370 370
         global $mode;
371 371
         if ( 'excerpt' == $mode ) {
372
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
373 373
         }
374 374
     }
375 375
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68 68
 
69 69
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name . ' column-' . $column_name;
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+		if ( current_user_can('frm_delete_entries') ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
130
+			unset( $class );
131 131
 			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133 133
 			$col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200 200
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
52
+			}
53
+		}
54 54
 
55
-        return $css_file;
56
-    }
55
+		return $css_file;
56
+	}
57 57
 
58
-    public static function enqueue_jquery_css() {
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+		$hex = str_replace('#', '', $hex);
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+		if ( strlen($hex) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199
-        } else {
199
+		} else {
200 200
 			$r = hexdec( substr( $hex, 0, 2 ) );
201 201
 			$g = hexdec( substr( $hex, 2, 2 ) );
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203
-        }
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47 47
 			$file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51 51
 				$css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162 162
 				<?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
195
+        if ( strlen( $hex ) == 3 ) {
196 196
 			$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197 197
 			$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198 198
 			$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			$b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
css/_single_theme.css.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,23 +3,23 @@  discard block
 block discarded – undo
3 3
 if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6
-    } else {
7
-        extract($_GET);
8
-    }
6
+	} else {
7
+		extract($_GET);
8
+	}
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+	$important_style = isset($important_style) ? $important_style : 0;
11
+	$auto_width = isset($auto_width) ? $auto_width : 0;
12
+	$submit_style = isset($submit_style) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
16 16
 		$style_class = $style_name . '.with_frm_style';
17
-    } else {
18
-        $style_class = 'with_frm_style';
19
-    }
17
+	} else {
18
+		$style_class = 'with_frm_style';
19
+	}
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+	extract($style->post_content);
23 23
 }
24 24
 
25 25
 $important = empty($important_style) ? '' : ' !important';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 if ( ! isset($collapse_icon) ) {
43
-    $collapse_icon = 0;
43
+	$collapse_icon = 0;
44 44
 }
45 45
 
46 46
 if ( ! isset( $center_form ) ) {
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     color:#<?php echo esc_html( $text_color . $important ) ?>;
338 338
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
339 339
 <?php if ( ! empty($important) ) {
340
-    echo esc_html( 'background-image:none' . $important . ';' );
340
+	echo esc_html( 'background-image:none' . $important . ';' );
341 341
 }
342 342
 ?>
343 343
     border-color:#<?php echo esc_html( $border_color . $important ) ?>;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     color:#<?php echo esc_html( $submit_active_color . $important ) ?>;
549 549
 }
550 550
 <?php
551
-    }
551
+	}
552 552
 }
553 553
 ?>
554 554
 
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 
852 852
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
853 853
 <?php
854
-    // calculate the top position based on field padding
855
-    $top_pad = explode(' ', $field_pad);
856
-    $top_pad = reset($top_pad); // the top padding is listed first
857
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
854
+	// calculate the top position based on field padding
855
+	$top_pad = explode(' ', $field_pad);
856
+	$top_pad = reset($top_pad); // the top padding is listed first
857
+	$pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
858
+	$top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
859 859
 ?>
860 860
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
861 861
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) {
3
+if ( isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] ) ) {
4 4
 	if ( isset( $_GET['frm_style_setting'] ) ) {
5 5
 		extract( $_GET['frm_style_setting']['post_content'] );
6 6
     } else {
7
-        extract($_GET);
7
+        extract( $_GET );
8 8
     }
9 9
 
10
-    $important_style = isset($important_style) ? $important_style : 0;
11
-    $auto_width = isset($auto_width) ? $auto_width : 0;
12
-    $submit_style = isset($submit_style) ? $submit_style : 0;
10
+    $important_style = isset( $important_style ) ? $important_style : 0;
11
+    $auto_width = isset( $auto_width ) ? $auto_width : 0;
12
+    $submit_style = isset( $submit_style ) ? $submit_style : 0;
13 13
 
14 14
 	$style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' );
15 15
 	if ( ! empty( $style_name ) ) {
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     }
20 20
 } else {
21 21
 	$style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
22
-    extract($style->post_content);
22
+    extract( $style->post_content );
23 23
 }
24 24
 
25
-$important = empty($important_style) ? '' : ' !important';
25
+$important = empty( $important_style ) ? '' : ' !important';
26 26
 $label_margin = (int) $width + 10;
27 27
 
28 28
 $minus_icons = FrmStylesHelper::minus_icons();
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	$change_margin = 650 . 'px';
42 42
 }
43 43
 
44
-if ( ! isset($collapse_icon) ) {
44
+if ( ! isset( $collapse_icon ) ) {
45 45
     $collapse_icon = 0;
46 46
 }
47 47
 
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 }
151 151
 
152 152
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{
153
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>";
153
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>";
154 154
 }
155 155
 
156 156
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{
157
-	content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>";
157
+	content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>";
158 158
 }
159 159
 
160 160
 .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before,
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 }
164 164
 
165 165
 .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
166
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>";
166
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>";
167 167
 }
168 168
 
169 169
 .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
170
-	content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>";
170
+	content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>";
171 171
 }
172 172
 
173 173
 .<?php echo esc_html( $style_class ) ?> .form-field{
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{
343 343
     color:#<?php echo esc_html( $text_color . $important ) ?>;
344 344
 	background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>;
345
-<?php if ( ! empty($important) ) {
345
+<?php if ( ! empty( $important ) ) {
346 346
     echo esc_html( 'background-image:none' . $important . ';' );
347 347
 }
348 348
 ?>
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     line-height:normal<?php echo esc_html( $important ) ?>;
501 501
     text-align:center;
502 502
     background:#<?php echo esc_html( $submit_bg_color );
503
-	if ( ! empty($submit_bg_img) ) {
503
+	if ( ! empty( $submit_bg_img ) ) {
504 504
 		echo esc_html( ' url(' . $submit_bg_img . ')' );
505 505
 	}
506 506
 	echo esc_html( $important ); ?>;
@@ -861,10 +861,10 @@  discard block
 block discarded – undo
861 861
 .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{
862 862
 <?php
863 863
     // calculate the top position based on field padding
864
-    $top_pad = explode(' ', $field_pad);
865
-    $top_pad = reset($top_pad); // the top padding is listed first
866
-    $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem...
867
-    $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2;
864
+    $top_pad = explode( ' ', $field_pad );
865
+    $top_pad = reset( $top_pad ); // the top padding is listed first
866
+    $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem...
867
+    $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2;
868 868
 ?>
869 869
     top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>;
870 870
 }
Please login to merge, or discard this patch.
css/custom_theme.css.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! isset($saving) ) {
3
-    header( 'Content-type: text/css' );
3
+	header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
6
-        echo $css;
7
-        die();
8
-    }
5
+	if ( isset($css) && $css ) {
6
+		echo $css;
7
+		die();
8
+	}
9 9
 }
10 10
 
11 11
 if ( ! isset($frm_style) ) {
12
-    $frm_style = new FrmStyle();
12
+	$frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <?php
188 188
 foreach ( $styles as $style ) {
189 189
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
190
-    unset($style);
190
+	unset($style);
191 191
 }
192 192
 ?>
193 193
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! isset($saving) ) {
2
+if ( ! isset( $saving ) ) {
3 3
     header( 'Content-type: text/css' );
4 4
 
5
-    if ( isset($css) && $css ) {
5
+    if ( isset( $css ) && $css ) {
6 6
         echo $css;
7 7
         die();
8 8
     }
9 9
 }
10 10
 
11
-if ( ! isset($frm_style) ) {
11
+if ( ! isset( $frm_style ) ) {
12 12
     $frm_style = new FrmStyle();
13 13
 }
14 14
 
15 15
 $styles = $frm_style->get_all();
16
-$default_style = $frm_style->get_default_style($styles);
16
+$default_style = $frm_style->get_default_style( $styles );
17 17
 $defaults = $default_style->post_content;
18 18
 ?>
19 19
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 <?php
195 195
 foreach ( $styles as $style ) {
196 196
 	include( dirname( __FILE__ ) . '/_single_theme.css.php' );
197
-    unset($style);
197
+    unset( $style );
198 198
 }
199 199
 ?>
200 200
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     overflow:hidden!important;
620 620
 }
621 621
 
622
-<?php include( dirname(__FILE__) . '/frm_grids.css' ); ?>
622
+<?php include( dirname( __FILE__ ) . '/frm_grids.css' ); ?>
623 623
 
624 624
 /* Left and right label styling for non-Formidable styling - very basic, not responsive */
625 625
 .frm_form_field.frm_left_container label.frm_primary_label{
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Spacing   +67 added lines, -67 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();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 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 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -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 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
 
@@ -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
     }
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
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 265
 			$result[] = $form_id . '_id';
266
-            $i--;
266
+            $i --;
267 267
 
268 268
 			$result[] = $form_id . '_item_key';
269
-            $i--;
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,14 +311,14 @@  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
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
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
 		}
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
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 361
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -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,9 +555,9 @@  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
 		}
Please login to merge, or discard this patch.
Indentation   +335 added lines, -335 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 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 ) {
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 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'] ) {
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106 106
 					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
107
+				}
108 108
 				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
109
+			}
110
+		}
111 111
 
112 112
 		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
113 113
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
114 114
 		$columns[ $form_id . '_ip' ] = 'IP';
115 115
 
116
-        $frm_vars['cols'] = $columns;
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,122 +222,122 @@  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 265
 			$result[] = $form_id . '_id';
266
-            $i--;
266
+			$i--;
267 267
 
268 268
 			$result[] = $form_id . '_item_key';
269
-            $i--;
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
-        }
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 324
 
325 325
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326
-    }
326
+	}
327 327
 
328
-    /* Back End CRUD */
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
 		if ( ! $entry ) {
342 342
 			echo '<div id="form_show_entry_page" class="wrap">' .
343 343
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -345,109 +345,109 @@  discard block
 block discarded – undo
345 345
 			return;
346 346
 		}
347 347
 
348
-        $data = maybe_unserialize($entry->description);
348
+		$data = maybe_unserialize($entry->description);
349 349
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
350 350
 			$data = array( 'referrer' => $data );
351 351
 		}
352 352
 
353 353
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
354
-        $to_emails = array();
354
+		$to_emails = array();
355 355
 
356 356
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
357
-    }
357
+	}
358 358
 
359
-    public static function destroy() {
360
-        FrmAppHelper::permission_check('frm_delete_entries');
359
+	public static function destroy() {
360
+		FrmAppHelper::permission_check('frm_delete_entries');
361 361
 
362 362
 		$params = FrmForm::get_admin_params();
363 363
 
364
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
365
-            //unlink entry from post
366
-            global $wpdb;
364
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
365
+			//unlink entry from post
366
+			global $wpdb;
367 367
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
368
-        }
368
+		}
369 369
 
370
-        $message = '';
371
-        if ( FrmEntry::destroy( $params['id'] ) ) {
372
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
373
-        }
370
+		$message = '';
371
+		if ( FrmEntry::destroy( $params['id'] ) ) {
372
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
373
+		}
374 374
 
375
-        self::display_list( $message );
376
-    }
375
+		self::display_list( $message );
376
+	}
377 377
 
378
-    public static function destroy_all() {
379
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
380
-            $frm_settings = FrmAppHelper::get_settings();
381
-            wp_die( $frm_settings->admin_permission );
382
-        }
378
+	public static function destroy_all() {
379
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
380
+			$frm_settings = FrmAppHelper::get_settings();
381
+			wp_die( $frm_settings->admin_permission );
382
+		}
383 383
 
384
-        global $wpdb;
384
+		global $wpdb;
385 385
 		$params = FrmForm::get_admin_params();
386
-        $message = '';
387
-        $errors = array();
388
-        $form_id = (int) $params['form'];
386
+		$message = '';
387
+		$errors = array();
388
+		$form_id = (int) $params['form'];
389 389
 
390
-        if ( $form_id ) {
391
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
390
+		if ( $form_id ) {
391
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
392 392
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
393 393
 
394
-            if ( $action ) {
395
-                // this action takes a while, so only trigger it if there are posts to delete
396
-                foreach ( $entry_ids as $entry_id ) {
397
-                    do_action( 'frm_before_destroy_entry', $entry_id );
398
-                    unset( $entry_id );
399
-                }
400
-            }
401
-
402
-            $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 ) );
403
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
404
-            if ( $results ) {
405
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
406
-            }
407
-        } else {
408
-            $errors = __( 'No entries were specified', 'formidable' );
409
-        }
410
-
411
-        self::display_list( $message, $errors );
412
-    }
413
-
414
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
415
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
416
-        return FrmFormsController::show_form( $id, $key, $title, $description );
417
-    }
418
-
419
-    public static function get_form( $filename, $form, $title, $description ) {
420
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
421
-        return FrmFormsController::get_form( $form, $title, $description );
422
-    }
423
-
424
-    public static function process_entry( $errors = '', $ajax = false ) {
394
+			if ( $action ) {
395
+				// this action takes a while, so only trigger it if there are posts to delete
396
+				foreach ( $entry_ids as $entry_id ) {
397
+					do_action( 'frm_before_destroy_entry', $entry_id );
398
+					unset( $entry_id );
399
+				}
400
+			}
401
+
402
+			$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 ) );
403
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
404
+			if ( $results ) {
405
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
406
+			}
407
+		} else {
408
+			$errors = __( 'No entries were specified', 'formidable' );
409
+		}
410
+
411
+		self::display_list( $message, $errors );
412
+	}
413
+
414
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
415
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
416
+		return FrmFormsController::show_form( $id, $key, $title, $description );
417
+	}
418
+
419
+	public static function get_form( $filename, $form, $title, $description ) {
420
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
421
+		return FrmFormsController::get_form( $form, $title, $description );
422
+	}
423
+
424
+	public static function process_entry( $errors = '', $ajax = false ) {
425 425
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
426 426
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
427
-            return;
428
-        }
427
+			return;
428
+		}
429 429
 
430
-        global $frm_vars;
430
+		global $frm_vars;
431 431
 
432 432
 		$form = FrmForm::getOne( $form_id );
433
-        if ( ! $form ) {
434
-            return;
435
-        }
433
+		if ( ! $form ) {
434
+			return;
435
+		}
436 436
 
437 437
 		$params = FrmForm::get_params( $form );
438 438
 
439
-        if ( ! isset( $frm_vars['form_params'] ) ) {
440
-            $frm_vars['form_params'] = array();
441
-        }
439
+		if ( ! isset( $frm_vars['form_params'] ) ) {
440
+			$frm_vars['form_params'] = array();
441
+		}
442 442
 		$frm_vars['form_params'][ $form->id ] = $params;
443 443
 
444 444
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
445
-            return;
446
-        }
445
+			return;
446
+		}
447 447
 
448
-        if ( $errors == '' && ! $ajax ) {
448
+		if ( $errors == '' && ! $ajax ) {
449 449
 			$errors = FrmEntryValidate::validate( $_POST );
450
-        }
450
+		}
451 451
 
452 452
 		/**
453 453
 		 * Use this filter to add trigger actions and add errors after
@@ -458,102 +458,102 @@  discard block
 block discarded – undo
458 458
 
459 459
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
460 460
 
461
-        if ( empty( $errors ) ) {
461
+		if ( empty( $errors ) ) {
462 462
 			$_POST['frm_skip_cookie'] = 1;
463
-            if ( $params['action'] == 'create' ) {
463
+			if ( $params['action'] == 'create' ) {
464 464
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
465 465
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
466
-                }
467
-            }
466
+				}
467
+			}
468 468
 
469
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
469
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
470 470
 			unset( $_POST['frm_skip_cookie'] );
471
-        }
472
-    }
473
-
474
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
475
-        self::_delete_entry( $atts['id'], $form );
476
-        return $url;
477
-    }
478
-
479
-    //Delete entry if not redirected
480
-    public static function delete_entry_after_save( $atts ) {
481
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
482
-    }
483
-
484
-    private static function _delete_entry( $entry_id, $form ) {
485
-        if ( ! $form ) {
486
-            return;
487
-        }
488
-
489
-        $form->options = maybe_unserialize( $form->options );
490
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
491
-            FrmEntry::destroy( $entry_id );
492
-        }
493
-    }
471
+		}
472
+	}
473
+
474
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
475
+		self::_delete_entry( $atts['id'], $form );
476
+		return $url;
477
+	}
478
+
479
+	//Delete entry if not redirected
480
+	public static function delete_entry_after_save( $atts ) {
481
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
482
+	}
483
+
484
+	private static function _delete_entry( $entry_id, $form ) {
485
+		if ( ! $form ) {
486
+			return;
487
+		}
488
+
489
+		$form->options = maybe_unserialize( $form->options );
490
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
491
+			FrmEntry::destroy( $entry_id );
492
+		}
493
+	}
494 494
 
495 495
 	public static function show_entry_shortcode( $atts ) {
496 496
 		return FrmEntryFormat::show_entry( $atts );
497 497
 	}
498 498
 
499
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
500
-        $field = FrmField::getOne($meta->field_id);
501
-        if ( ! $field ) {
502
-            return $value;
503
-        }
499
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
500
+		$field = FrmField::getOne($meta->field_id);
501
+		if ( ! $field ) {
502
+			return $value;
503
+		}
504 504
 
505
-        $value = self::filter_display_value($value, $field, $atts);
506
-        return $value;
507
-    }
505
+		$value = self::filter_display_value($value, $field, $atts);
506
+		return $value;
507
+	}
508 508
 
509 509
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
510
-        $plain_text = add_filter('frm_plain_text_email', true);
510
+		$plain_text = add_filter('frm_plain_text_email', true);
511 511
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
512 512
 
513
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
514
-            return $value;
515
-        }
513
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
514
+			return $value;
515
+		}
516 516
 
517
-        return self::filter_display_value($value, $field, $atts);
518
-    }
517
+		return self::filter_display_value($value, $field, $atts);
518
+	}
519 519
 
520
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
521
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
520
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
521
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
522 522
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
523
-            return $value;
524
-        }
525
-
526
-        $f_values = $f_labels = array();
527
-
528
-        foreach ( $field->options as $opt_key => $opt ) {
529
-            if ( ! is_array($opt) ) {
530
-                continue;
531
-            }
532
-
533
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
534
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
535
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
536
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
537
-            }
538
-            unset($opt_key, $opt);
539
-        }
540
-
541
-        if ( ! empty($f_values) ) {
542
-            foreach ( (array) $value as $v_key => $val ) {
543
-                if ( in_array($val, $f_values) ) {
544
-                    $opt = array_search($val, $f_values);
545
-                    if ( is_array($value) ) {
546
-                        $value[ $v_key ] = $f_labels[ $opt ];
547
-                    } else {
548
-                        $value = $f_labels[ $opt ];
549
-                    }
550
-                }
551
-                unset($v_key, $val);
552
-            }
553
-        }
554
-
555
-        return $value;
556
-    }
523
+			return $value;
524
+		}
525
+
526
+		$f_values = $f_labels = array();
527
+
528
+		foreach ( $field->options as $opt_key => $opt ) {
529
+			if ( ! is_array($opt) ) {
530
+				continue;
531
+			}
532
+
533
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
534
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
535
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
536
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
537
+			}
538
+			unset($opt_key, $opt);
539
+		}
540
+
541
+		if ( ! empty($f_values) ) {
542
+			foreach ( (array) $value as $v_key => $val ) {
543
+				if ( in_array($val, $f_values) ) {
544
+					$opt = array_search($val, $f_values);
545
+					if ( is_array($value) ) {
546
+						$value[ $v_key ] = $f_labels[ $opt ];
547
+					} else {
548
+						$value = $f_labels[ $opt ];
549
+					}
550
+				}
551
+				unset($v_key, $val);
552
+			}
553
+		}
554
+
555
+		return $value;
556
+	}
557 557
 
558 558
 	public static function get_params( $form = null ) {
559 559
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -561,13 +561,13 @@  discard block
 block discarded – undo
561 561
 	}
562 562
 
563 563
 	public static function entry_sidebar( $entry ) {
564
-        $data = maybe_unserialize($entry->description);
565
-        $date_format = get_option('date_format');
566
-        $time_format = get_option('time_format');
564
+		$data = maybe_unserialize($entry->description);
565
+		$date_format = get_option('date_format');
566
+		$time_format = get_option('time_format');
567 567
 		if ( isset( $data['browser'] ) ) {
568 568
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
569 569
 		}
570 570
 
571 571
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
572
-    }
572
+	}
573 573
 }
Please login to merge, or discard this patch.
classes/views/frm-forms/add_field.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $display = apply_filters('frm_display_field_options', array(
4
-    'type' => $field['type'], 'field_data' => $field,
5
-    'required' => true, 'unique' => false, 'read_only' => false,
6
-    'description' => true, 'options' => true, 'label_position' => true,
7
-    'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8
-    'default_blank' => true, 'css' => true, 'conf_field' => false,
4
+	'type' => $field['type'], 'field_data' => $field,
5
+	'required' => true, 'unique' => false, 'read_only' => false,
6
+	'description' => true, 'options' => true, 'label_position' => true,
7
+	'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8
+	'default_blank' => true, 'css' => true, 'conf_field' => false,
9 9
 	'max' => true, 'captcha_size' => false,
10 10
 ));
11 11
 
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 $frm_settings = FrmAppHelper::get_settings();
26 26
 
27 27
 if ( ! isset( $frm_all_field_selection ) ) {
28
-    if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
-        $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
30
-    } else {
28
+	if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
+		$frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
30
+	} else {
31 31
 		$pro_field_selection = FrmField::pro_field_selection();
32 32
 		$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
33
-    }
33
+	}
34 34
 }
35 35
 
36 36
 $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection;
37 37
 
38 38
 
39 39
 if ( ! isset( $ajax ) ) {
40
-    $li_classes .= ' ui-state-default widgets-holder-wrap'; ?>
40
+	$li_classes .= ' ui-state-default widgets-holder-wrap'; ?>
41 41
 <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?>" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo ( 'divider' == $field['type'] ) ? esc_attr( $field['form_select'] ) : esc_attr( $field['form_id'] ); ?>">
42 42
 <?php
43 43
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     </span>
60 60
     <?php }
61 61
 
62
-    ?>
62
+	?>
63 63
     <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
64 64
 
65 65
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
106 106
     <div class="frm-show-click frm_small_top_margin"><?php
107 107
 
108
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
108
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
109 109
 		echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
110 110
 	} else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
111 111
 ?>
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 				<a href="javascript:void(0);" id="other_button_<?php echo esc_attr( $field['id'] ); ?>" data-opttype="other" data-ftype="<?php echo esc_attr( $field['type'] ) ?>" class="button frm_cb_button frm_add_opt<?php echo ( in_array( $field['type'], array( 'radio', 'select' ) ) && $field['other'] == true ? ' frm_hidden' : '' ); ?>"><?php _e( 'Add "Other"', 'formidable' ) ?></a>
118 118
                 <input type="hidden" value="<?php echo esc_attr( $field['other'] ); ?>" id="other_input_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[other_<?php echo esc_attr( $field['id'] ); ?>]">
119 119
             <?php
120
-            }
120
+			}
121 121
 
122
-            if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
122
+			if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
123 123
 			<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '&quot;', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange">
124 124
 				<?php _e( 'Bulk Edit Options', 'formidable' ) ?>
125 125
 			</a>
126 126
             <?php } ?>
127 127
         </div>
128 128
 <?php
129
-    }
129
+	}
130 130
 ?>
131 131
     </div>
132 132
 <?php
@@ -158,28 +158,28 @@  discard block
 block discarded – undo
158 158
 				if ( $display['required'] ) { ?>
159 159
                     <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label>
160 160
                 <?php
161
-                }
161
+				}
162 162
 
163 163
 				if ( $display['unique'] ) {
164
-                    if ( ! isset( $field['unique'] ) ) {
165
-                        $field['unique'] = false;
166
-                    }
167
-                ?>
164
+					if ( ! isset( $field['unique'] ) ) {
165
+						$field['unique'] = false;
166
+					}
167
+				?>
168 168
                 <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ) ?>"><input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ) ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" /> <?php _e( 'Unique', 'formidable' ) ?></label>
169 169
                 <?php
170
-                }
170
+				}
171 171
 
172 172
 				if ( $display['read_only'] ) {
173
-                    if ( ! isset( $field['read_only'] ) ) {
174
-                        $field['read_only'] = false;
173
+					if ( ! isset( $field['read_only'] ) ) {
174
+						$field['read_only'] = false;
175 175
 					}
176
-                ?>
176
+				?>
177 177
                 <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label>
178 178
                 <?php }
179 179
 
180
-                do_action('frm_field_options_form_top', $field, $display, $values);
180
+				do_action('frm_field_options_form_top', $field, $display, $values);
181 181
 
182
-                ?>
182
+				?>
183 183
                 <?php
184 184
 				if ( $display['required'] ) { ?>
185 185
                 <div class="frm_required_details<?php echo esc_attr( $field['id'] . ( $field['required'] ? '' : ' frm_hidden' ) ); ?>">
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				do_action( 'frm_' . $field['type'] . '_field_options_form', $field, $display, $values );
266 266
 				do_action( 'frm_field_options_form', $field, $display, $values );
267 267
 
268
-                if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
268
+				if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
269 269
 					<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
270 270
 					<td colspan="2">
271 271
                     <div class="menu-settings">
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                             <input type="text" name="field_options[blank_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['blank'] ); ?>" />
279 279
                         </p>
280 280
                         <?php
281
-                        }
281
+						}
282 282
 
283 283
 						if ( $display['invalid'] ) { ?>
284 284
                             <p><label><?php _e( 'Invalid Format', 'formidable' ) ?></label>
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                             <input type="text" name="field_options[unique_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['unique_msg'] ); ?>" />
294 294
                         </p>
295 295
                         <?php
296
-                        }
296
+						}
297 297
 
298 298
 						if ( $display['conf_field'] ) { ?>
299 299
                         <p class="frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                             <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" />
302 302
                         </p>
303 303
                         <?php
304
-                        } ?>
304
+						} ?>
305 305
                     </div>
306 306
                     </div>
307 307
                     </td>
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$display = apply_filters('frm_display_field_options', array(
3
+$display = apply_filters( 'frm_display_field_options', array(
4 4
     'type' => $field['type'], 'field_data' => $field,
5 5
     'required' => true, 'unique' => false, 'read_only' => false,
6 6
     'description' => true, 'options' => true, 'label_position' => true,
7 7
     'invalid' => false, 'size' => false, 'clear_on_focus' => false,
8 8
     'default_blank' => true, 'css' => true, 'conf_field' => false,
9 9
 	'max' => true, 'captcha_size' => false,
10
-));
10
+) );
11 11
 
12 12
 $li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type'];
13
-$li_classes = apply_filters('frm_build_field_class', $li_classes, $field );
13
+$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field );
14 14
 
15 15
 if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) {
16 16
 ?>
17 17
 <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>">
18 18
 <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" />
19
-<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span>
19
+<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span>
20 20
 </li>
21 21
 <?php
22 22
    return;
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 $frm_settings = FrmAppHelper::get_settings();
26 26
 
27 27
 if ( ! isset( $frm_all_field_selection ) ) {
28
-    if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
29
-        $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
28
+    if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) {
29
+        $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection );
30 30
     } else {
31 31
 		$pro_field_selection = FrmField::pro_field_selection();
32 32
 		$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a>
52 52
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a>
53 53
     <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a>
54
-    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" />
55
-    <?php do_action('frm_extra_field_actions', $field['id']); ?>
54
+    <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" />
55
+    <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?>
56 56
     <?php if ( $display['required'] ) { ?>
57 57
     <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>">
58 58
 		<a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     <?php }
61 61
 
62 62
     ?>
63
-    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
63
+    <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label>
64 64
 
65 65
 
66 66
 <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container">
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 </div>
79 79
 <?php
80 80
 if ( $display['description'] ) { ?>
81
-    <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
81
+    <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div>
82 82
     <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" />
83 83
 
84 84
 <?php } ?>
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 		<div class="frm_form_fields">
91 91
 			<input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" class="dyn_default_value" />
92 92
 		</div>
93
-    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php
94
-			echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div>
93
+    	<div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php
94
+			echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div>
95 95
     	<input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" />
96 96
 </div>
97 97
 	<?php if ( $display['clear_on_focus'] ) { ?>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?>
107 107
     <div class="frm-show-click frm_small_top_margin"><?php
108 108
 
109
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
109
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
110 110
 		echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>';
111 111
 	} else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) {
112 112
 ?>
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             <?php
121 121
             }
122 122
 
123
-            if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?>
123
+            if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?>
124 124
 			<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '&quot;', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange">
125 125
 				<?php _e( 'Bulk Edit Options', 'formidable' ) ?>
126 126
 			</a>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 <?php
134 134
 }
135 135
 
136
-do_action('frm_before_field_options', $field);
136
+do_action( 'frm_before_field_options', $field );
137 137
 
138 138
 if ( $display['options'] ) { ?>
139 139
     <div class="widget">
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
         </div>
144 144
     	<div class="widget-inside">
145 145
             <table class="form-table frm_clear_none">
146
-                <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?>
146
+                <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?>
147 147
 				<tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td>
148 148
                     <td>
149
-                <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
149
+                <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
150 150
                     <?php
151 151
 					foreach ( $field_types as $fkey => $ftype ) { ?>
152
-                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : '';  ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option>
152
+                        <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option>
153 153
                     <?php
154 154
 						unset( $fkey, $ftype );
155 155
 					} ?>
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 				</label>
185 185
                 <?php }
186 186
 
187
-                do_action('frm_field_options_form_top', $field, $display, $values);
187
+                do_action( 'frm_field_options_form_top', $field, $display, $values );
188 188
 
189 189
                 ?>
190 190
                 <?php
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 				if ( $display['label_position'] ) { ?>
222 222
                     <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td>
223 223
                         <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]">
224
-                            <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option>
225
-                            <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option>
226
-                            <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option>
227
-                            <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option>
228
-                            <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
229
-                            <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option>
230
-                            <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
224
+                            <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
225
+                            <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option>
226
+                            <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option>
227
+                            <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option>
228
+                            <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option>
229
+                            <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option>
230
+                            <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option>
231 231
                         </select>
232 232
                         </td>
233 233
                     </tr>
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 					<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span>
251 251
                     </td>
252 252
                     <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]">
253
-                        <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option>
254
-                        <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
253
+                        <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option>
254
+                        <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option>
255 255
                     </select>
256 256
                     </td>
257 257
                 </tr>
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 				do_action( 'frm_field_options_form', $field, $display, $values );
274 274
 
275 275
                 if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
276
-					<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
276
+					<tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
277 277
 					<td colspan="2">
278 278
                     <div class="menu-settings">
279 279
                     <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3>
@@ -337,4 +337,4 @@  discard block
 block discarded – undo
337 337
 <?php
338 338
 }
339 339
 
340
-unset($display);
340
+unset( $display );
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Spacing   +166 added lines, -166 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
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'slug'          => (string) $t->term_slug,
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+            ) );
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
98
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
97
+                $imported['imported']['terms'] ++;
98
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
99 99
             }
100 100
 
101 101
 			unset( $term, $t );
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
                 'default_template' => (int) $item->default_template,
139 139
                 'editable'      => (int) $item->editable,
140 140
                 'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
141
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
142
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
143 143
             );
144 144
 
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
145
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
@@ -152,35 +152,35 @@  discard block
 block discarded – undo
152 152
                 $edit_query['created_at'] = $form['created_at'];
153 153
             }
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
158
+            unset( $edit_query );
159 159
 
160 160
             if ( ! empty( $this_form ) ) {
161 161
                 $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
162
+                FrmForm::update( $form_id, $form );
163
+                $imported['updated']['forms'] ++;
164 164
                 // Keep track of whether this specific form was updated or not
165
-				$imported['form_status'][ $form_id ] = 'updated';
165
+				$imported['form_status'][$form_id] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168 168
                 $old_fields = array();
169 169
                 foreach ( $form_fields as $f ) {
170
-					$old_fields[ $f->id ] = $f;
171
-					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
170
+					$old_fields[$f->id] = $f;
171
+					$old_fields[$f->field_key] = $f->id;
172
+                    unset( $f );
173 173
                 }
174 174
                 $form_fields = $old_fields;
175
-                unset($old_fields);
175
+                unset( $old_fields );
176 176
             } else {
177 177
                 $old_id = false;
178 178
                 //form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180 180
                 if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
181
+                    $imported['imported']['forms'] ++;
182 182
                     // Keep track of whether this specific form was updated or not
183
-					$imported['form_status'][ $form_id ] = 'imported';
183
+					$imported['form_status'][$form_id] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185 185
                 }
186 186
             }
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
     		// Delete any fields attached to this form that were not included in the template
191 191
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
193
+                    if ( is_object( $field ) ) {
194
+                        FrmField::destroy( $field->id );
195 195
                     }
196
-                    unset($field);
196
+                    unset( $field );
197 197
                 }
198
-                unset($form_fields);
198
+                unset( $form_fields );
199 199
             }
200 200
 
201 201
 		    // Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204
-			$imported['forms'][ (int) $item->id ] = $form_id;
204
+			$imported['forms'][(int) $item->id] = $form_id;
205 205
 
206 206
             // Send pre 2.0 form options through function that creates actions
207 207
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+		    unset( $form, $item );
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$regular_forms = array();
226 226
 
227 227
 		foreach ( $forms as $form ) {
228
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
228
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
229 229
 
230 230
 			if ( $parent_form_id ) {
231 231
 				$child_forms[] = $form;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	*/
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250
-			$child_forms[ $form_id ] = $parent_form_id;
250
+			$child_forms[$form_id] = $parent_form_id;
251 251
 		}
252 252
 	}
253 253
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
265
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
265
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
266 266
 				// Update all children with this old parent_form_id
267
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
267
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
268 268
 
269 269
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
270 270
 			}
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 		        'name'          => (string) $field->name,
288 288
 		        'description'   => (string) $field->description,
289 289
 		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
290
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
291 291
 		        'field_order'   => (int) $field->field_order,
292 292
 		        'form_id'       => (int) $form_id,
293 293
 		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
294
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296 296
 		    );
297 297
 
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
298
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
299 299
 		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
300
+		        'number', 'phone', 'date', 'time',
301 301
 		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
302
+		    ) ) ) {
303
+		        if ( count( $f['default_value'] ) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305 305
 		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
306
+		            $f['default_value'] = reset( $f['default_value'] );
307 307
 		        }
308 308
 		    }
309 309
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 			self::maybe_update_form_select( $f, $imported );
312 312
 			self::maybe_update_get_values_form_setting( $imported, $f );
313 313
 
314
-			if ( ! empty($this_form) ) {
314
+			if ( ! empty( $this_form ) ) {
315 315
 				// check for field to edit by field id
316
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
316
+				if ( isset( $form_fields[$f['id']] ) ) {
317 317
 					FrmField::update( $f['id'], $f );
318
-					$imported['updated']['fields']++;
318
+					$imported['updated']['fields'] ++;
319 319
 
320
-					unset( $form_fields[ $f['id'] ] );
320
+					unset( $form_fields[$f['id']] );
321 321
 
322 322
 					//unset old field key
323
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
-						unset( $form_fields[ $f['field_key'] ] );
323
+					if ( isset( $form_fields[$f['field_key']] ) ) {
324
+						unset( $form_fields[$f['field_key']] );
325 325
 					}
326
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
326
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
327 327
 					// check for field to edit by field key
328
-					unset($f['id']);
328
+					unset( $f['id'] );
329 329
 
330
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
331
-					$imported['updated']['fields']++;
330
+					FrmField::update( $form_fields[$f['field_key']], $f );
331
+					$imported['updated']['fields'] ++;
332 332
 
333
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
334
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
333
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
334
+					unset( $form_fields[$f['field_key']] ); //unset old field key
335 335
 				} else {
336 336
 					// if no matching field id or key in this form, create the field
337 337
 					self::create_imported_field( $f, $imported );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
383 383
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
384 384
 				$form_select = $f['field_options']['form_select'];
385
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
386
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
385
+				if ( isset( $imported['forms'][$form_select] ) ) {
386
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
387 387
 				}
388 388
 			}
389 389
 		}
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 
404 404
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
405 405
 			$old_form = $f['field_options']['get_values_form'];
406
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
407
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
406
+			if ( isset( $imported['forms'][$old_form] ) ) {
407
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
408 408
 			}
409 409
 		}
410 410
 	}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	private static function create_imported_field( $f, &$imported ) {
420 420
 		$new_id = FrmField::create( $f );
421 421
 		if ( $new_id != false ) {
422
-			$imported['imported']['fields']++;
422
+			$imported['imported']['fields'] ++;
423 423
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
424 424
 		}
425 425
 	}
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 				'post_id'       => (int) $item->post_id,
482 482
 				'post_parent'   => (int) $item->post_parent,
483 483
 				'menu_order'    => (int) $item->menu_order,
484
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
485
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
484
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
485
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
486 486
 				'is_sticky'     => (string) $item->is_sticky,
487 487
 				'comment_status' => (string) $item->comment_status,
488 488
 				'post_date'     => (string) $item->post_date,
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 			);
494 494
 
495 495
             $old_id = $post['post_id'];
496
-            self::populate_post($post, $item, $imported);
496
+            self::populate_post( $post, $item, $imported );
497 497
 
498
-			unset($item);
498
+			unset( $item );
499 499
 
500 500
 			$post_id = false;
501 501
             if ( $post['post_type'] == $form_action_type ) {
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 				if ( $action_control && is_object( $action_control ) ) {
504 504
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
505 505
 				}
506
-                unset($action_control);
506
+                unset( $action_control );
507 507
             } else if ( $post['post_type'] == 'frm_styles' ) {
508 508
                 // Properly encode post content before inserting the post
509 509
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -516,26 +516,26 @@  discard block
 block discarded – undo
516 516
                 $post_id = wp_insert_post( $post );
517 517
             }
518 518
 
519
-            if ( ! is_numeric($post_id) ) {
519
+            if ( ! is_numeric( $post_id ) ) {
520 520
                 continue;
521 521
             }
522 522
 
523
-            self::update_postmeta($post, $post_id);
523
+            self::update_postmeta( $post, $post_id );
524 524
 
525 525
             $this_type = 'posts';
526
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
527
-				$this_type = $post_types[ $post['post_type'] ];
526
+			if ( isset( $post_types[$post['post_type']] ) ) {
527
+				$this_type = $post_types[$post['post_type']];
528 528
             }
529 529
 
530
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
531
-                $imported['updated'][ $this_type ]++;
530
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
531
+                $imported['updated'][$this_type] ++;
532 532
             } else {
533
-                $imported['imported'][ $this_type ]++;
533
+                $imported['imported'][$this_type] ++;
534 534
             }
535 535
 
536
-            unset($post);
536
+            unset( $post );
537 537
 
538
-			$imported['posts'][ (int) $old_id ] = $post_id;
538
+			$imported['posts'][(int) $old_id] = $post_id;
539 539
 		}
540 540
 
541 541
 		self::maybe_update_stylesheet( $imported );
@@ -544,23 +544,23 @@  discard block
 block discarded – undo
544 544
     }
545 545
 
546 546
     private static function populate_post( &$post, $item, $imported ) {
547
-		if ( isset($item->attachment_url) ) {
547
+		if ( isset( $item->attachment_url ) ) {
548 548
 			$post['attachment_url'] = (string) $item->attachment_url;
549 549
 		}
550 550
 
551
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
551
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
552 552
 		    // update to new form id
553
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
553
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
554 554
 		}
555 555
 
556 556
 		foreach ( $item->postmeta as $meta ) {
557
-		    self::populate_postmeta($post, $meta, $imported);
558
-			unset($meta);
557
+		    self::populate_postmeta( $post, $meta, $imported );
558
+			unset( $meta );
559 559
 		}
560 560
 
561
-        self::populate_taxonomies($post, $item);
561
+        self::populate_taxonomies( $post, $item );
562 562
 
563
-        self::maybe_editing_post($post);
563
+        self::maybe_editing_post( $post );
564 564
     }
565 565
 
566 566
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -572,27 +572,27 @@  discard block
 block discarded – undo
572 572
 		);
573 573
 
574 574
 		//switch old form and field ids to new ones
575
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
576
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
575
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
576
+		    $m['value'] = $imported['forms'][(int) $m['value']];
577 577
 		} else {
578
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
578
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
579 579
 
580
-		    if ( ! empty($frm_duplicate_ids) ) {
580
+		    if ( ! empty( $frm_duplicate_ids ) ) {
581 581
 
582 582
 		        if ( $m['key'] == 'frm_dyncontent' ) {
583
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
583
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
584 584
     		    } else if ( $m['key'] == 'frm_options' ) {
585 585
 
586 586
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
587
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
588
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
587
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
588
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
589 589
     		            }
590 590
     		        }
591 591
 
592 592
                     $check_dup_array = array();
593 593
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
594
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
595
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
594
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
595
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
596 596
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
597 597
                             $check_dup_array[] = 'order_by';
598 598
     		            }
@@ -603,22 +603,22 @@  discard block
 block discarded – undo
603 603
     		        }
604 604
 
605 605
                     foreach ( $check_dup_array as $check_k ) {
606
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
607
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
608
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
606
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
607
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
608
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
609 609
 		                    }
610
-		                    unset($mk, $mv);
610
+		                    unset( $mk, $mv );
611 611
 		                }
612 612
                     }
613 613
     		    }
614 614
 		    }
615 615
 		}
616 616
 
617
-		if ( ! is_array($m['value']) ) {
618
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
617
+		if ( ! is_array( $m['value'] ) ) {
618
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
619 619
 		}
620 620
 
621
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
621
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
622 622
     }
623 623
 
624 624
     /**
@@ -634,23 +634,23 @@  discard block
 block discarded – undo
634 634
             }
635 635
 
636 636
 		    $taxonomy = (string) $att['domain'];
637
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
637
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
638 638
 		        $name = (string) $att['nicename'];
639
-		        $h_term = get_term_by('slug', $name, $taxonomy);
639
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
640 640
 		        if ( $h_term ) {
641 641
 		            $name = $h_term->term_id;
642 642
 		        }
643
-		        unset($h_term);
643
+		        unset( $h_term );
644 644
 		    } else {
645 645
 		        $name = (string) $c;
646 646
 		    }
647 647
 
648
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
649
-				$post['tax_input'][ $taxonomy ] = array();
648
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
649
+				$post['tax_input'][$taxonomy] = array();
650 650
 			}
651 651
 
652
-			$post['tax_input'][ $taxonomy ][] = $name;
653
-		    unset($name);
652
+			$post['tax_input'][$taxonomy][] = $name;
653
+		    unset( $name );
654 654
 		}
655 655
     }
656 656
 
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
 
668 668
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
669 669
 		    $match_by['include'] = $post['post_id'];
670
-		    unset($match_by['name']);
670
+		    unset( $match_by['name'] );
671 671
 		}
672 672
 
673
-		$editing = get_posts($match_by);
673
+		$editing = get_posts( $match_by );
674 674
 
675
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
675
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
676 676
             // set the id of the post to edit
677
-            $post['ID'] = current($editing)->ID;
677
+            $post['ID'] = current( $editing )->ID;
678 678
         }
679 679
     }
680 680
 
681 681
     private static function update_postmeta( &$post, $post_id ) {
682 682
         foreach ( $post['postmeta'] as $k => $v ) {
683 683
             if ( '_edit_last' == $k ) {
684
-                $v = FrmAppHelper::get_user_id_param($v);
684
+                $v = FrmAppHelper::get_user_id_param( $v );
685 685
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
686 686
                 //change the attachment ID
687
-                $v = FrmProXMLHelper::get_file_id($v);
687
+                $v = FrmProXMLHelper::get_file_id( $v );
688 688
             }
689 689
 
690
-            update_post_meta($post_id, $k, $v);
690
+            update_post_meta( $post_id, $k, $v );
691 691
 
692
-            unset($k, $v);
692
+            unset( $k, $v );
693 693
         }
694 694
     }
695 695
 
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
      * @param string $message
707 707
      */
708 708
 	public static function parse_message( $result, &$message, &$errors ) {
709
-        if ( is_wp_error($result) ) {
709
+        if ( is_wp_error( $result ) ) {
710 710
             $errors[] = $result->get_error_message();
711 711
         } else if ( ! $result ) {
712 712
             return;
713 713
         }
714 714
 
715
-        if ( ! is_array($result) ) {
715
+        if ( ! is_array( $result ) ) {
716 716
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
717 717
             return;
718 718
         }
@@ -724,20 +724,20 @@  discard block
 block discarded – undo
724 724
 
725 725
         $message = '<ul>';
726 726
         foreach ( $result as $type => $results ) {
727
-			if ( ! isset( $t_strings[ $type ] ) ) {
727
+			if ( ! isset( $t_strings[$type] ) ) {
728 728
                 // only print imported and updated
729 729
                 continue;
730 730
             }
731 731
 
732 732
             $s_message = array();
733 733
             foreach ( $results as $k => $m ) {
734
-                self::item_count_message($m, $k, $s_message);
735
-                unset($k, $m);
734
+                self::item_count_message( $m, $k, $s_message );
735
+                unset( $k, $m );
736 736
             }
737 737
 
738
-            if ( ! empty($s_message) ) {
739
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
740
-                $message .= implode(', ', $s_message);
738
+            if ( ! empty( $s_message ) ) {
739
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
740
+                $message .= implode( ', ', $s_message );
741 741
                 $message .= '</li>';
742 742
             }
743 743
         }
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
767 767
         );
768 768
 
769
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
769
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
770 770
     }
771 771
 
772 772
 	/**
@@ -798,14 +798,14 @@  discard block
 block discarded – undo
798 798
 	}
799 799
 
800 800
 	public static function cdata( $str ) {
801
-	    $str = maybe_unserialize($str);
802
-	    if ( is_array($str) ) {
803
-	        $str = json_encode($str);
801
+	    $str = maybe_unserialize( $str );
802
+	    if ( is_array( $str ) ) {
803
+	        $str = json_encode( $str );
804 804
 		} else if ( seems_utf8( $str ) == false ) {
805 805
 			$str = utf8_encode( $str );
806 806
 		}
807 807
 
808
-        if ( is_numeric($str) ) {
808
+        if ( is_numeric( $str ) ) {
809 809
             return $str;
810 810
         }
811 811
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
     * @param string $post_type
851 851
     */
852 852
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
853
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
853
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
854 854
             return;
855 855
         }
856 856
 
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
         );
872 872
 
873 873
         foreach ( $post_settings as $post_setting ) {
874
-			if ( isset( $form_options[ $post_setting ] ) ) {
875
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
874
+			if ( isset( $form_options[$post_setting] ) ) {
875
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
876 876
             }
877
-            unset($post_setting);
877
+            unset( $post_setting );
878 878
         }
879 879
 
880 880
 		$new_action['event'] = array( 'create', 'update' );
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 
889 889
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
890 890
         }
891
-        $new_action['post_content'] = json_encode($new_action['post_content']);
891
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
892 892
 
893 893
         $exists = get_posts( array(
894 894
             'name'          => $new_action['post_name'],
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
         if ( ! $exists ) {
901 901
 			// this isn't an email, but we need to use a class that will always be included
902 902
 			FrmAppHelper::save_json_post( $new_action );
903
-            $imported['imported']['actions']++;
903
+            $imported['imported']['actions'] ++;
904 904
         }
905 905
     }
906 906
 
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
         foreach ( $post_content as $key => $setting ) {
933 933
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
934 934
                 // Replace old IDs with new IDs
935
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
935
+				$post_content[$key] = str_replace( $old, $new, $setting );
936 936
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
937 937
                 foreach ( $setting as $k => $val ) {
938 938
                     // Replace old IDs with new IDs
939
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
939
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
940 940
                 }
941 941
             }
942 942
             unset( $key, $setting );
@@ -959,14 +959,14 @@  discard block
 block discarded – undo
959 959
         // Migrate autoresponders
960 960
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
961 961
 
962
-        if (  empty( $notifications ) ) {
962
+        if ( empty( $notifications ) ) {
963 963
             return;
964 964
         }
965 965
 
966 966
         foreach ( $notifications as $new_notification ) {
967 967
             $new_notification['post_type']      = $post_type;
968 968
             $new_notification['post_excerpt']   = 'email';
969
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
969
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
970 970
             $new_notification['menu_order']     = $form_id;
971 971
             $new_notification['post_status']    = 'publish';
972 972
 
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 				// Switch all other field IDs in email
980 980
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
981 981
             }
982
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
982
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
983 983
 
984 984
             $exists = get_posts( array(
985 985
                 'name'          => $new_notification['post_name'],
@@ -988,11 +988,11 @@  discard block
 block discarded – undo
988 988
                 'numberposts'   => 1,
989 989
             ) );
990 990
 
991
-            if ( empty($exists) ) {
991
+            if ( empty( $exists ) ) {
992 992
 				FrmAppHelper::save_json_post( $new_notification );
993
-                $imported['imported']['actions']++;
993
+                $imported['imported']['actions'] ++;
994 994
             }
995
-            unset($new_notification);
995
+            unset( $new_notification );
996 996
         }
997 997
     }
998 998
 
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1006 1006
         }
1007 1007
 
1008
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1008
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1009 1009
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1010 1010
 
1011 1011
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -1033,12 +1033,12 @@  discard block
 block discarded – undo
1033 1033
         // Format the reply to email and name
1034 1034
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1035 1035
         foreach ( $reply_fields as $f => $val ) {
1036
-			if ( isset( $notification[ $f ] ) ) {
1037
-				$atts[ $f ] = $notification[ $f ];
1038
-				if ( 'custom' == $notification[ $f ] ) {
1039
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1040
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1041
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1036
+			if ( isset( $notification[$f] ) ) {
1037
+				$atts[$f] = $notification[$f];
1038
+				if ( 'custom' == $notification[$f] ) {
1039
+					$atts[$f] = $notification['cust_' . $f];
1040
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1041
+					$atts[$f] = '[' . $atts[$f] . ']';
1042 1042
                 }
1043 1043
             }
1044 1044
             unset( $f, $val );
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		$atts['event'] = array( 'create' );
1049 1049
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1050 1050
             $atts['event'][] = 'update';
1051
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1051
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1052 1052
 			$atts['event'] = array( 'update' );
1053 1053
         }
1054 1054
     }
@@ -1069,18 +1069,18 @@  discard block
 block discarded – undo
1069 1069
         foreach ( $atts['email_to'] as $key => $email_field ) {
1070 1070
 
1071 1071
             if ( is_numeric( $email_field ) ) {
1072
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1072
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1073 1073
             }
1074 1074
 
1075
-            if ( strpos( $email_field, '|') ) {
1075
+            if ( strpos( $email_field, '|' ) ) {
1076 1076
                 $email_opt = explode( '|', $email_field );
1077 1077
                 if ( isset( $email_opt[0] ) ) {
1078
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1078
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1079 1079
                 }
1080 1080
                 unset( $email_opt );
1081 1081
             }
1082 1082
         }
1083
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1083
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1084 1084
     }
1085 1085
 
1086 1086
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1096,12 +1096,12 @@  discard block
 block discarded – undo
1096 1096
         // Add more fields to the new notification
1097 1097
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1098 1098
         foreach ( $add_fields as $add_field ) {
1099
-			if ( isset( $notification[ $add_field ] ) ) {
1100
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1099
+			if ( isset( $notification[$add_field] ) ) {
1100
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1101 1101
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1102
-				$new_notification['post_content'][ $add_field ] = 0;
1102
+				$new_notification['post_content'][$add_field] = 0;
1103 1103
             } else {
1104
-				$new_notification['post_content'][ $add_field ] = '';
1104
+				$new_notification['post_content'][$add_field] = '';
1105 1105
             }
1106 1106
             unset( $add_field );
1107 1107
         }
@@ -1125,26 +1125,26 @@  discard block
 block discarded – undo
1125 1125
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1126 1126
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1127 1127
 				if ( is_numeric( $email_key ) ) {
1128
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1128
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1129 1129
 				}
1130
-				unset( $email_key, $val);
1130
+				unset( $email_key, $val );
1131 1131
 			}
1132 1132
 		}
1133 1133
 	}
1134 1134
 
1135 1135
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1136
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1136
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1137 1137
             // migrate autoresponder
1138 1138
 
1139
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1140
-            if ( strpos($email_field, '|') ) {
1139
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1140
+            if ( strpos( $email_field, '|' ) ) {
1141 1141
                 // data from entries field
1142
-                $email_field = explode('|', $email_field);
1143
-                if ( isset($email_field[1]) ) {
1142
+                $email_field = explode( '|', $email_field );
1143
+                if ( isset( $email_field[1] ) ) {
1144 1144
                     $email_field = $email_field[1];
1145 1145
                 }
1146 1146
             }
1147
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1147
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1148 1148
 				$email_field = '[' . $email_field . ']';
1149 1149
             }
1150 1150
 
@@ -1152,16 +1152,16 @@  discard block
 block discarded – undo
1152 1152
             $new_notification2 = array(
1153 1153
                 'post_content'  => array(
1154 1154
                     'email_message' => $notification['ar_email_message'],
1155
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1155
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1156 1156
                     'email_to'      => $email_field,
1157
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1157
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1158 1158
                     'inc_user_info' => 0,
1159 1159
                 ),
1160 1160
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1161 1161
             );
1162 1162
 
1163
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1164
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1163
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1164
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1165 1165
 
1166 1166
 			if ( ! empty( $reply_to ) ) {
1167 1167
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
Indentation   +571 added lines, -571 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,45 +64,45 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-            ));
94
+			));
95 95
 
96 96
 			if ( $term && is_array( $term ) ) {
97
-                $imported['imported']['terms']++;
97
+				$imported['imported']['terms']++;
98 98
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
99
-            }
99
+			}
100 100
 
101 101
 			unset( $term, $t );
102 102
 		}
103 103
 
104 104
 		return $imported;
105
-    }
105
+	}
106 106
 
107 107
 	/**
108 108
 	 * @since 2.0.8
@@ -127,99 +127,99 @@  discard block
 block discarded – undo
127 127
 		self::put_child_forms_first( $forms );
128 128
 
129 129
 		foreach ( $forms as $item ) {
130
-            $form = array(
131
-                'id'            => (int) $item->id,
132
-                'form_key'      => (string) $item->form_key,
133
-                'name'          => (string) $item->name,
134
-                'description'   => (string) $item->description,
135
-                'options'       => (string) $item->options,
136
-                'logged_in'     => (int) $item->logged_in,
137
-                'is_template'   => (int) $item->is_template,
138
-                'default_template' => (int) $item->default_template,
139
-                'editable'      => (int) $item->editable,
140
-                'status'        => (string) $item->status,
141
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
-            );
144
-
145
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
130
+			$form = array(
131
+				'id'            => (int) $item->id,
132
+				'form_key'      => (string) $item->form_key,
133
+				'name'          => (string) $item->name,
134
+				'description'   => (string) $item->description,
135
+				'options'       => (string) $item->options,
136
+				'logged_in'     => (int) $item->logged_in,
137
+				'is_template'   => (int) $item->is_template,
138
+				'default_template' => (int) $item->default_template,
139
+				'editable'      => (int) $item->editable,
140
+				'status'        => (string) $item->status,
141
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
142
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
143
+			);
144
+
145
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146 146
 
147 147
 			self::update_custom_style_setting_on_import( $form );
148 148
 
149
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
149
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
150 150
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
151
-            if ( ! $form['is_template'] ) {
152
-                $edit_query['created_at'] = $form['created_at'];
153
-            }
151
+			if ( ! $form['is_template'] ) {
152
+				$edit_query['created_at'] = $form['created_at'];
153
+			}
154 154
 
155
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
156 156
 
157
-            $this_form = FrmForm::getAll($edit_query, '', 1);
158
-            unset($edit_query);
157
+			$this_form = FrmForm::getAll($edit_query, '', 1);
158
+			unset($edit_query);
159 159
 
160
-            if ( ! empty( $this_form ) ) {
161
-                $old_id = $form_id = $this_form->id;
162
-                FrmForm::update($form_id, $form );
163
-                $imported['updated']['forms']++;
164
-                // Keep track of whether this specific form was updated or not
160
+			if ( ! empty( $this_form ) ) {
161
+				$old_id = $form_id = $this_form->id;
162
+				FrmForm::update($form_id, $form );
163
+				$imported['updated']['forms']++;
164
+				// Keep track of whether this specific form was updated or not
165 165
 				$imported['form_status'][ $form_id ] = 'updated';
166 166
 
167 167
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
168
-                $old_fields = array();
169
-                foreach ( $form_fields as $f ) {
168
+				$old_fields = array();
169
+				foreach ( $form_fields as $f ) {
170 170
 					$old_fields[ $f->id ] = $f;
171 171
 					$old_fields[ $f->field_key ] = $f->id;
172
-                    unset($f);
173
-                }
174
-                $form_fields = $old_fields;
175
-                unset($old_fields);
176
-            } else {
177
-                $old_id = false;
178
-                //form does not exist, so create it
172
+					unset($f);
173
+				}
174
+				$form_fields = $old_fields;
175
+				unset($old_fields);
176
+			} else {
177
+				$old_id = false;
178
+				//form does not exist, so create it
179 179
 				$form_id = FrmForm::create( $form );
180
-                if ( $form_id ) {
181
-                    $imported['imported']['forms']++;
182
-                    // Keep track of whether this specific form was updated or not
180
+				if ( $form_id ) {
181
+					$imported['imported']['forms']++;
182
+					// Keep track of whether this specific form was updated or not
183 183
 					$imported['form_status'][ $form_id ] = 'imported';
184 184
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
185
-                }
186
-            }
185
+				}
186
+			}
187 187
 
188
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
189 189
 
190
-    		// Delete any fields attached to this form that were not included in the template
191
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
190
+			// Delete any fields attached to this form that were not included in the template
191
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
192 192
 				foreach ( $form_fields as $field ) {
193
-                    if ( is_object($field) ) {
194
-                        FrmField::destroy($field->id);
195
-                    }
196
-                    unset($field);
197
-                }
198
-                unset($form_fields);
199
-            }
200
-
201
-		    // Update field ids/keys to new ones
193
+					if ( is_object($field) ) {
194
+						FrmField::destroy($field->id);
195
+					}
196
+					unset($field);
197
+				}
198
+				unset($form_fields);
199
+			}
200
+
201
+			// Update field ids/keys to new ones
202 202
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
203 203
 
204 204
 			$imported['forms'][ (int) $item->id ] = $form_id;
205 205
 
206
-            // Send pre 2.0 form options through function that creates actions
207
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
206
+			// Send pre 2.0 form options through function that creates actions
207
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
208 208
 
209
-		    unset($form, $item);
209
+			unset($form, $item);
210 210
 		}
211 211
 
212 212
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
213 213
 
214 214
 		return $imported;
215
-    }
215
+	}
216 216
 
217 217
 	/**
218
-	* Put child forms first so they will be imported before parents
219
-	*
220
-	* @since 2.0.16
221
-	* @param array $forms
222
-	*/
218
+	 * Put child forms first so they will be imported before parents
219
+	 *
220
+	 * @since 2.0.16
221
+	 * @param array $forms
222
+	 */
223 223
 	private static function put_child_forms_first( &$forms ) {
224 224
 		$child_forms = array();
225 225
 		$regular_forms = array();
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Keep track of all imported child forms
242
-	*
243
-	* @since 2.0.16
244
-	* @param int $form_id
245
-	* @param int $parent_form_id
246
-	* @param array $child_forms
247
-	*/
241
+	 * Keep track of all imported child forms
242
+	 *
243
+	 * @since 2.0.16
244
+	 * @param int $form_id
245
+	 * @param int $parent_form_id
246
+	 * @param array $child_forms
247
+	 */
248 248
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
249 249
 		if ( $parent_form_id ) {
250 250
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Update the parent_form_id on imported child forms
256
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
-	*
258
-	* @since 2.0.6
259
-	* @param array $imported_forms
260
-	* @param array $child_forms
261
-	*/
255
+	 * Update the parent_form_id on imported child forms
256
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
257
+	 *
258
+	 * @since 2.0.6
259
+	 * @param array $imported_forms
260
+	 * @param array $child_forms
261
+	 */
262 262
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
263 263
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Import all fields for a form
276
-	* @since 2.0.13
277
-	*
278
-	* TODO: Cut down on params
279
-	*/
275
+	 * Import all fields for a form
276
+	 * @since 2.0.13
277
+	 *
278
+	 * TODO: Cut down on params
279
+	 */
280 280
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
281 281
 		$in_section = 0;
282 282
 
283 283
 		foreach ( $xml_fields as $field ) {
284
-		    $f = array(
285
-		        'id'            => (int) $field->id,
286
-		        'field_key'     => (string) $field->field_key,
287
-		        'name'          => (string) $field->name,
288
-		        'description'   => (string) $field->description,
289
-		        'type'          => (string) $field->type,
290
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
-		        'field_order'   => (int) $field->field_order,
292
-		        'form_id'       => (int) $form_id,
293
-		        'required'      => (int) $field->required,
294
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
284
+			$f = array(
285
+				'id'            => (int) $field->id,
286
+				'field_key'     => (string) $field->field_key,
287
+				'name'          => (string) $field->name,
288
+				'description'   => (string) $field->description,
289
+				'type'          => (string) $field->type,
290
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
291
+				'field_order'   => (int) $field->field_order,
292
+				'form_id'       => (int) $form_id,
293
+				'required'      => (int) $field->required,
294
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
295 295
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
296
-		    );
297
-
298
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
299
-		        'text', 'email', 'url', 'textarea',
300
-		        'number','phone', 'date', 'time',
301
-		        'hidden', 'password', 'tag', 'image',
302
-		    )) ) {
303
-		        if ( count($f['default_value']) === 1 ) {
296
+			);
297
+
298
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
299
+				'text', 'email', 'url', 'textarea',
300
+				'number','phone', 'date', 'time',
301
+				'hidden', 'password', 'tag', 'image',
302
+			)) ) {
303
+				if ( count($f['default_value']) === 1 ) {
304 304
 					$f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
305
-		        } else {
306
-		            $f['default_value'] = reset($f['default_value']);
307
-		        }
308
-		    }
305
+				} else {
306
+					$f['default_value'] = reset($f['default_value']);
307
+				}
308
+			}
309 309
 
310 310
 			self::maybe_update_in_section_variable( $in_section, $f );
311 311
 			self::maybe_update_form_select( $f, $imported );
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
372
-	*
373
-	* @since 2.0.16
374
-	* @param array $f
375
-	* @param array $imported
376
-	*/
371
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
372
+	 *
373
+	 * @since 2.0.16
374
+	 * @param array $f
375
+	 * @param array $imported
376
+	 */
377 377
 	private static function maybe_update_form_select( &$f, $imported ) {
378 378
 		if ( ! isset( $imported['forms'] ) ) {
379 379
 			return;
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	/**
428
-	* Updates the custom style setting on import
429
-	* Convert the post slug to an ID
430
-	*
431
-	* @since 2.0.19
432
-	* @param array $form
433
-	*
434
-	*/
428
+	 * Updates the custom style setting on import
429
+	 * Convert the post slug to an ID
430
+	 *
431
+	 * @since 2.0.19
432
+	 * @param array $form
433
+	 *
434
+	 */
435 435
 	private static function update_custom_style_setting_on_import( &$form ) {
436 436
 		if ( ! isset( $form['options']['custom_style'] ) ) {
437 437
 			return;
@@ -485,16 +485,16 @@  discard block
 block discarded – undo
485 485
 	}
486 486
 
487 487
 	public static function import_xml_views( $views, $imported ) {
488
-        $imported['posts'] = array();
489
-        $form_action_type = FrmFormActionsController::$action_post_type;
488
+		$imported['posts'] = array();
489
+		$form_action_type = FrmFormActionsController::$action_post_type;
490 490
 
491
-        $post_types = array(
492
-            'frm_display' => 'views',
493
-            $form_action_type => 'actions',
494
-            'frm_styles'    => 'styles',
495
-        );
491
+		$post_types = array(
492
+			'frm_display' => 'views',
493
+			$form_action_type => 'actions',
494
+			'frm_styles'    => 'styles',
495
+		);
496 496
 
497
-        foreach ( $views as $item ) {
497
+		foreach ( $views as $item ) {
498 498
 			$post = array(
499 499
 				'post_title'    => (string) $item->title,
500 500
 				'post_name'     => (string) $item->post_name,
@@ -513,52 +513,52 @@  discard block
 block discarded – undo
513 513
 				'post_date'     => (string) $item->post_date,
514 514
 				'post_date_gmt' => (string) $item->post_date_gmt,
515 515
 				'ping_status'   => (string) $item->ping_status,
516
-                'postmeta'      => array(),
517
-                'tax_input'     => array(),
516
+				'postmeta'      => array(),
517
+				'tax_input'     => array(),
518 518
 			);
519 519
 
520
-            $old_id = $post['post_id'];
521
-            self::populate_post($post, $item, $imported);
520
+			$old_id = $post['post_id'];
521
+			self::populate_post($post, $item, $imported);
522 522
 
523 523
 			unset($item);
524 524
 
525 525
 			$post_id = false;
526
-            if ( $post['post_type'] == $form_action_type ) {
527
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
526
+			if ( $post['post_type'] == $form_action_type ) {
527
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
528 528
 				if ( $action_control && is_object( $action_control ) ) {
529 529
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
530 530
 				}
531
-                unset($action_control);
532
-            } else if ( $post['post_type'] == 'frm_styles' ) {
533
-                // Properly encode post content before inserting the post
534
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
535
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
536
-
537
-                // Create/update post now
538
-                $post_id = wp_insert_post( $post );
539
-            } else {
540
-                // Create/update post now
541
-                $post_id = wp_insert_post( $post );
542
-            }
543
-
544
-            if ( ! is_numeric($post_id) ) {
545
-                continue;
546
-            }
547
-
548
-            self::update_postmeta($post, $post_id);
549
-
550
-            $this_type = 'posts';
531
+				unset($action_control);
532
+			} else if ( $post['post_type'] == 'frm_styles' ) {
533
+				// Properly encode post content before inserting the post
534
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
535
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
536
+
537
+				// Create/update post now
538
+				$post_id = wp_insert_post( $post );
539
+			} else {
540
+				// Create/update post now
541
+				$post_id = wp_insert_post( $post );
542
+			}
543
+
544
+			if ( ! is_numeric($post_id) ) {
545
+				continue;
546
+			}
547
+
548
+			self::update_postmeta($post, $post_id);
549
+
550
+			$this_type = 'posts';
551 551
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
552 552
 				$this_type = $post_types[ $post['post_type'] ];
553
-            }
553
+			}
554 554
 
555
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
556
-                $imported['updated'][ $this_type ]++;
557
-            } else {
558
-                $imported['imported'][ $this_type ]++;
559
-            }
555
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
556
+				$imported['updated'][ $this_type ]++;
557
+			} else {
558
+				$imported['imported'][ $this_type ]++;
559
+			}
560 560
 
561
-            unset($post);
561
+			unset($post);
562 562
 
563 563
 			$imported['posts'][ (int) $old_id ] = $post_id;
564 564
 		}
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
 		self::maybe_update_stylesheet( $imported );
567 567
 
568 568
 		return $imported;
569
-    }
569
+	}
570 570
 
571
-    private static function populate_post( &$post, $item, $imported ) {
571
+	private static function populate_post( &$post, $item, $imported ) {
572 572
 		if ( isset($item->attachment_url) ) {
573 573
 			$post['attachment_url'] = (string) $item->attachment_url;
574 574
 		}
575 575
 
576 576
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
577
-		    // update to new form id
578
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
577
+			// update to new form id
578
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
579 579
 		}
580 580
 
581 581
 		// Don't allow default styles to take over a site's default style
@@ -584,144 +584,144 @@  discard block
 block discarded – undo
584 584
 		}
585 585
 
586 586
 		foreach ( $item->postmeta as $meta ) {
587
-		    self::populate_postmeta($post, $meta, $imported);
587
+			self::populate_postmeta($post, $meta, $imported);
588 588
 			unset($meta);
589 589
 		}
590 590
 
591
-        self::populate_taxonomies($post, $item);
591
+		self::populate_taxonomies($post, $item);
592 592
 
593
-        self::maybe_editing_post($post);
594
-    }
593
+		self::maybe_editing_post($post);
594
+	}
595 595
 
596
-    private static function populate_postmeta( &$post, $meta, $imported ) {
597
-        global $frm_duplicate_ids;
596
+	private static function populate_postmeta( &$post, $meta, $imported ) {
597
+		global $frm_duplicate_ids;
598 598
 
599
-	    $m = array(
599
+		$m = array(
600 600
 			'key'   => (string) $meta->meta_key,
601 601
 			'value' => (string) $meta->meta_value,
602 602
 		);
603 603
 
604 604
 		//switch old form and field ids to new ones
605 605
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
606
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
606
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
607 607
 		} else {
608
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
608
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
609 609
 
610
-		    if ( ! empty($frm_duplicate_ids) ) {
610
+			if ( ! empty($frm_duplicate_ids) ) {
611 611
 
612
-		        if ( $m['key'] == 'frm_dyncontent' ) {
613
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
614
-    		    } else if ( $m['key'] == 'frm_options' ) {
612
+				if ( $m['key'] == 'frm_dyncontent' ) {
613
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
614
+				} else if ( $m['key'] == 'frm_options' ) {
615 615
 
616 616
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
617 617
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
618 618
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
619
-    		            }
620
-    		        }
621
-
622
-                    $check_dup_array = array();
623
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
624
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
625
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
626
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
627
-                            $check_dup_array[] = 'order_by';
628
-    		            }
629
-    		        }
630
-
631
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
632
-    		            $check_dup_array[] = 'where';
633
-    		        }
634
-
635
-                    foreach ( $check_dup_array as $check_k ) {
619
+						}
620
+					}
621
+
622
+					$check_dup_array = array();
623
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
624
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
625
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
626
+						} else if ( is_array( $m['value']['order_by'] ) ) {
627
+							$check_dup_array[] = 'order_by';
628
+						}
629
+					}
630
+
631
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
632
+						$check_dup_array[] = 'where';
633
+					}
634
+
635
+					foreach ( $check_dup_array as $check_k ) {
636 636
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
637 637
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
638 638
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
639
-		                    }
640
-		                    unset($mk, $mv);
641
-		                }
642
-                    }
643
-    		    }
644
-		    }
639
+							}
640
+							unset($mk, $mv);
641
+						}
642
+					}
643
+				}
644
+			}
645 645
 		}
646 646
 
647 647
 		if ( ! is_array($m['value']) ) {
648
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
648
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
649 649
 		}
650 650
 
651 651
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
652
-    }
653
-
654
-    /**
655
-     * Add terms to post
656
-     * @param array $post by reference
657
-     * @param object $item The XML object data
658
-     */
659
-    private static function populate_taxonomies( &$post, $item ) {
652
+	}
653
+
654
+	/**
655
+	 * Add terms to post
656
+	 * @param array $post by reference
657
+	 * @param object $item The XML object data
658
+	 */
659
+	private static function populate_taxonomies( &$post, $item ) {
660 660
 		foreach ( $item->category as $c ) {
661 661
 			$att = $c->attributes();
662 662
 			if ( ! isset( $att['nicename'] ) ) {
663
-                continue;
664
-            }
665
-
666
-		    $taxonomy = (string) $att['domain'];
667
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
668
-		        $name = (string) $att['nicename'];
669
-		        $h_term = get_term_by('slug', $name, $taxonomy);
670
-		        if ( $h_term ) {
671
-		            $name = $h_term->term_id;
672
-		        }
673
-		        unset($h_term);
674
-		    } else {
675
-		        $name = (string) $c;
676
-		    }
663
+				continue;
664
+			}
665
+
666
+			$taxonomy = (string) $att['domain'];
667
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
668
+				$name = (string) $att['nicename'];
669
+				$h_term = get_term_by('slug', $name, $taxonomy);
670
+				if ( $h_term ) {
671
+					$name = $h_term->term_id;
672
+				}
673
+				unset($h_term);
674
+			} else {
675
+				$name = (string) $c;
676
+			}
677 677
 
678 678
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
679 679
 				$post['tax_input'][ $taxonomy ] = array();
680 680
 			}
681 681
 
682 682
 			$post['tax_input'][ $taxonomy ][] = $name;
683
-		    unset($name);
683
+			unset($name);
684 684
 		}
685
-    }
685
+	}
686 686
 
687
-    /**
688
-     * Edit post if the key and created time match
689
-     */
690
-    private static function maybe_editing_post( &$post ) {
687
+	/**
688
+	 * Edit post if the key and created time match
689
+	 */
690
+	private static function maybe_editing_post( &$post ) {
691 691
 		$match_by = array(
692
-		    'post_type'     => $post['post_type'],
693
-		    'name'          => $post['post_name'],
694
-		    'post_status'   => $post['post_status'],
695
-		    'posts_per_page' => 1,
692
+			'post_type'     => $post['post_type'],
693
+			'name'          => $post['post_name'],
694
+			'post_status'   => $post['post_status'],
695
+			'posts_per_page' => 1,
696 696
 		);
697 697
 
698 698
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
699
-		    $match_by['include'] = $post['post_id'];
700
-		    unset($match_by['name']);
699
+			$match_by['include'] = $post['post_id'];
700
+			unset($match_by['name']);
701 701
 		}
702 702
 
703 703
 		$editing = get_posts($match_by);
704 704
 
705
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
706
-            // set the id of the post to edit
707
-            $post['ID'] = current($editing)->ID;
708
-        }
709
-    }
705
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
706
+			// set the id of the post to edit
707
+			$post['ID'] = current($editing)->ID;
708
+		}
709
+	}
710 710
 
711
-    private static function update_postmeta( &$post, $post_id ) {
712
-        foreach ( $post['postmeta'] as $k => $v ) {
713
-            if ( '_edit_last' == $k ) {
714
-                $v = FrmAppHelper::get_user_id_param($v);
715
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
716
-                //change the attachment ID
717
-                $v = FrmProXMLHelper::get_file_id($v);
718
-            }
711
+	private static function update_postmeta( &$post, $post_id ) {
712
+		foreach ( $post['postmeta'] as $k => $v ) {
713
+			if ( '_edit_last' == $k ) {
714
+				$v = FrmAppHelper::get_user_id_param($v);
715
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
716
+				//change the attachment ID
717
+				$v = FrmProXMLHelper::get_file_id($v);
718
+			}
719 719
 
720
-            update_post_meta($post_id, $k, $v);
720
+			update_post_meta($post_id, $k, $v);
721 721
 
722
-            unset($k, $v);
723
-        }
724
-    }
722
+			unset($k, $v);
723
+		}
724
+	}
725 725
 
726 726
 	private static function maybe_update_stylesheet( $imported ) {
727 727
 		$new_styles = isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] );
@@ -737,72 +737,72 @@  discard block
 block discarded – undo
737 737
 		}
738 738
 	}
739 739
 
740
-    /**
741
-     * @param string $message
742
-     */
740
+	/**
741
+	 * @param string $message
742
+	 */
743 743
 	public static function parse_message( $result, &$message, &$errors ) {
744
-        if ( is_wp_error($result) ) {
745
-            $errors[] = $result->get_error_message();
746
-        } else if ( ! $result ) {
747
-            return;
748
-        }
749
-
750
-        if ( ! is_array($result) ) {
751
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
752
-            return;
753
-        }
754
-
755
-        $t_strings = array(
756
-            'imported'  => __( 'Imported', 'formidable' ),
757
-            'updated'   => __( 'Updated', 'formidable' ),
758
-        );
759
-
760
-        $message = '<ul>';
761
-        foreach ( $result as $type => $results ) {
744
+		if ( is_wp_error($result) ) {
745
+			$errors[] = $result->get_error_message();
746
+		} else if ( ! $result ) {
747
+			return;
748
+		}
749
+
750
+		if ( ! is_array($result) ) {
751
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
752
+			return;
753
+		}
754
+
755
+		$t_strings = array(
756
+			'imported'  => __( 'Imported', 'formidable' ),
757
+			'updated'   => __( 'Updated', 'formidable' ),
758
+		);
759
+
760
+		$message = '<ul>';
761
+		foreach ( $result as $type => $results ) {
762 762
 			if ( ! isset( $t_strings[ $type ] ) ) {
763
-                // only print imported and updated
764
-                continue;
765
-            }
763
+				// only print imported and updated
764
+				continue;
765
+			}
766 766
 
767
-            $s_message = array();
768
-            foreach ( $results as $k => $m ) {
769
-                self::item_count_message($m, $k, $s_message);
770
-                unset($k, $m);
771
-            }
767
+			$s_message = array();
768
+			foreach ( $results as $k => $m ) {
769
+				self::item_count_message($m, $k, $s_message);
770
+				unset($k, $m);
771
+			}
772 772
 
773
-            if ( ! empty($s_message) ) {
773
+			if ( ! empty($s_message) ) {
774 774
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
775
-                $message .= implode(', ', $s_message);
776
-                $message .= '</li>';
777
-            }
778
-        }
779
-
780
-        if ( $message == '<ul>' ) {
781
-            $message = '';
782
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
783
-        } else {
784
-            $message .= '</ul>';
785
-        }
786
-    }
775
+				$message .= implode(', ', $s_message);
776
+				$message .= '</li>';
777
+			}
778
+		}
779
+
780
+		if ( $message == '<ul>' ) {
781
+			$message = '';
782
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
783
+		} else {
784
+			$message .= '</ul>';
785
+		}
786
+	}
787 787
 
788 788
 	public static function item_count_message( $m, $type, &$s_message ) {
789
-        if ( ! $m ) {
790
-            return;
791
-        }
792
-
793
-        $strings = array(
794
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
795
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
796
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
797
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
798
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
799
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
800
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
801
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
802
-        );
789
+		if ( ! $m ) {
790
+			return;
791
+		}
792
+
793
+		$strings = array(
794
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
795
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
796
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
797
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
798
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
799
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
800
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
801
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
802
+		);
803 803
 
804 804
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
805
-    }
805
+	}
806 806
 
807 807
 	/**
808 808
 	 * Prepare the form options for export
@@ -833,16 +833,16 @@  discard block
 block discarded – undo
833 833
 	}
834 834
 
835 835
 	public static function cdata( $str ) {
836
-	    $str = maybe_unserialize($str);
837
-	    if ( is_array($str) ) {
838
-	        $str = json_encode($str);
836
+		$str = maybe_unserialize($str);
837
+		if ( is_array($str) ) {
838
+			$str = json_encode($str);
839 839
 		} else if ( seems_utf8( $str ) == false ) {
840 840
 			$str = utf8_encode( $str );
841 841
 		}
842 842
 
843
-        if ( is_numeric($str) ) {
844
-            return $str;
845
-        }
843
+		if ( is_numeric($str) ) {
844
+			return $str;
845
+		}
846 846
 
847 847
 		self::remove_invalid_characters_from_xml( $str );
848 848
 
@@ -863,58 +863,58 @@  discard block
 block discarded – undo
863 863
 		$str = str_replace( '\x1F', '', $str );
864 864
 	}
865 865
 
866
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
867
-        // Get post type
868
-        $post_type = FrmFormActionsController::$action_post_type;
869
-
870
-        // Set up imported index, if not set up yet
871
-        if ( ! isset( $imported['imported']['actions'] ) ) {
872
-            $imported['imported']['actions'] = 0;
873
-        }
874
-
875
-        // Migrate post settings to action
876
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
877
-
878
-        // Migrate email settings to action
879
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
880
-    }
881
-
882
-    /**
883
-    * Migrate post settings to form action
884
-    *
885
-    * @param string $post_type
886
-    */
887
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
888
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
889
-            return;
890
-        }
891
-
892
-        $new_action = array(
893
-            'post_type'     => $post_type,
894
-            'post_excerpt'  => 'wppost',
866
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
867
+		// Get post type
868
+		$post_type = FrmFormActionsController::$action_post_type;
869
+
870
+		// Set up imported index, if not set up yet
871
+		if ( ! isset( $imported['imported']['actions'] ) ) {
872
+			$imported['imported']['actions'] = 0;
873
+		}
874
+
875
+		// Migrate post settings to action
876
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
877
+
878
+		// Migrate email settings to action
879
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
880
+	}
881
+
882
+	/**
883
+	 * Migrate post settings to form action
884
+	 *
885
+	 * @param string $post_type
886
+	 */
887
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
888
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
889
+			return;
890
+		}
891
+
892
+		$new_action = array(
893
+			'post_type'     => $post_type,
894
+			'post_excerpt'  => 'wppost',
895 895
 			'post_title'    => __( 'Create Posts', 'formidable' ),
896
-            'menu_order'    => $form_id,
897
-            'post_status'   => 'publish',
898
-            'post_content'  => array(),
896
+			'menu_order'    => $form_id,
897
+			'post_status'   => 'publish',
898
+			'post_content'  => array(),
899 899
 			'post_name'     => $form_id . '_wppost_1',
900
-        );
900
+		);
901 901
 
902
-        $post_settings = array(
903
-            'post_type', 'post_category', 'post_content',
904
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
902
+		$post_settings = array(
903
+			'post_type', 'post_category', 'post_content',
904
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
905 905
 			'post_status', 'post_custom_fields', 'post_password',
906
-        );
906
+		);
907 907
 
908
-        foreach ( $post_settings as $post_setting ) {
908
+		foreach ( $post_settings as $post_setting ) {
909 909
 			if ( isset( $form_options[ $post_setting ] ) ) {
910 910
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
911
-            }
912
-            unset($post_setting);
913
-        }
911
+			}
912
+			unset($post_setting);
913
+		}
914 914
 
915 915
 		$new_action['event'] = array( 'create', 'update' );
916 916
 
917
-        if ( $switch ) {
917
+		if ( $switch ) {
918 918
 			// Fields with string or int saved
919 919
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
920 920
 
@@ -922,22 +922,22 @@  discard block
 block discarded – undo
922 922
 			$array_fields = array( 'post_category', 'post_custom_fields' );
923 923
 
924 924
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
925
-        }
926
-        $new_action['post_content'] = json_encode($new_action['post_content']);
925
+		}
926
+		$new_action['post_content'] = json_encode($new_action['post_content']);
927 927
 
928
-        $exists = get_posts( array(
929
-            'name'          => $new_action['post_name'],
930
-            'post_type'     => $new_action['post_type'],
931
-            'post_status'   => $new_action['post_status'],
932
-            'numberposts'   => 1,
933
-        ) );
928
+		$exists = get_posts( array(
929
+			'name'          => $new_action['post_name'],
930
+			'post_type'     => $new_action['post_type'],
931
+			'post_status'   => $new_action['post_status'],
932
+			'numberposts'   => 1,
933
+		) );
934 934
 
935
-        if ( ! $exists ) {
935
+		if ( ! $exists ) {
936 936
 			// this isn't an email, but we need to use a class that will always be included
937 937
 			FrmAppHelper::save_json_post( $new_action );
938
-            $imported['imported']['actions']++;
939
-        }
940
-    }
938
+			$imported['imported']['actions']++;
939
+		}
940
+	}
941 941
 
942 942
 	/**
943 943
 	 * Switch old field IDs for new field IDs in emails and post
@@ -950,211 +950,211 @@  discard block
 block discarded – undo
950 950
 	 * @return string $post_content - new field IDs
951 951
 	 */
952 952
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
953
-        global $frm_duplicate_ids;
953
+		global $frm_duplicate_ids;
954 954
 
955
-        // If there aren't IDs that were switched, end now
956
-        if ( ! $frm_duplicate_ids ) {
957
-            return;
958
-        }
955
+		// If there aren't IDs that were switched, end now
956
+		if ( ! $frm_duplicate_ids ) {
957
+			return;
958
+		}
959 959
 
960
-        // Get old IDs
961
-        $old = array_keys( $frm_duplicate_ids );
960
+		// Get old IDs
961
+		$old = array_keys( $frm_duplicate_ids );
962 962
 
963
-        // Get new IDs
964
-        $new = array_values( $frm_duplicate_ids );
963
+		// Get new IDs
964
+		$new = array_values( $frm_duplicate_ids );
965 965
 
966
-        // Do a str_replace with each item to set the new IDs
967
-        foreach ( $post_content as $key => $setting ) {
968
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
969
-                // Replace old IDs with new IDs
966
+		// Do a str_replace with each item to set the new IDs
967
+		foreach ( $post_content as $key => $setting ) {
968
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
969
+				// Replace old IDs with new IDs
970 970
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
971
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
972
-                foreach ( $setting as $k => $val ) {
973
-                    // Replace old IDs with new IDs
971
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
972
+				foreach ( $setting as $k => $val ) {
973
+					// Replace old IDs with new IDs
974 974
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
975
-                }
976
-            }
977
-            unset( $key, $setting );
978
-        }
979
-        return $post_content;
980
-    }
981
-
982
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
983
-        // No old notifications or autoresponders to carry over
975
+				}
976
+			}
977
+			unset( $key, $setting );
978
+		}
979
+		return $post_content;
980
+	}
981
+
982
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
983
+		// No old notifications or autoresponders to carry over
984 984
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
985
-            return;
986
-        }
985
+			return;
986
+		}
987 987
 
988
-        // Initialize notifications array
989
-        $notifications = array();
988
+		// Initialize notifications array
989
+		$notifications = array();
990 990
 
991
-        // Migrate regular notifications
992
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
991
+		// Migrate regular notifications
992
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
993 993
 
994
-        // Migrate autoresponders
995
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
994
+		// Migrate autoresponders
995
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
996 996
 
997
-        if (  empty( $notifications ) ) {
998
-            return;
999
-        }
997
+		if (  empty( $notifications ) ) {
998
+			return;
999
+		}
1000 1000
 
1001
-        foreach ( $notifications as $new_notification ) {
1002
-            $new_notification['post_type']      = $post_type;
1003
-            $new_notification['post_excerpt']   = 'email';
1001
+		foreach ( $notifications as $new_notification ) {
1002
+			$new_notification['post_type']      = $post_type;
1003
+			$new_notification['post_excerpt']   = 'email';
1004 1004
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1005
-            $new_notification['menu_order']     = $form_id;
1006
-            $new_notification['post_status']    = 'publish';
1005
+			$new_notification['menu_order']     = $form_id;
1006
+			$new_notification['post_status']    = 'publish';
1007 1007
 
1008
-            // Switch field IDs and keys, if needed
1009
-            if ( $switch ) {
1008
+			// Switch field IDs and keys, if needed
1009
+			if ( $switch ) {
1010 1010
 
1011 1011
 				// Switch field IDs in email conditional logic
1012 1012
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1013 1013
 
1014 1014
 				// Switch all other field IDs in email
1015
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1016
-            }
1017
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1018
-
1019
-            $exists = get_posts( array(
1020
-                'name'          => $new_notification['post_name'],
1021
-                'post_type'     => $new_notification['post_type'],
1022
-                'post_status'   => $new_notification['post_status'],
1023
-                'numberposts'   => 1,
1024
-            ) );
1025
-
1026
-            if ( empty($exists) ) {
1015
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1016
+			}
1017
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1018
+
1019
+			$exists = get_posts( array(
1020
+				'name'          => $new_notification['post_name'],
1021
+				'post_type'     => $new_notification['post_type'],
1022
+				'post_status'   => $new_notification['post_status'],
1023
+				'numberposts'   => 1,
1024
+			) );
1025
+
1026
+			if ( empty($exists) ) {
1027 1027
 				FrmAppHelper::save_json_post( $new_notification );
1028
-                $imported['imported']['actions']++;
1029
-            }
1030
-            unset($new_notification);
1031
-        }
1032
-    }
1033
-
1034
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1035
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1036
-            // add old settings into notification array
1028
+				$imported['imported']['actions']++;
1029
+			}
1030
+			unset($new_notification);
1031
+		}
1032
+	}
1033
+
1034
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1035
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1036
+			// add old settings into notification array
1037 1037
 			$form_options['notification'] = array( 0 => $form_options );
1038
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1039
-            // make sure it's in the correct format
1038
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1039
+			// make sure it's in the correct format
1040 1040
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1041
-        }
1041
+		}
1042 1042
 
1043
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1044
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1043
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1044
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1045 1045
 
1046
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1046
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
1047 1047
 
1048
-                // Format the email data
1049
-                self::format_email_data( $atts, $notification );
1048
+				// Format the email data
1049
+				self::format_email_data( $atts, $notification );
1050 1050
 
1051 1051
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1052 1052
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1053 1053
 				}
1054 1054
 
1055
-                // Setup the new notification
1056
-                $new_notification = array();
1057
-                self::setup_new_notification( $new_notification, $notification, $atts );
1055
+				// Setup the new notification
1056
+				$new_notification = array();
1057
+				self::setup_new_notification( $new_notification, $notification, $atts );
1058 1058
 
1059
-                $notifications[] = $new_notification;
1060
-            }
1061
-        }
1062
-    }
1059
+				$notifications[] = $new_notification;
1060
+			}
1061
+		}
1062
+	}
1063 1063
 
1064
-    private static function format_email_data( &$atts, $notification ) {
1065
-        // Format email_to
1066
-        self::format_email_to_data( $atts, $notification );
1064
+	private static function format_email_data( &$atts, $notification ) {
1065
+		// Format email_to
1066
+		self::format_email_to_data( $atts, $notification );
1067 1067
 
1068
-        // Format the reply to email and name
1069
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1070
-        foreach ( $reply_fields as $f => $val ) {
1068
+		// Format the reply to email and name
1069
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
1070
+		foreach ( $reply_fields as $f => $val ) {
1071 1071
 			if ( isset( $notification[ $f ] ) ) {
1072 1072
 				$atts[ $f ] = $notification[ $f ];
1073 1073
 				if ( 'custom' == $notification[ $f ] ) {
1074 1074
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1075 1075
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1076 1076
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1077
-                }
1078
-            }
1079
-            unset( $f, $val );
1080
-        }
1077
+				}
1078
+			}
1079
+			unset( $f, $val );
1080
+		}
1081 1081
 
1082
-        // Format event
1082
+		// Format event
1083 1083
 		$atts['event'] = array( 'create' );
1084
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1085
-            $atts['event'][] = 'update';
1086
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1084
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1085
+			$atts['event'][] = 'update';
1086
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1087 1087
 			$atts['event'] = array( 'update' );
1088
-        }
1089
-    }
1088
+		}
1089
+	}
1090 1090
 
1091
-    private static function format_email_to_data( &$atts, $notification ) {
1092
-        if ( isset( $notification['email_to'] ) ) {
1091
+	private static function format_email_to_data( &$atts, $notification ) {
1092
+		if ( isset( $notification['email_to'] ) ) {
1093 1093
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1094
-        } else {
1095
-            $atts['email_to'] = array();
1096
-        }
1094
+		} else {
1095
+			$atts['email_to'] = array();
1096
+		}
1097 1097
 
1098
-        if ( isset( $notification['also_email_to'] ) ) {
1099
-            $email_fields = (array) $notification['also_email_to'];
1100
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1101
-            unset( $email_fields );
1102
-        }
1098
+		if ( isset( $notification['also_email_to'] ) ) {
1099
+			$email_fields = (array) $notification['also_email_to'];
1100
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1101
+			unset( $email_fields );
1102
+		}
1103 1103
 
1104
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1104
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1105 1105
 
1106
-            if ( is_numeric( $email_field ) ) {
1106
+			if ( is_numeric( $email_field ) ) {
1107 1107
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1108
-            }
1108
+			}
1109 1109
 
1110
-            if ( strpos( $email_field, '|') ) {
1111
-                $email_opt = explode( '|', $email_field );
1112
-                if ( isset( $email_opt[0] ) ) {
1110
+			if ( strpos( $email_field, '|') ) {
1111
+				$email_opt = explode( '|', $email_field );
1112
+				if ( isset( $email_opt[0] ) ) {
1113 1113
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1114
-                }
1115
-                unset( $email_opt );
1116
-            }
1117
-        }
1118
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1119
-    }
1120
-
1121
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1122
-        // Set up new notification
1123
-        $new_notification = array(
1124
-            'post_content'  => array(
1125
-                'email_to'      => $atts['email_to'],
1126
-                'event'         => $atts['event'],
1127
-            ),
1114
+				}
1115
+				unset( $email_opt );
1116
+			}
1117
+		}
1118
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1119
+	}
1120
+
1121
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1122
+		// Set up new notification
1123
+		$new_notification = array(
1124
+			'post_content'  => array(
1125
+				'email_to'      => $atts['email_to'],
1126
+				'event'         => $atts['event'],
1127
+			),
1128 1128
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1129
-        );
1129
+		);
1130 1130
 
1131
-        // Add more fields to the new notification
1132
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1133
-        foreach ( $add_fields as $add_field ) {
1131
+		// Add more fields to the new notification
1132
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1133
+		foreach ( $add_fields as $add_field ) {
1134 1134
 			if ( isset( $notification[ $add_field ] ) ) {
1135 1135
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1136
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1136
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1137 1137
 				$new_notification['post_content'][ $add_field ] = 0;
1138
-            } else {
1138
+			} else {
1139 1139
 				$new_notification['post_content'][ $add_field ] = '';
1140
-            }
1141
-            unset( $add_field );
1142
-        }
1140
+			}
1141
+			unset( $add_field );
1142
+		}
1143 1143
 
1144 1144
 		// Set reply to
1145 1145
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1146 1146
 
1147
-        // Set from
1147
+		// Set from
1148 1148
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1149 1149
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1150
-        }
1151
-    }
1150
+		}
1151
+	}
1152 1152
 
1153 1153
 	/**
1154
-	* Switch field IDs in pre-2.0 email conditional logic
1155
-	*
1156
-	* @param $post_content array, pass by reference
1157
-	*/
1154
+	 * Switch field IDs in pre-2.0 email conditional logic
1155
+	 *
1156
+	 * @param $post_content array, pass by reference
1157
+	 */
1158 1158
 	private static function switch_email_contition_field_ids( &$post_content ) {
1159 1159
 		// Switch field IDs in conditional logic
1160 1160
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1167,36 +1167,36 @@  discard block
 block discarded – undo
1167 1167
 		}
1168 1168
 	}
1169 1169
 
1170
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1171
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1172
-            // migrate autoresponder
1173
-
1174
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1175
-            if ( strpos($email_field, '|') ) {
1176
-                // data from entries field
1177
-                $email_field = explode('|', $email_field);
1178
-                if ( isset($email_field[1]) ) {
1179
-                    $email_field = $email_field[1];
1180
-                }
1181
-            }
1182
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1170
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1171
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1172
+			// migrate autoresponder
1173
+
1174
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1175
+			if ( strpos($email_field, '|') ) {
1176
+				// data from entries field
1177
+				$email_field = explode('|', $email_field);
1178
+				if ( isset($email_field[1]) ) {
1179
+					$email_field = $email_field[1];
1180
+				}
1181
+			}
1182
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1183 1183
 				$email_field = '[' . $email_field . ']';
1184
-            }
1185
-
1186
-            $notification = $form_options;
1187
-            $new_notification2 = array(
1188
-                'post_content'  => array(
1189
-                    'email_message' => $notification['ar_email_message'],
1190
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1191
-                    'email_to'      => $email_field,
1192
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1193
-                    'inc_user_info' => 0,
1194
-                ),
1184
+			}
1185
+
1186
+			$notification = $form_options;
1187
+			$new_notification2 = array(
1188
+				'post_content'  => array(
1189
+					'email_message' => $notification['ar_email_message'],
1190
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1191
+					'email_to'      => $email_field,
1192
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1193
+					'inc_user_info' => 0,
1194
+				),
1195 1195
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1196
-            );
1196
+			);
1197 1197
 
1198
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1199
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1198
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1199
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1200 1200
 
1201 1201
 			if ( ! empty( $reply_to ) ) {
1202 1202
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1206,9 +1206,9 @@  discard block
 block discarded – undo
1206 1206
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1207 1207
 			}
1208 1208
 
1209
-            $notifications[] = $new_notification2;
1210
-            unset( $new_notification2 );
1211
-        }
1212
-    }
1209
+			$notifications[] = $new_notification2;
1210
+			unset( $new_notification2 );
1211
+		}
1212
+	}
1213 1213
 }
1214 1214
 
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -5,69 +5,69 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		$values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11 11
 			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12
-        }
13
-
14
-        $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
17
-        }
18
-
19
-        foreach ( (array) $fields as $field ) {
20
-            $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
-
22
-            $field_array = array(
23
-                'id' => $field->id,
24
-                'value' => $new_value,
25
-                'default_value' => $field->default_value,
26
-                'name' => $field->name,
27
-                'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
-                'options' => $field->options,
30
-                'required' => $field->required,
31
-                'field_key' => $field->field_key,
32
-                'field_order' => $field->field_order,
33
-                'form_id' => $field->form_id,
12
+		}
13
+
14
+		$values['fields'] = array();
15
+		if ( empty($fields) ) {
16
+			return apply_filters('frm_setup_new_entry', $values);
17
+		}
18
+
19
+		foreach ( (array) $fields as $field ) {
20
+			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
21
+
22
+			$field_array = array(
23
+				'id' => $field->id,
24
+				'value' => $new_value,
25
+				'default_value' => $field->default_value,
26
+				'name' => $field->name,
27
+				'description' => $field->description,
28
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+				'options' => $field->options,
30
+				'required' => $field->required,
31
+				'field_key' => $field->field_key,
32
+				'field_order' => $field->field_order,
33
+				'form_id' => $field->form_id,
34 34
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
35
-	            'reset_value' => $reset,
35
+				'reset_value' => $reset,
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37
-            );
37
+			);
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
-            $opt_defaults['required_indicator'] = '';
39
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
40
+			$opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
46
-            }
44
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
+				unset($opt, $default_opt);
46
+			}
47 47
 
48
-            unset($opt_defaults);
48
+			unset($opt_defaults);
49 49
 
50
-            if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
-            }
50
+			if ( $field_array['custom_html'] == '' ) {
51
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
52
+			}
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
-            $field_array = array_merge( $field->field_options, $field_array );
54
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
55
+			$field_array = array_merge( $field->field_options, $field_array );
56 56
 
57
-            $values['fields'][] = $field_array;
57
+			$values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
61
-            }
62
-        }
59
+			if ( ! $form || ! isset($form->id) ) {
60
+				$form = FrmForm::getOne($field->form_id);
61
+			}
62
+		}
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
66
-            foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
69
-            }
70
-        }
64
+		$form->options = maybe_unserialize($form->options);
65
+		if ( is_array($form->options) ) {
66
+			foreach ( $form->options as $opt => $value ) {
67
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
+				unset($opt, $value);
69
+			}
70
+		}
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
79 79
 		return apply_filters( 'frm_setup_new_entry', $values );
80
-    }
80
+	}
81 81
 
82 82
 	/**
83
-	* Set the value for each field
84
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
85
-	*
86
-	* @since 2.0.13
87
-	*
88
-	* @param object $field - this is passed by reference since it is an object
89
-	* @param boolean $reset
90
-	* @param array $args
91
-	* @return string|array $new_value
92
-	*/
83
+	 * Set the value for each field
84
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
85
+	 *
86
+	 * @since 2.0.13
87
+	 *
88
+	 * @param object $field - this is passed by reference since it is an object
89
+	 * @param boolean $reset
90
+	 * @param array $args
91
+	 * @return string|array $new_value
92
+	 */
93 93
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
94 94
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Check if a field has a posted value
119
-	*
120
-	* @since 2.01.0
121
-	* @param object $field
122
-	* @param array $args
123
-	* @return boolean $value_is_posted
124
-	*/
118
+	 * Check if a field has a posted value
119
+	 *
120
+	 * @since 2.01.0
121
+	 * @param object $field
122
+	 * @param array $args
123
+	 * @return boolean $value_is_posted
124
+	 */
125 125
 	public static function value_is_posted( $field, $args ) {
126 126
 		$value_is_posted = false;
127 127
 		if ( $_POST ) {
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 
140 140
 	public static function setup_edit_vars( $values, $record ) {
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142
-        $values['form_id'] = $record->form_id;
143
-        $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
-    }
142
+		$values['form_id'] = $record->form_id;
143
+		$values['is_draft'] = $record->is_draft;
144
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
145
+	}
146 146
 
147
-    public static function get_admin_params( $form = null ) {
147
+	public static function get_admin_params( $form = null ) {
148 148
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
149 149
 		return FrmForm::set_current_form( $form );
150
-    }
150
+	}
151 151
 
152 152
 	public static function set_current_form( $form_id ) {
153 153
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -159,284 +159,284 @@  discard block
 block discarded – undo
159 159
 		return FrmForm::get_current_form( $form_id );
160 160
 	}
161 161
 
162
-    public static function get_current_form_id() {
162
+	public static function get_current_form_id() {
163 163
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
164 164
 		return FrmForm::get_current_form_id();
165
-    }
165
+	}
166 166
 
167
-    public static function maybe_get_entry( &$entry ) {
167
+	public static function maybe_get_entry( &$entry ) {
168 168
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
169 169
 		FrmEntry::maybe_get_entry( $entry );
170
-    }
170
+	}
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
175
-            ! empty( $message ) ) {
176
-            return $message;
177
-        }
178
-
179
-        if ( empty($message) ) {
180
-            $message = '[default-message]';
181
-        }
182
-
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
-
185
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
-            if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
189
-            } else {
190
-                $this_atts = $atts;
191
-            }
173
+		if ( strpos($message, '[default-message') === false &&
174
+			strpos($message, '[default_message') === false &&
175
+			! empty( $message ) ) {
176
+			return $message;
177
+		}
178
+
179
+		if ( empty($message) ) {
180
+			$message = '[default-message]';
181
+		}
182
+
183
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
184
+
185
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
186
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
187
+			if ( $add_atts ) {
188
+				$this_atts = array_merge($atts, $add_atts);
189
+			} else {
190
+				$this_atts = $atts;
191
+			}
192 192
 
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195
-            // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
-        }
195
+			// Add the default message
196
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
197
+		}
198 198
 
199
-        return $message;
200
-    }
199
+		return $message;
200
+	}
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203 203
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
204 204
 
205
-        if ( FrmAppHelper::pro_is_installed() ) {
205
+		if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207
-        }
207
+		}
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
211
-        }
209
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
+			return self::display_value($field_value, $field, $atts);
211
+		}
212 212
 
213
-        // this is an embeded form
214
-        $val = '';
213
+		// this is an embeded form
214
+		$val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
-            //this is a repeating section
216
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
217
+			//this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219
-        } else {
220
-            // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
219
+		} else {
220
+			// get all values for this field
221
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
222 222
 
223
-            if ( $child_values ) {
224
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
-	        }
226
-	    }
223
+			if ( $child_values ) {
224
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
225
+			}
226
+		}
227 227
 
228
-	    $field_value = array();
228
+		$field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
-            return $val;
232
-        }
230
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231
+			return $val;
232
+		}
233 233
 
234
-        foreach ( $child_entries as $child_entry ) {
235
-            $atts['item_id'] = $child_entry->id;
236
-            $atts['post_id'] = $child_entry->post_id;
234
+		foreach ( $child_entries as $child_entry ) {
235
+			$atts['item_id'] = $child_entry->id;
236
+			$atts['post_id'] = $child_entry->post_id;
237 237
 
238
-            // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
238
+			// get the value for this field -- check for post values as well
239
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
240 240
 
241
-            if ( $entry_val ) {
242
-                // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
244
-            }
241
+			if ( $entry_val ) {
242
+				// foreach entry get display_value
243
+				$field_value[] = self::display_value($entry_val, $field, $atts);
244
+			}
245 245
 
246
-            unset($child_entry);
247
-        }
246
+			unset($child_entry);
247
+		}
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+		$val = implode(', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252
-        return $val;
253
-    }
252
+		return $val;
253
+	}
254 254
 
255
-    /**
256
-     * Prepare the saved value for display
257
-     * @return string
258
-     */
255
+	/**
256
+	 * Prepare the saved value for display
257
+	 * @return string
258
+	 */
259 259
 	public static function display_value( $value, $field, $atts = array() ) {
260 260
 
261
-        $defaults = array(
262
-            'type' => '', 'html' => false, 'show_filename' => true,
263
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
261
+		$defaults = array(
262
+			'type' => '', 'html' => false, 'show_filename' => true,
263
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
264
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
265 265
 			'return_array' => false,
266
-        );
266
+		);
267 267
 
268
-        $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
268
+		$atts = wp_parse_args( $atts, $defaults );
269
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
272
-            $field->field_options['post_field'] = '';
273
-        }
271
+		if ( ! isset($field->field_options['post_field']) ) {
272
+			$field->field_options['post_field'] = '';
273
+		}
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
276
-            $field->field_options['custom_field'] = '';
277
-        }
275
+		if ( ! isset($field->field_options['custom_field']) ) {
276
+			$field->field_options['custom_field'] = '';
277
+		}
278 278
 
279
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
-            $atts['pre_truncate'] = $atts['truncate'];
281
-            $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
279
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280
+			$atts['pre_truncate'] = $atts['truncate'];
281
+			$atts['truncate'] = true;
282
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
-            $atts['truncate'] = $atts['pre_truncate'];
286
-        }
284
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
285
+			$atts['truncate'] = $atts['pre_truncate'];
286
+		}
287 287
 
288
-        if ( $value == '' ) {
289
-            return $value;
290
-        }
288
+		if ( $value == '' ) {
289
+			return $value;
290
+		}
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295
-        $new_value = '';
295
+		$new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
298
-            foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
297
+		if ( is_array($value) && $atts['type'] != 'file' ) {
298
+			foreach ( $value as $val ) {
299
+				if ( is_array($val) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
302
-                    if ( $atts['type'] != 'data' ) {
303
-                        $new_value .= '<br/>';
304
-                    }
305
-                }
306
-                unset($val);
307
-            }
308
-        }
309
-
310
-        if ( ! empty($new_value) ) {
311
-            $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
314
-        }
315
-
316
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
318
-        }
301
+					$new_value .= implode($atts['sep'], $val);
302
+					if ( $atts['type'] != 'data' ) {
303
+						$new_value .= '<br/>';
304
+					}
305
+				}
306
+				unset($val);
307
+			}
308
+		}
309
+
310
+		if ( ! empty($new_value) ) {
311
+			$value = $new_value;
312
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+			$value = implode($atts['sep'], $value);
314
+		}
315
+
316
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
+			$value = FrmAppHelper::truncate($value, 50);
318
+		}
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
325
-    }
324
+		return apply_filters('frm_display_value', $value, $field, $atts);
325
+	}
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
328
-        // If validating a field with "other" opt, set back to prev value now
329
-        if ( isset( $args['other'] ) && $args['other'] ) {
330
-            $value = $args['temp_value'];
331
-        }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
334
-        } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
-        }
337
-    }
328
+		// If validating a field with "other" opt, set back to prev value now
329
+		if ( isset( $args['other'] ) && $args['other'] ) {
330
+			$value = $args['temp_value'];
331
+		}
332
+		if ( empty($args['parent_field_id']) ) {
333
+			$_POST['item_meta'][ $field->id ] = $value;
334
+		} else {
335
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
336
+		}
337
+	}
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
-        } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
-        }
342
+		if ( empty($args['parent_field_id']) ) {
343
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
344
+		} else {
345
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
346
+		}
347 347
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
348 348
 		$value = stripslashes_deep( $value );
349
-    }
350
-
351
-    /**
352
-    * Check if field has an "Other" option and if any other values are posted
353
-    *
354
-    * @since 2.0
355
-    *
356
-    * @param object $field
357
-    * @param string|array $value
358
-    * @param array $args
359
-    */
360
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
361
-        $args['other'] = false;
362
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
363
-            return;
364
-        }
365
-
366
-        // Get other value for fields in repeating section
367
-        self::set_other_repeating_vals( $field, $value, $args );
368
-
369
-        // Check if there are any posted "Other" values
349
+	}
350
+
351
+	/**
352
+	 * Check if field has an "Other" option and if any other values are posted
353
+	 *
354
+	 * @since 2.0
355
+	 *
356
+	 * @param object $field
357
+	 * @param string|array $value
358
+	 * @param array $args
359
+	 */
360
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
361
+		$args['other'] = false;
362
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
363
+			return;
364
+		}
365
+
366
+		// Get other value for fields in repeating section
367
+		self::set_other_repeating_vals( $field, $value, $args );
368
+
369
+		// Check if there are any posted "Other" values
370 370
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
371 371
 
372
-            // Save original value
373
-            $args['temp_value'] = $value;
374
-            $args['other'] = true;
375
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
376
-
377
-            // Set the validation value now
378
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
379
-        }
380
-    }
381
-
382
-    /**
383
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
384
-    *
385
-    * @since 2.0
386
-    *
387
-    * @param object $field
388
-    * @param string|array $value
389
-    * @param array $args
390
-    */
391
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
392
-        if ( ! $args['parent_field_id'] ) {
393
-            return;
394
-        }
395
-
396
-        // Check if there are any other posted "other" values for this field
372
+			// Save original value
373
+			$args['temp_value'] = $value;
374
+			$args['other'] = true;
375
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
376
+
377
+			// Set the validation value now
378
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
379
+		}
380
+	}
381
+
382
+	/**
383
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
384
+	 *
385
+	 * @since 2.0
386
+	 *
387
+	 * @param object $field
388
+	 * @param string|array $value
389
+	 * @param array $args
390
+	 */
391
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
392
+		if ( ! $args['parent_field_id'] ) {
393
+			return;
394
+		}
395
+
396
+		// Check if there are any other posted "other" values for this field
397 397
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
398
-            // Save original value
399
-            $args['temp_value'] = $value;
400
-            $args['other'] = true;
401
-
402
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
403
-
404
-            // Set the validation value now
405
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
406
-        }
407
-    }
408
-
409
-    /**
410
-    * Modify value used for validation
411
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
412
-    * It also adds any text from the free text fields to the value
413
-    *
414
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
415
-    *
416
-    * @since 2.0
417
-    *
418
-    * @param string|array $value
419
-    * @param string|array $other_vals (usually of posted values)
420
-    * @param object $field
421
-    * @param array $args
422
-    */
423
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
424
-        // Checkboxes and multi-select dropdowns
425
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
426
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
427
-            $value = array_merge( $value, $other_vals );
428
-            $value = array_filter( $value );
429
-            if ( count( $value ) == 0 ) {
430
-                $value = '';
431
-            }
432
-        } else {
398
+			// Save original value
399
+			$args['temp_value'] = $value;
400
+			$args['other'] = true;
401
+
402
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
403
+
404
+			// Set the validation value now
405
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
406
+		}
407
+	}
408
+
409
+	/**
410
+	 * Modify value used for validation
411
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
412
+	 * It also adds any text from the free text fields to the value
413
+	 *
414
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
415
+	 *
416
+	 * @since 2.0
417
+	 *
418
+	 * @param string|array $value
419
+	 * @param string|array $other_vals (usually of posted values)
420
+	 * @param object $field
421
+	 * @param array $args
422
+	 */
423
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
424
+		// Checkboxes and multi-select dropdowns
425
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
426
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
427
+			$value = array_merge( $value, $other_vals );
428
+			$value = array_filter( $value );
429
+			if ( count( $value ) == 0 ) {
430
+				$value = '';
431
+			}
432
+		} else {
433 433
 			// Radio and dropdowns
434
-            $other_key = array_filter( array_keys($field->options), 'is_string');
435
-            $other_key = reset( $other_key );
434
+			$other_key = array_filter( array_keys($field->options), 'is_string');
435
+			$other_key = reset( $other_key );
436 436
 
437
-            // Multi-select dropdown
438
-            if ( is_array( $value ) ) {
439
-                $o_key = array_search( $field->options[ $other_key ], $value );
437
+			// Multi-select dropdown
438
+			if ( is_array( $value ) ) {
439
+				$o_key = array_search( $field->options[ $other_key ], $value );
440 440
 
441 441
 				if ( $o_key !== false ) {
442 442
 					// Modify the original value so other key will be preserved
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 					$args['temp_value'] = $value;
452 452
 					$value[ $other_key ] = reset( $other_vals );
453 453
 				}
454
-            } else if ( $field->options[ $other_key ] == $value ) {
455
-                $value = $other_vals;
456
-            }
457
-        }
458
-    }
454
+			} else if ( $field->options[ $other_key ] == $value ) {
455
+				$value = $other_vals;
456
+			}
457
+		}
458
+	}
459 459
 
460 460
 	public static function enqueue_scripts( $params ) {
461 461
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
462 462
 		FrmFormsController::enqueue_scripts( $params );
463 463
 	}
464 464
 
465
-    // Add submitted values to a string for spam checking
465
+	// Add submitted values to a string for spam checking
466 466
 	public static function entry_array_to_string( $values ) {
467
-        $content = '';
467
+		$content = '';
468 468
 		foreach ( $values['item_meta'] as $val ) {
469 469
 			if ( $content != '' ) {
470 470
 				$content .= "\n\n";
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 
473 473
 			if ( is_array($val) ) {
474 474
 				$val = FrmAppHelper::array_flatten( $val );
475
-			    $val = implode(',', $val);
475
+				$val = implode(',', $val);
476 476
 			}
477 477
 
478 478
 			$content .= $val;
479 479
 		}
480 480
 
481 481
 		return $content;
482
-    }
482
+	}
483 483
 
484 484
 	public static function fill_entry_values( $atts, $f, array &$values ) {
485 485
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
     public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
         $values = array();
10 10
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
11
-			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
11
+			$values[$var] = FrmAppHelper::get_post_param( $var, $default, 'wp_kses_post' );
12 12
         }
13 13
 
14 14
         $values['fields'] = array();
15
-        if ( empty($fields) ) {
16
-            return apply_filters('frm_setup_new_entry', $values);
15
+        if ( empty( $fields ) ) {
16
+            return apply_filters( 'frm_setup_new_entry', $values );
17 17
         }
18 18
 
19 19
         foreach ( (array) $fields as $field ) {
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                 'default_value' => $field->default_value,
26 26
                 'name' => $field->name,
27 27
                 'description' => $field->description,
28
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
28
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
29 29
                 'options' => $field->options,
30 30
                 'required' => $field->required,
31 31
                 'field_key' => $field->field_key,
@@ -36,43 +36,43 @@  discard block
 block discarded – undo
36 36
 				'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0',
37 37
             );
38 38
 
39
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
40 40
             $opt_defaults['required_indicator'] = '';
41 41
 			$opt_defaults['original_type'] = $field->type;
42 42
 
43 43
 			foreach ( $opt_defaults as $opt => $default_opt ) {
44
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
45
-                unset($opt, $default_opt);
44
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
45
+                unset( $opt, $default_opt );
46 46
             }
47 47
 
48
-            unset($opt_defaults);
48
+            unset( $opt_defaults );
49 49
 
50 50
             if ( $field_array['custom_html'] == '' ) {
51
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
52 52
             }
53 53
 
54
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args );
54
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
55 55
             $field_array = array_merge( $field->field_options, $field_array );
56 56
 
57 57
             $values['fields'][] = $field_array;
58 58
 
59
-            if ( ! $form || ! isset($form->id) ) {
60
-                $form = FrmForm::getOne($field->form_id);
59
+            if ( ! $form || ! isset( $form->id ) ) {
60
+                $form = FrmForm::getOne( $field->form_id );
61 61
             }
62 62
         }
63 63
 
64
-        $form->options = maybe_unserialize($form->options);
65
-        if ( is_array($form->options) ) {
64
+        $form->options = maybe_unserialize( $form->options );
65
+        if ( is_array( $form->options ) ) {
66 66
             foreach ( $form->options as $opt => $value ) {
67
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
68
-                unset($opt, $value);
67
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
68
+                unset( $opt, $value );
69 69
             }
70 70
         }
71 71
 
72 72
 		$form_defaults = FrmFormsHelper::get_default_opts();
73 73
 
74 74
 		$frm_settings = FrmAppHelper::get_settings();
75
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
75
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
76 76
 
77 77
 		$values = array_merge( $form_defaults, $values );
78 78
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$return_array = FrmField::is_field_with_multiple_values( $field );
96 96
 
97 97
 		// Do any shortcodes in default value and allow customization of default value
98
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
98
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
99 99
 		// Calls FrmProFieldsHelper::get_default_value
100 100
 
101 101
 		$new_value = $field->default_value;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		if ( ! is_array( $new_value ) ) {
111
-			$new_value = str_replace('"', '&quot;', $new_value);
111
+			$new_value = str_replace( '"', '&quot;', $new_value );
112 112
 		}
113 113
 
114 114
 		return $new_value;
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		if ( $_POST ) {
128 128
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
129 129
 			if ( $repeating ) {
130
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
130
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
131 131
 					$value_is_posted = true;
132 132
 				}
133
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
133
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
134 134
 				$value_is_posted = true;
135 135
 			}
136 136
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
142 142
         $values['form_id'] = $record->form_id;
143 143
         $values['is_draft'] = $record->is_draft;
144
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
144
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
145 145
     }
146 146
 
147 147
     public static function get_admin_params( $form = null ) {
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
     }
171 171
 
172 172
 	public static function replace_default_message( $message, $atts ) {
173
-        if ( strpos($message, '[default-message') === false &&
174
-            strpos($message, '[default_message') === false &&
173
+        if ( strpos( $message, '[default-message' ) === false &&
174
+            strpos( $message, '[default_message' ) === false &&
175 175
             ! empty( $message ) ) {
176 176
             return $message;
177 177
         }
178 178
 
179
-        if ( empty($message) ) {
179
+        if ( empty( $message ) ) {
180 180
             $message = '[default-message]';
181 181
         }
182 182
 
183
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
183
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
184 184
 
185 185
         foreach ( $shortcodes[0] as $short_key => $tag ) {
186
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
186
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
187 187
             if ( $add_atts ) {
188
-                $this_atts = array_merge($atts, $add_atts);
188
+                $this_atts = array_merge( $atts, $add_atts );
189 189
             } else {
190 190
                 $this_atts = $atts;
191 191
             }
@@ -193,32 +193,32 @@  discard block
 block discarded – undo
193 193
 			$default = FrmEntryFormat::show_entry( $this_atts );
194 194
 
195 195
             // Add the default message
196
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
196
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
197 197
         }
198 198
 
199 199
         return $message;
200 200
     }
201 201
 
202 202
 	public static function prepare_display_value( $entry, $field, $atts ) {
203
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
203
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
204 204
 
205 205
         if ( FrmAppHelper::pro_is_installed() ) {
206 206
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
207 207
         }
208 208
 
209
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
210
-            return self::display_value($field_value, $field, $atts);
209
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210
+            return self::display_value( $field_value, $field, $atts );
211 211
         }
212 212
 
213 213
         // this is an embeded form
214 214
         $val = '';
215 215
 
216
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
216
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
217 217
             //this is a repeating section
218 218
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
219 219
         } else {
220 220
             // get all values for this field
221
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
221
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
222 222
 
223 223
             if ( $child_values ) {
224 224
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 	    $field_value = array();
229 229
 
230
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
230
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
231 231
             return $val;
232 232
         }
233 233
 
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
             $atts['post_id'] = $child_entry->post_id;
237 237
 
238 238
             // get the value for this field -- check for post values as well
239
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
239
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
240 240
 
241 241
             if ( $entry_val ) {
242 242
                 // foreach entry get display_value
243
-                $field_value[] = self::display_value($entry_val, $field, $atts);
243
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
244 244
             }
245 245
 
246
-            unset($child_entry);
246
+            unset( $child_entry );
247 247
         }
248 248
 
249
-        $val = implode(', ', (array) $field_value );
249
+        $val = implode( ', ', (array) $field_value );
250 250
 		$val = wp_kses_post( $val );
251 251
 
252 252
         return $val;
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
         );
267 267
 
268 268
         $atts = wp_parse_args( $atts, $defaults );
269
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
269
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
270 270
 
271
-        if ( ! isset($field->field_options['post_field']) ) {
271
+        if ( ! isset( $field->field_options['post_field'] ) ) {
272 272
             $field->field_options['post_field'] = '';
273 273
         }
274 274
 
275
-        if ( ! isset($field->field_options['custom_field']) ) {
275
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
276 276
             $field->field_options['custom_field'] = '';
277 277
         }
278 278
 
279 279
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
280 280
             $atts['pre_truncate'] = $atts['truncate'];
281 281
             $atts['truncate'] = true;
282
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
282
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
283 283
 
284
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
284
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
285 285
             $atts['truncate'] = $atts['pre_truncate'];
286 286
         }
287 287
 
@@ -289,39 +289,39 @@  discard block
 block discarded – undo
289 289
             return $value;
290 290
         }
291 291
 
292
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
292
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
293 293
 		$value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
294 294
 
295 295
         $new_value = '';
296 296
 
297
-        if ( is_array($value) && $atts['type'] != 'file' ) {
297
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
298 298
             foreach ( $value as $val ) {
299
-                if ( is_array($val) ) {
299
+                if ( is_array( $val ) ) {
300 300
 					//TODO: add options for display (li or ,)
301
-                    $new_value .= implode($atts['sep'], $val);
301
+                    $new_value .= implode( $atts['sep'], $val );
302 302
                     if ( $atts['type'] != 'data' ) {
303 303
                         $new_value .= '<br/>';
304 304
                     }
305 305
                 }
306
-                unset($val);
306
+                unset( $val );
307 307
             }
308 308
         }
309 309
 
310
-        if ( ! empty($new_value) ) {
310
+        if ( ! empty( $new_value ) ) {
311 311
             $value = $new_value;
312
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
-            $value = implode($atts['sep'], $value);
312
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
313
+            $value = implode( $atts['sep'], $value );
314 314
         }
315 315
 
316 316
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
317
-            $value = FrmAppHelper::truncate($value, 50);
317
+            $value = FrmAppHelper::truncate( $value, 50 );
318 318
         }
319 319
 
320 320
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
321 321
 			$value = wp_kses_post( $value );
322 322
 		}
323 323
 
324
-        return apply_filters('frm_display_value', $value, $field, $atts);
324
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
325 325
     }
326 326
 
327 327
 	public static function set_posted_value( $field, $value, $args ) {
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
         if ( isset( $args['other'] ) && $args['other'] ) {
330 330
             $value = $args['temp_value'];
331 331
         }
332
-        if ( empty($args['parent_field_id']) ) {
333
-            $_POST['item_meta'][ $field->id ] = $value;
332
+        if ( empty( $args['parent_field_id'] ) ) {
333
+            $_POST['item_meta'][$field->id] = $value;
334 334
         } else {
335
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
335
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
336 336
         }
337 337
     }
338 338
 
339 339
 	public static function get_posted_value( $field, &$value, $args ) {
340 340
 		$field_id = is_object( $field ) ? $field->id : $field;
341 341
 
342
-        if ( empty($args['parent_field_id']) ) {
343
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
342
+        if ( empty( $args['parent_field_id'] ) ) {
343
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
344 344
         } else {
345
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
345
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
346 346
         }
347 347
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
348 348
 		$value = stripslashes_deep( $value );
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
         self::set_other_repeating_vals( $field, $value, $args );
368 368
 
369 369
         // Check if there are any posted "Other" values
370
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
370
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
371 371
 
372 372
             // Save original value
373 373
             $args['temp_value'] = $value;
374 374
             $args['other'] = true;
375
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
375
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
376 376
 
377 377
             // Set the validation value now
378 378
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
         }
395 395
 
396 396
         // Check if there are any other posted "other" values for this field
397
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
397
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
398 398
             // Save original value
399 399
             $args['temp_value'] = $value;
400 400
             $args['other'] = true;
401 401
 
402
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
402
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
403 403
 
404 404
             // Set the validation value now
405 405
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -431,27 +431,27 @@  discard block
 block discarded – undo
431 431
             }
432 432
         } else {
433 433
 			// Radio and dropdowns
434
-            $other_key = array_filter( array_keys($field->options), 'is_string');
434
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
435 435
             $other_key = reset( $other_key );
436 436
 
437 437
             // Multi-select dropdown
438 438
             if ( is_array( $value ) ) {
439
-                $o_key = array_search( $field->options[ $other_key ], $value );
439
+                $o_key = array_search( $field->options[$other_key], $value );
440 440
 
441 441
 				if ( $o_key !== false ) {
442 442
 					// Modify the original value so other key will be preserved
443
-					$value[ $other_key ] = $value[ $o_key ];
443
+					$value[$other_key] = $value[$o_key];
444 444
 
445 445
 					// By default, the array keys will be numeric for multi-select dropdowns
446 446
 					// If going backwards and forwards between pages, the array key will match the other key
447 447
 					if ( $o_key != $other_key ) {
448
-						unset( $value[ $o_key ] );
448
+						unset( $value[$o_key] );
449 449
 					}
450 450
 
451 451
 					$args['temp_value'] = $value;
452
-					$value[ $other_key ] = reset( $other_vals );
452
+					$value[$other_key] = reset( $other_vals );
453 453
 				}
454
-            } else if ( $field->options[ $other_key ] == $value ) {
454
+            } else if ( $field->options[$other_key] == $value ) {
455 455
                 $value = $other_vals;
456 456
             }
457 457
         }
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 				$content .= "\n\n";
471 471
 			}
472 472
 
473
-			if ( is_array($val) ) {
473
+			if ( is_array( $val ) ) {
474 474
 				$val = FrmAppHelper::array_flatten( $val );
475
-			    $val = implode(',', $val);
475
+			    $val = implode( ',', $val );
476 476
 			}
477 477
 
478 478
 			$content .= $val;
Please login to merge, or discard this patch.