Completed
Pull Request — master (#36)
by Stephanie
03:00
created
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -2,70 +2,70 @@  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( 'https://formidableforms.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( 'https://formidableforms.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;
68
+		global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84 84
 		$columns[ $form_id . '_ip' ] = 'IP';
85 85
 
86
-        $frm_vars['cols'] = $columns;
86
+		$frm_vars['cols'] = $columns;
87 87
 
88 88
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
89 89
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
90 90
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
91
-        }
91
+		}
92 92
 
93
-        return $columns;
94
-    }
93
+		return $columns;
94
+	}
95 95
 
96 96
 	private static function get_columns_for_form( $form_id, &$columns ) {
97 97
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
125 125
 					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
126 126
 				} else {
127
-          $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
128
-        }
127
+		  $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
128
+		}
129 129
 			}
130 130
 		}
131 131
 	}
@@ -134,76 +134,76 @@  discard block
 block discarded – undo
134 134
 		$menu_name = FrmAppHelper::get_menu_name();
135 135
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
136 136
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
137
-            return $check;
138
-        }
137
+			return $check;
138
+		}
139 139
 
140 140
 		if ( empty( $prev_value ) ) {
141 141
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
142 142
 		}
143 143
 
144
-        global $frm_vars;
145
-        //add a check so we don't create a loop
146
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
144
+		global $frm_vars;
145
+		//add a check so we don't create a loop
146
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147 147
 
148
-        return $check;
149
-    }
148
+		return $check;
149
+	}
150 150
 
151
-    //add hidden columns back from other forms
151
+	//add hidden columns back from other forms
152 152
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
153 153
 		$menu_name = FrmAppHelper::get_menu_name();
154 154
 		$sanitized = sanitize_title( $menu_name );
155 155
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
156 156
 		if ( $meta_key != $this_page_name ) {
157
-            return;
158
-        }
159
-
160
-        global $frm_vars;
161
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
-            return; //don't continue if there's no previous value
163
-        }
164
-
165
-        foreach ( $meta_value as $mk => $mv ) {
166
-            //remove blank values
167
-            if ( empty( $mv ) ) {
168
-                unset( $meta_value[ $mk ] );
169
-            }
170
-        }
171
-
172
-        $cur_form_prefix = reset($meta_value);
173
-        $cur_form_prefix = explode('_', $cur_form_prefix);
174
-        $cur_form_prefix = $cur_form_prefix[0];
175
-        $save = false;
176
-
177
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
157
+			return;
158
+		}
159
+
160
+		global $frm_vars;
161
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
+			return; //don't continue if there's no previous value
163
+		}
164
+
165
+		foreach ( $meta_value as $mk => $mv ) {
166
+			//remove blank values
167
+			if ( empty( $mv ) ) {
168
+				unset( $meta_value[ $mk ] );
169
+			}
170
+		}
171
+
172
+		$cur_form_prefix = reset($meta_value);
173
+		$cur_form_prefix = explode('_', $cur_form_prefix);
174
+		$cur_form_prefix = $cur_form_prefix[0];
175
+		$save = false;
176
+
177
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
178 178
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
179
-                //don't add blank cols or process included cols
180
-                continue;
181
-            }
179
+				//don't add blank cols or process included cols
180
+				continue;
181
+			}
182 182
 
183 183
 			$form_prefix = explode( '_', $prev_hidden );
184
-            $form_prefix = $form_prefix[0];
185
-            if ( $form_prefix == $cur_form_prefix ) {
186
-                //don't add back columns that are meant to be hidden
187
-                continue;
188
-            }
184
+			$form_prefix = $form_prefix[0];
185
+			if ( $form_prefix == $cur_form_prefix ) {
186
+				//don't add back columns that are meant to be hidden
187
+				continue;
188
+			}
189 189
 
190
-            $meta_value[] = $prev_hidden;
191
-            $save = true;
192
-            unset($form_prefix);
193
-        }
190
+			$meta_value[] = $prev_hidden;
191
+			$save = true;
192
+			unset($form_prefix);
193
+		}
194 194
 
195 195
 		if ( $save ) {
196
-            $user = wp_get_current_user();
196
+			$user = wp_get_current_user();
197 197
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
198
-        }
199
-    }
198
+		}
199
+	}
200 200
 
