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