201 201
 	public static function save_per_page( $save, $option, $value ) {
202
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
203
-            $save = (int) $value;
204
-        }
205
-        return $save;
206
-    }
202
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
203
+			$save = (int) $value;
204
+		}
205
+		return $save;
206
+	}
207 207
 
208 208
 	public static function sortable_columns() {
209 209
 		$form_id = FrmForm::get_current_form_id();
@@ -229,46 +229,46 @@  discard block
 block discarded – undo
229 229
 	}
230 230
 
231 231
 	public static function hidden_columns( $result ) {
232
-        global $frm_vars;
232
+		global $frm_vars;
233 233
 
234 234
 		$form_id = FrmForm::get_current_form_id();
235 235
 
236
-        $return = false;
237
-        foreach ( (array) $result as $r ) {
238
-            if ( ! empty( $r ) ) {
239
-                $form_prefix = explode( '_', $r );
240
-                $form_prefix = $form_prefix[0];
236
+		$return = false;
237
+		foreach ( (array) $result as $r ) {
238
+			if ( ! empty( $r ) ) {
239
+				$form_prefix = explode( '_', $r );
240
+				$form_prefix = $form_prefix[0];
241 241
 
242
-                if ( (int) $form_prefix == (int) $form_id ) {
243
-                    $return = true;
244
-                    break;
245
-                }
242
+				if ( (int) $form_prefix == (int) $form_id ) {
243
+					$return = true;
244
+					break;
245
+				}
246 246
 
247
-                unset($form_prefix);
248
-            }
249
-        }
247
+				unset($form_prefix);
248
+			}
249
+		}
250 250
 
251
-        if ( $return ) {
251
+		if ( $return ) {
252 252
 			return $result;
253 253
 		}
254 254
 
255
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
-        $max_columns = 8;
257
-        if ( $i <= $max_columns ) {
255
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
+		$max_columns = 8;
257
+		if ( $i <= $max_columns ) {
258 258
 			return $result;
259 259
 		}
260 260
 
261
-        global $frm_vars;
262
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
263
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
264
-        }
261
+		global $frm_vars;
262
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
263
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
264
+		}
265 265
 
266 266
 		$has_custom_hidden_columns = ( 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'] ) );
267 267
 		if ( $has_custom_hidden_columns ) {
268
-            $result = $frm_vars['current_form']->options['hidden_cols'];
269
-        } else {
270
-            $cols = $frm_vars['cols'];
271
-            $cols = array_reverse($cols, true);
268
+			$result = $frm_vars['current_form']->options['hidden_cols'];
269
+		} else {
270
+			$cols = $frm_vars['cols'];
271
+			$cols = array_reverse($cols, true);
272 272
 
273 273
 			if ( $form_id ) {
274 274
 				$result[] = $form_id . '_id';
@@ -276,59 +276,59 @@  discard block
 block discarded – undo
276 276
 			}
277 277
 
278 278
 			$result[] = $form_id . '_item_key';
279
-            $i--;
279
+			$i--;
280 280
 
281 281
 			foreach ( $cols as $col_key => $col ) {
282
-                if ( $i > $max_columns ) {
282
+				if ( $i > $max_columns ) {
283 283
 					$result[] = $col_key;
284 284
 				}
285
-                //remove some columns by default
286
-                $i--;
287
-                unset($col_key, $col);
288
-            }
289
-        }
285
+				//remove some columns by default
286
+				$i--;
287
+				unset($col_key, $col);
288
+			}
289
+		}
290 290
 
291
-        return $result;
292
-    }
291
+		return $result;
292
+	}
293 293
 
294 294
 	public static function display_list( $message = '', $errors = array() ) {
295
-        global $wpdb, $frm_vars;
295
+		global $wpdb, $frm_vars;
296 296
 
297 297
 		$form = FrmForm::maybe_get_current_form();
298 298
 		$params = FrmForm::get_admin_params( $form );
299 299
 
300
-        if ( $form ) {
301
-            $params['form'] = $form->id;
302
-            $frm_vars['current_form'] = $form;
300
+		if ( $form ) {
301
+			$params['form'] = $form->id;
302
+			$frm_vars['current_form'] = $form;
303 303
 
304 304
 			self::get_delete_form_time( $form, $errors );
305 305
 		}
306 306
 
307
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
307
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
308 308
 
309
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
309
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
310 310
 
311
-        $pagenum = $wp_list_table->get_pagenum();
311
+		$pagenum = $wp_list_table->get_pagenum();
312 312
 
313
-        $wp_list_table->prepare_items();
313
+		$wp_list_table->prepare_items();
314 314
 
315
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
316
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
315
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
316
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
317 317
 			$url = add_query_arg( 'paged', $total_pages );
318
-            if ( headers_sent() ) {
319
-                echo FrmAppHelper::js_redirect($url);
320
-            } else {
321
-                wp_redirect( esc_url_raw( $url ) );
322
-            }
323
-            die();
324
-        }
325
-
326
-        if ( empty($message) && isset($_GET['import-message']) ) {
327
-            $message = __( 'Your import is complete', 'formidable' );
328
-        }
318
+			if ( headers_sent() ) {
319
+				echo FrmAppHelper::js_redirect($url);
320
+			} else {
321
+				wp_redirect( esc_url_raw( $url ) );
322
+			}
323
+			die();
324
+		}
325
+
326
+		if ( empty($message) && isset($_GET['import-message']) ) {
327
+			$message = __( 'Your import is complete', 'formidable' );
328
+		}
329 329
 
330 330
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
331
-    }
331
+	}
332 332
 
333 333
 	private static function get_delete_form_time( $form, &$errors ) {
334 334
 		if ( 'trash' == $form->status ) {
@@ -338,19 +338,19 @@  discard block
 block discarded – undo
338 338
 		}
339 339
 	}
340 340
 
341
-    /* Back End CRUD */
341
+	/* Back End CRUD */
342 342
 	public static function show( $id = 0 ) {
343
-        FrmAppHelper::permission_check('frm_view_entries');
343
+		FrmAppHelper::permission_check('frm_view_entries');
344 344
 
345
-        if ( ! $id ) {
345
+		if ( ! $id ) {
346 346
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
347 347
 
348
-            if ( ! $id ) {
348
+			if ( ! $id ) {
349 349
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
350
-            }
351
-        }
350
+			}
351
+		}
352 352
 
353
-        $entry = FrmEntry::getOne($id, true);
353
+		$entry = FrmEntry::getOne($id, true);
354 354
 		if ( ! $entry ) {
355 355
 			echo '<div id="form_show_entry_page" class="wrap">' .
356 356
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -358,110 +358,110 @@  discard block
 block discarded – undo
358 358
 			return;
359 359
 		}
360 360
 
361
-        $data = maybe_unserialize($entry->description);
361
+		$data = maybe_unserialize($entry->description);
362 362
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
363 363
 			$data = array( 'referrer' => $data );
364 364
 		}
365 365
 
366 366
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
367
-        $to_emails = array();
367
+		$to_emails = array();
368 368
 
369 369
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
370
-    }
370
+	}
371 371
 
372
-    public static function destroy() {
373
-        FrmAppHelper::permission_check('frm_delete_entries');
372
+	public static function destroy() {
373
+		FrmAppHelper::permission_check('frm_delete_entries');
374 374
 
375 375
 		$params = FrmForm::get_admin_params();
376 376
 
377
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
-            //unlink entry from post
379
-            global $wpdb;
377
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
+			//unlink entry from post
379
+			global $wpdb;
380 380
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
381
-        }
381
+		}
382 382
 
383
-        $message = '';
384
-        if ( FrmEntry::destroy( $params['id'] ) ) {
385
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
386
-        }
383
+		$message = '';
384
+		if ( FrmEntry::destroy( $params['id'] ) ) {
385
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
386
+		}
387 387
 
388
-        self::display_list( $message );
389
-    }
388
+		self::display_list( $message );
389
+	}
390 390
 
391
-    public static function destroy_all() {
392
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
393
-            $frm_settings = FrmAppHelper::get_settings();
394
-            wp_die( $frm_settings->admin_permission );
395
-        }
391
+	public static function destroy_all() {
392
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
393
+			$frm_settings = FrmAppHelper::get_settings();
394
+			wp_die( $frm_settings->admin_permission );
395
+		}
396 396
 
397
-        global $wpdb;
397
+		global $wpdb;
398 398
 		$params = FrmForm::get_admin_params();
399
-        $message = '';
400
-        $errors = array();
401
-        $form_id = (int) $params['form'];
399
+		$message = '';
400
+		$errors = array();
401
+		$form_id = (int) $params['form'];
402 402
 
403
-        if ( $form_id ) {
404
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
403
+		if ( $form_id ) {
404
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
405 405
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
406 406
 
407
-            if ( $action ) {
408
-                // this action takes a while, so only trigger it if there are posts to delete
409
-                foreach ( $entry_ids as $entry_id ) {
410
-                    do_action( 'frm_before_destroy_entry', $entry_id );
411
-                    unset( $entry_id );
412
-                }
413
-            }
414
-
415
-            $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 ) );
416
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
417
-            if ( $results ) {
407
+			if ( $action ) {
408
+				// this action takes a while, so only trigger it if there are posts to delete
409
+				foreach ( $entry_ids as $entry_id ) {
410
+					do_action( 'frm_before_destroy_entry', $entry_id );
411
+					unset( $entry_id );
412
+				}
413
+			}
414
+
415
+			$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 ) );
416
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
417
+			if ( $results ) {
418 418
 				FrmEntry::clear_cache();
419
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
420
-            }
421
-        } else {
422
-            $errors = __( 'No entries were specified', 'formidable' );
423
-        }
424
-
425
-        self::display_list( $message, $errors );
426
-    }
427
-
428
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
429
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
430
-        return FrmFormsController::show_form( $id, $key, $title, $description );
431
-    }
432
-
433
-    public static function get_form( $filename, $form, $title, $description ) {
434
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
435
-        return FrmFormsController::get_form( $form, $title, $description );
436
-    }
437
-
438
-    public static function process_entry( $errors = '', $ajax = false ) {
419
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
420
+			}
421
+		} else {
422
+			$errors = __( 'No entries were specified', 'formidable' );
423
+		}
424
+
425
+		self::display_list( $message, $errors );
426
+	}
427
+
428
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
429
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
430
+		return FrmFormsController::show_form( $id, $key, $title, $description );
431
+	}
432
+
433
+	public static function get_form( $filename, $form, $title, $description ) {
434
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
435
+		return FrmFormsController::get_form( $form, $title, $description );
436
+	}
437
+
438
+	public static function process_entry( $errors = '', $ajax = false ) {
439 439
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
440 440
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
441
-            return;
442
-        }
441
+			return;
442
+		}
443 443
 
444
-        global $frm_vars;
444
+		global $frm_vars;
445 445
 
446 446
 		$form = FrmForm::getOne( $form_id );
447
-        if ( ! $form ) {
448
-            return;
449
-        }
447
+		if ( ! $form ) {
448
+			return;
449
+		}
450 450
 
451 451
 		$params = FrmForm::get_params( $form );
452 452
 
453
-        if ( ! isset( $frm_vars['form_params'] ) ) {
454
-            $frm_vars['form_params'] = array();
455
-        }
453
+		if ( ! isset( $frm_vars['form_params'] ) ) {
454
+			$frm_vars['form_params'] = array();
455
+		}
456 456
 		$frm_vars['form_params'][ $form->id ] = $params;
457 457
 
458 458
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
459
-            return;
460
-        }
459
+			return;
460
+		}
461 461
 
462
-        if ( $errors == '' && ! $ajax ) {
462
+		if ( $errors == '' && ! $ajax ) {
463 463
 			$errors = FrmEntryValidate::validate( $_POST );
464
-        }
464
+		}
465 465
 
466 466
 		/**
467 467
 		 * Use this filter to add trigger actions and add errors after
@@ -472,54 +472,54 @@  discard block
 block discarded – undo
472 472
 
473 473
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
474 474
 
475
-        if ( empty( $errors ) ) {
475
+		if ( empty( $errors ) ) {
476 476
 			$_POST['frm_skip_cookie'] = 1;
477
-            if ( $params['action'] == 'create' ) {
477
+			if ( $params['action'] == 'create' ) {
478 478
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
479 479
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
480
-                }
481
-            }
480
+				}
481
+			}
482 482
 
483
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
483
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
484 484
 			unset( $_POST['frm_skip_cookie'] );
485
-        }
486
-    }
487
-
488
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
489
-        self::_delete_entry( $atts['id'], $form );
490
-        return $url;
491
-    }
492
-
493
-    //Delete entry if not redirected
494
-    public static function delete_entry_after_save( $atts ) {
495
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
496
-    }
497
-
498
-    private static function _delete_entry( $entry_id, $form ) {
499
-        if ( ! $form ) {
500
-            return;
501
-        }
502
-
503
-        $form->options = maybe_unserialize( $form->options );
504
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
505
-            FrmEntry::destroy( $entry_id );
506
-        }
507
-    }
485
+		}
486
+	}
487
+
488
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
489
+		self::_delete_entry( $atts['id'], $form );
490
+		return $url;
491
+	}
492
+
493
+	//Delete entry if not redirected
494
+	public static function delete_entry_after_save( $atts ) {
495
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
496
+	}
497
+
498
+	private static function _delete_entry( $entry_id, $form ) {
499
+		if ( ! $form ) {
500
+			return;
501
+		}
502
+
503
+		$form->options = maybe_unserialize( $form->options );
504
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
505
+			FrmEntry::destroy( $entry_id );
506
+		}
507
+	}
508 508
 
509 509
 	public static function show_entry_shortcode( $atts ) {
510 510
 		return FrmEntryFormat::show_entry( $atts );
511 511
 	}
512 512
 
513 513
 	public static function filter_shortcode_value( $value, $tag, $atts, $field ) {
514
-        $plain_text = add_filter('frm_plain_text_email', true);
514
+		$plain_text = add_filter('frm_plain_text_email', true);
515 515
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
516 516
 
517
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
518
-            return $value;
519
-        }
517
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
518
+			return $value;
519
+		}
520 520
 
521
-        return $value;
522
-    }
521
+		return $value;
522
+	}
523 523
 
524 524
 	public static function get_params( $form = null ) {
525 525
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -527,15 +527,15 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	public static function entry_sidebar( $entry ) {
530
-        $data = maybe_unserialize($entry->description);
531
-        $date_format = get_option('date_format');
532
-        $time_format = get_option('time_format');
530
+		$data = maybe_unserialize($entry->description);
531
+		$date_format = get_option('date_format');
532
+		$time_format = get_option('time_format');
533 533
 		if ( isset( $data['browser'] ) ) {
534 534
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
535 535
 		}
536 536
 
537 537
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
538
-    }
538
+	}
539 539
 
540 540
 	/***********************************************************************
541 541
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 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,20 +68,20 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
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
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84
-		$columns[ $form_id . '_ip' ] = 'IP';
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84
+		$columns[$form_id . '_ip'] = 'IP';
85 85
 
86 86
         $frm_vars['cols'] = $columns;
87 87
 
@@ -107,24 +107,24 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
121 121
 					$col_id .= '-_-form' . $form_col->form_id;
122 122
 				}
123 123
 
124
-				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
125
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
124
+				if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) {
125
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
126 126
 				} else {
127
-          $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+          $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
         }
129 129
 			}
130 130
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
         global $frm_vars;
145 145
         //add a check so we don't create a loop
146
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
146
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147 147
 
148 148
         return $check;
149 149
     }
@@ -158,19 +158,19 @@  discard block
 block discarded – undo
158 158
         }
159 159
 
160 160
         global $frm_vars;
161
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
161
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
162 162
             return; //don't continue if there's no previous value
163 163
         }
164 164
 
165 165
         foreach ( $meta_value as $mk => $mv ) {
166 166
             //remove blank values
167 167
             if ( empty( $mv ) ) {
168
-                unset( $meta_value[ $mk ] );
168
+                unset( $meta_value[$mk] );
169 169
             }
170 170
         }
171 171
 
172
-        $cur_form_prefix = reset($meta_value);
173
-        $cur_form_prefix = explode('_', $cur_form_prefix);
172
+        $cur_form_prefix = reset( $meta_value );
173
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
174 174
         $cur_form_prefix = $cur_form_prefix[0];
175 175
         $save = false;
176 176
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
             $meta_value[] = $prev_hidden;
191 191
             $save = true;
192
-            unset($form_prefix);
192
+            unset( $form_prefix );
193 193
         }
194 194
 
195 195
 		if ( $save ) {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		foreach ( $fields as $field ) {
222 222
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
223 223
 				// Can't sort on checkboxes because they are stored serialized, or post fields
224
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
224
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
225 225
 			}
226 226
 		}
227 227
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     break;
245 245
                 }
246 246
 
247
-                unset($form_prefix);
247
+                unset( $form_prefix );
248 248
             }
249 249
         }
250 250
 
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
 			return $result;
253 253
 		}
254 254
 
255
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
255
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
256 256
         $max_columns = 8;
257 257
         if ( $i <= $max_columns ) {
258 258
 			return $result;
259 259
 		}
260 260
 
261 261
         global $frm_vars;
262
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
263
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
262
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
263
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
264 264
         }
265 265
 
266 266
 		$has_custom_hidden_columns = ( 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'] ) );
@@ -268,23 +268,23 @@  discard block
 block discarded – undo
268 268
             $result = $frm_vars['current_form']->options['hidden_cols'];
269 269
         } else {
270 270
             $cols = $frm_vars['cols'];
271
-            $cols = array_reverse($cols, true);
271
+            $cols = array_reverse( $cols, true );
272 272
 
273 273
 			if ( $form_id ) {
274 274
 				$result[] = $form_id . '_id';
275
-				$i--;
275
+				$i --;
276 276
 			}
277 277
 
278 278
 			$result[] = $form_id . '_item_key';
279
-            $i--;
279
+            $i --;
280 280
 
281 281
 			foreach ( $cols as $col_key => $col ) {
282 282
                 if ( $i > $max_columns ) {
283 283
 					$result[] = $col_key;
284 284
 				}
285 285
                 //remove some columns by default
286
-                $i--;
287
-                unset($col_key, $col);
286
+                $i --;
287
+                unset( $col_key, $col );
288 288
             }
289 289
         }
290 290
 
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
317 317
 			$url = add_query_arg( 'paged', $total_pages );
318 318
             if ( headers_sent() ) {
319
-                echo FrmAppHelper::js_redirect($url);
319
+                echo FrmAppHelper::js_redirect( $url );
320 320
             } else {
321 321
                 wp_redirect( esc_url_raw( $url ) );
322 322
             }
323 323
             die();
324 324
         }
325 325
 
326
-        if ( empty($message) && isset($_GET['import-message']) ) {
326
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
327 327
             $message = __( 'Your import is complete', 'formidable' );
328 328
         }
329 329
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
     /* Back End CRUD */
342 342
 	public static function show( $id = 0 ) {
343
-        FrmAppHelper::permission_check('frm_view_entries');
343
+        FrmAppHelper::permission_check( 'frm_view_entries' );
344 344
 
345 345
         if ( ! $id ) {
346 346
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             }
351 351
         }
352 352
 
353
-        $entry = FrmEntry::getOne($id, true);
353
+        $entry = FrmEntry::getOne( $id, true );
354 354
 		if ( ! $entry ) {
355 355
 			echo '<div id="form_show_entry_page" class="wrap">' .
356 356
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			return;
359 359
 		}
360 360
 
361
-        $data = maybe_unserialize($entry->description);
361
+        $data = maybe_unserialize( $entry->description );
362 362
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
363 363
 			$data = array( 'referrer' => $data );
364 364
 		}
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
     }
371 371
 
372 372
     public static function destroy() {
373
-        FrmAppHelper::permission_check('frm_delete_entries');
373
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
374 374
 
375 375
 		$params = FrmForm::get_admin_params();
376 376
 
377
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
377
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
378 378
             //unlink entry from post
379 379
             global $wpdb;
380 380
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
         if ( ! isset( $frm_vars['form_params'] ) ) {
454 454
             $frm_vars['form_params'] = array();
455 455
         }
456
-		$frm_vars['form_params'][ $form->id ] = $params;
456
+		$frm_vars['form_params'][$form->id] = $params;
457 457
 
458
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
458
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
459 459
             return;
460 460
         }
461 461
 
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 		 */
471 471
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
472 472
 
473
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
473
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
474 474
 
475 475
         if ( empty( $errors ) ) {
476 476
 			$_POST['frm_skip_cookie'] = 1;
477 477
             if ( $params['action'] == 'create' ) {
478
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
479
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
478
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
479
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
480 480
                 }
481 481
             }
482 482
 
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 	}
512 512
 
513 513
 	public static function filter_shortcode_value( $value, $tag, $atts, $field ) {
514
-        $plain_text = add_filter('frm_plain_text_email', true);
514
+        $plain_text = add_filter( 'frm_plain_text_email', true );
515 515
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
516 516
 
517
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
517
+        if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) {
518 518
             return $value;
519 519
         }
520 520
 
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	public static function entry_sidebar( $entry ) {
530
-        $data = maybe_unserialize($entry->description);
531
-        $date_format = get_option('date_format');
532
-        $time_format = get_option('time_format');
530
+        $data = maybe_unserialize( $entry->description );
531
+        $date_format = get_option( 'date_format' );
532
+        $time_format = get_option( 'time_format' );
533 533
 		if ( isset( $data['browser'] ) ) {
534 534
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
535 535
 		}
Please login to merge, or discard this patch.