Completed
Push — master ( 2b2bc1...a58c0a )
by Stephanie
02:32
created
classes/controllers/FrmEntriesController.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -312,6 +312,7 @@
 block discarded – undo
312 312
 	 * Remove some columns by default when there are too many
313 313
 	 *
314 314
 	 * @since 2.05.07
315
+	 * @param string[] $result
315 316
 	 */
316 317
 	private static function remove_excess_cols( $atts, &$result ) {
317 318
 		global $frm_vars;
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -24,57 +24,57 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 	}
26 26
 
27
-    /* Display in Back End */
28
-    public static function route() {
27
+	/* Display in Back End */
28
+	public static function route() {
29 29
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
30 30
 
31
-        switch ( $action ) {
32
-            case 'show':
33
-            case 'destroy':
34
-            case 'destroy_all':
35
-                return self::$action();
31
+		switch ( $action ) {
32
+			case 'show':
33
+			case 'destroy':
34
+			case 'destroy_all':
35
+				return self::$action();
36 36
 
37
-            default:
38
-                do_action( 'frm_entry_action_route', $action );
39
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
40
-                    return;
41
-                }
37
+			default:
38
+				do_action( 'frm_entry_action_route', $action );
39
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
40
+					return;
41
+				}
42 42
 
43
-                return self::display_list();
44
-        }
45
-    }
43
+				return self::display_list();
44
+		}
45
+	}
46 46
 
47 47
 	public static function contextual_help( $help, $screen_id, $screen ) {
48
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
49
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
50
-            return $help;
51
-        }
48
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
49
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
50
+			return $help;
51
+		}
52 52
 
53 53
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
54 54
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
55 55
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
56
-            return $help;
57
-        }
56
+			return $help;
57
+		}
58 58
 
59 59
 		unset( $action, $page );
60 60
 
61
-        $screen->add_help_tab( array(
62
-            'id'      => 'formidable-entries-tab',
63
-            'title'   => __( 'Overview', 'formidable' ),
61
+		$screen->add_help_tab( array(
62
+			'id'      => 'formidable-entries-tab',
63
+			'title'   => __( 'Overview', 'formidable' ),
64 64
 			'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>',
65
-        ));
65
+		));
66 66
 
67
-        $screen->set_help_sidebar(
67
+		$screen->set_help_sidebar(
68 68
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
69 69
 			'<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>' .
70 70
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
71
-    	);
71
+		);
72 72
 
73
-        return $help;
74
-    }
73
+		return $help;
74
+	}
75 75
 
76 76
 	public static function manage_columns( $columns ) {
77
-        global $frm_vars;
77
+		global $frm_vars;
78 78
 		$form_id = FrmForm::get_current_form_id();
79 79
 
80 80
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
93 93
 		self::maybe_add_ip_col( $form_id, $columns );
94 94
 
95
-        $frm_vars['cols'] = $columns;
95
+		$frm_vars['cols'] = $columns;
96 96
 
97 97
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
98 98
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
99 99
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
100
-        }
100
+		}
101 101
 
102
-        return $columns;
103
-    }
102
+		return $columns;
103
+	}
104 104
 
105 105
 	private static function get_columns_for_form( $form_id, &$columns ) {
106 106
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -149,67 +149,67 @@  discard block
 block discarded – undo
149 149
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
150 150
 		$this_page_name = self::hidden_column_key();
151 151
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
152
-            return $check;
153
-        }
152
+			return $check;
153
+		}
154 154
 
155 155
 		if ( empty( $prev_value ) ) {
156 156
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
157 157
 		}
158 158
 
159
-        global $frm_vars;
160
-        //add a check so we don't create a loop
161
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
159
+		global $frm_vars;
160
+		//add a check so we don't create a loop
161
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
162 162
 
163
-        return $check;
164
-    }
163
+		return $check;
164
+	}
165 165
 
166
-    //add hidden columns back from other forms
166
+	//add hidden columns back from other forms
167 167
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
168 168
 		$this_page_name = self::hidden_column_key();
169 169
 		if ( $meta_key != $this_page_name ) {
170
-            return;
171
-        }
172
-
173
-        global $frm_vars;
174
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
175
-            return; //don't continue if there's no previous value
176
-        }
177
-
178
-        foreach ( $meta_value as $mk => $mv ) {
179
-            //remove blank values
180
-            if ( empty( $mv ) ) {
181
-                unset( $meta_value[ $mk ] );
182
-            }
183
-        }
184
-
185
-        $cur_form_prefix = reset($meta_value);
186
-        $cur_form_prefix = explode('_', $cur_form_prefix);
187
-        $cur_form_prefix = $cur_form_prefix[0];
188
-        $save = false;
189
-
190
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
170
+			return;
171
+		}
172
+
173
+		global $frm_vars;
174
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
175
+			return; //don't continue if there's no previous value
176
+		}
177
+
178
+		foreach ( $meta_value as $mk => $mv ) {
179
+			//remove blank values
180
+			if ( empty( $mv ) ) {
181
+				unset( $meta_value[ $mk ] );
182
+			}
183
+		}
184
+
185
+		$cur_form_prefix = reset($meta_value);
186
+		$cur_form_prefix = explode('_', $cur_form_prefix);
187
+		$cur_form_prefix = $cur_form_prefix[0];
188
+		$save = false;
189
+
190
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
191 191
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
192
-                //don't add blank cols or process included cols
193
-                continue;
194
-            }
192
+				//don't add blank cols or process included cols
193
+				continue;
194
+			}
195 195
 
196 196
 			$form_prefix = explode( '_', $prev_hidden );
197
-            $form_prefix = $form_prefix[0];
198
-            if ( $form_prefix == $cur_form_prefix ) {
199
-                //don't add back columns that are meant to be hidden
200
-                continue;
201
-            }
197
+			$form_prefix = $form_prefix[0];
198
+			if ( $form_prefix == $cur_form_prefix ) {
199
+				//don't add back columns that are meant to be hidden
200
+				continue;
201
+			}
202 202
 
203
-            $meta_value[] = $prev_hidden;
204
-            $save = true;
205
-            unset($form_prefix);
206
-        }
203
+			$meta_value[] = $prev_hidden;
204
+			$save = true;
205
+			unset($form_prefix);
206
+		}
207 207
 
208 208
 		if ( $save ) {
209 209
 			$user_id = get_current_user_id();
210 210
 			update_user_option( $user_id, $this_page_name, $meta_value, true );
211
-        }
212
-    }
211
+		}
212
+	}
213 213
 
214 214
 	/**
215 215
 	 * @since 2.05.07
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	public static function save_per_page( $save, $option, $value ) {
233
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
234
-            $save = (int) $value;
235
-        }
236
-        return $save;
237
-    }
233
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
234
+			$save = (int) $value;
235
+		}
236
+		return $save;
237
+	}
238 238
 
239 239
 	public static function sortable_columns() {
240 240
 		$form_id = FrmForm::get_current_form_id();
@@ -331,43 +331,43 @@  discard block
 block discarded – undo
331 331
 	}
332 332
 
333 333
 	public static function display_list( $message = '', $errors = array() ) {
334
-        global $wpdb, $frm_vars;
334
+		global $wpdb, $frm_vars;
335 335
 
336 336
 		$form = FrmForm::maybe_get_current_form();
337 337
 		$params = FrmForm::get_admin_params( $form );
338 338
 
339
-        if ( $form ) {
340
-            $params['form'] = $form->id;
341
-            $frm_vars['current_form'] = $form;
339
+		if ( $form ) {
340
+			$params['form'] = $form->id;
341
+			$frm_vars['current_form'] = $form;
342 342
 
343 343
 			self::get_delete_form_time( $form, $errors );
344 344
 		}
345 345
 
346
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
346
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
347 347
 
348
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
348
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
349 349
 
350
-        $pagenum = $wp_list_table->get_pagenum();
350
+		$pagenum = $wp_list_table->get_pagenum();
351 351
 
352
-        $wp_list_table->prepare_items();
352
+		$wp_list_table->prepare_items();
353 353
 
354
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
355
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
354
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
355
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
356 356
 			$url = add_query_arg( 'paged', $total_pages );
357
-            if ( headers_sent() ) {
358
-                echo FrmAppHelper::js_redirect($url);
359
-            } else {
360
-                wp_redirect( esc_url_raw( $url ) );
361
-            }
362
-            die();
363
-        }
364
-
365
-        if ( empty($message) && isset($_GET['import-message']) ) {
366
-            $message = __( 'Your import is complete', 'formidable' );
367
-        }
357
+			if ( headers_sent() ) {
358
+				echo FrmAppHelper::js_redirect($url);
359
+			} else {
360
+				wp_redirect( esc_url_raw( $url ) );
361
+			}
362
+			die();
363
+		}
364
+
365
+		if ( empty($message) && isset($_GET['import-message']) ) {
366
+			$message = __( 'Your import is complete', 'formidable' );
367
+		}
368 368
 
369 369
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
370
-    }
370
+	}
371 371
 
372 372
 	private static function get_delete_form_time( $form, &$errors ) {
373 373
 		if ( 'trash' == $form->status ) {
@@ -377,19 +377,19 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    /* Back End CRUD */
380
+	/* Back End CRUD */
381 381
 	public static function show( $id = 0 ) {
382
-        FrmAppHelper::permission_check('frm_view_entries');
382
+		FrmAppHelper::permission_check('frm_view_entries');
383 383
 
384
-        if ( ! $id ) {
384
+		if ( ! $id ) {
385 385
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
386 386
 
387
-            if ( ! $id ) {
387
+			if ( ! $id ) {
388 388
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
389
-            }
390
-        }
389
+			}
390
+		}
391 391
 
392
-        $entry = FrmEntry::getOne($id, true);
392
+		$entry = FrmEntry::getOne($id, true);
393 393
 		if ( ! $entry ) {
394 394
 			echo '<div id="form_show_entry_page" class="wrap">' .
395 395
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -397,110 +397,110 @@  discard block
 block discarded – undo
397 397
 			return;
398 398
 		}
399 399
 
400
-        $data = maybe_unserialize($entry->description);
400
+		$data = maybe_unserialize($entry->description);
401 401
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
402 402
 			$data = array( 'referrer' => $data );
403 403
 		}
404 404
 
405 405
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
406
-        $to_emails = array();
406
+		$to_emails = array();
407 407
 
408 408
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
409
-    }
409
+	}
410 410
 
411
-    public static function destroy() {
412
-        FrmAppHelper::permission_check('frm_delete_entries');
411
+	public static function destroy() {
412
+		FrmAppHelper::permission_check('frm_delete_entries');
413 413
 
414 414
 		$params = FrmForm::get_admin_params();
415 415
 
416
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
417
-            //unlink entry from post
418
-            global $wpdb;
416
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
417
+			//unlink entry from post
418
+			global $wpdb;
419 419
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
420
-        }
420
+		}
421 421
 
422
-        $message = '';
423
-        if ( FrmEntry::destroy( $params['id'] ) ) {
424
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
425
-        }
422
+		$message = '';
423
+		if ( FrmEntry::destroy( $params['id'] ) ) {
424
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
425
+		}
426 426
 
427
-        self::display_list( $message );
428
-    }
427
+		self::display_list( $message );
428
+	}
429 429
 
430
-    public static function destroy_all() {
431
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
432
-            $frm_settings = FrmAppHelper::get_settings();
433
-            wp_die( $frm_settings->admin_permission );
434
-        }
430
+	public static function destroy_all() {
431
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
432
+			$frm_settings = FrmAppHelper::get_settings();
433
+			wp_die( $frm_settings->admin_permission );
434
+		}
435 435
 
436
-        global $wpdb;
436
+		global $wpdb;
437 437
 		$params = FrmForm::get_admin_params();
438
-        $message = '';
439
-        $errors = array();
440
-        $form_id = (int) $params['form'];
438
+		$message = '';
439
+		$errors = array();
440
+		$form_id = (int) $params['form'];
441 441
 
442
-        if ( $form_id ) {
443
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
442
+		if ( $form_id ) {
443
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
444 444
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
445 445
 
446
-            if ( $action ) {
447
-                // this action takes a while, so only trigger it if there are posts to delete
448
-                foreach ( $entry_ids as $entry_id ) {
449
-                    do_action( 'frm_before_destroy_entry', $entry_id );
450
-                    unset( $entry_id );
451
-                }
452
-            }
453
-
454
-            $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 ) );
455
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
456
-            if ( $results ) {
446
+			if ( $action ) {
447
+				// this action takes a while, so only trigger it if there are posts to delete
448
+				foreach ( $entry_ids as $entry_id ) {
449
+					do_action( 'frm_before_destroy_entry', $entry_id );
450
+					unset( $entry_id );
451
+				}
452
+			}
453
+
454
+			$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 ) );
455
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
456
+			if ( $results ) {
457 457
 				FrmEntry::clear_cache();
458
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
459
-            }
460
-        } else {
461
-            $errors = __( 'No entries were specified', 'formidable' );
462
-        }
463
-
464
-        self::display_list( $message, $errors );
465
-    }
466
-
467
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
468
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
469
-        return FrmFormsController::show_form( $id, $key, $title, $description );
470
-    }
471
-
472
-    public static function get_form( $filename, $form, $title, $description ) {
473
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
474
-        return FrmFormsController::get_form( $form, $title, $description );
475
-    }
476
-
477
-    public static function process_entry( $errors = '', $ajax = false ) {
458
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
459
+			}
460
+		} else {
461
+			$errors = __( 'No entries were specified', 'formidable' );
462
+		}
463
+
464
+		self::display_list( $message, $errors );
465
+	}
466
+
467
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
468
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
469
+		return FrmFormsController::show_form( $id, $key, $title, $description );
470
+	}
471
+
472
+	public static function get_form( $filename, $form, $title, $description ) {
473
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
474
+		return FrmFormsController::get_form( $form, $title, $description );
475
+	}
476
+
477
+	public static function process_entry( $errors = '', $ajax = false ) {
478 478
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
479 479
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
480
-            return;
481
-        }
480
+			return;
481
+		}
482 482
 
483
-        global $frm_vars;
483
+		global $frm_vars;
484 484
 
485 485
 		$form = FrmForm::getOne( $form_id );
486
-        if ( ! $form ) {
487
-            return;
488
-        }
486
+		if ( ! $form ) {
487
+			return;
488
+		}
489 489
 
490 490
 		$params = FrmForm::get_params( $form );
491 491
 
492
-        if ( ! isset( $frm_vars['form_params'] ) ) {
493
-            $frm_vars['form_params'] = array();
494
-        }
492
+		if ( ! isset( $frm_vars['form_params'] ) ) {
493
+			$frm_vars['form_params'] = array();
494
+		}
495 495
 		$frm_vars['form_params'][ $form->id ] = $params;
496 496
 
497 497
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
498
-            return;
499
-        }
498
+			return;
499
+		}
500 500
 
501
-        if ( $errors == '' && ! $ajax ) {
501
+		if ( $errors == '' && ! $ajax ) {
502 502
 			$errors = FrmEntryValidate::validate( $_POST );
503
-        }
503
+		}
504 504
 
505 505
 		/**
506 506
 		 * Use this filter to add trigger actions and add errors after
@@ -511,39 +511,39 @@  discard block
 block discarded – undo
511 511
 
512 512
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
513 513
 
514
-        if ( empty( $errors ) ) {
514
+		if ( empty( $errors ) ) {
515 515
 			$_POST['frm_skip_cookie'] = 1;
516
-            if ( $params['action'] == 'create' ) {
516
+			if ( $params['action'] == 'create' ) {
517 517
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
518 518
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
519
-                }
520
-            }
519
+				}
520
+			}
521 521
 
522
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
522
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
523 523
 			unset( $_POST['frm_skip_cookie'] );
524
-        }
525
-    }
526
-
527
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
528
-        self::_delete_entry( $atts['id'], $form );
529
-        return $url;
530
-    }
531
-
532
-    //Delete entry if not redirected
533
-    public static function delete_entry_after_save( $atts ) {
534
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
535
-    }
536
-
537
-    private static function _delete_entry( $entry_id, $form ) {
538
-        if ( ! $form ) {
539
-            return;
540
-        }
541
-
542
-        $form->options = maybe_unserialize( $form->options );
543
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
544
-            FrmEntry::destroy( $entry_id );
545
-        }
546
-    }
524
+		}
525
+	}
526
+
527
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
528
+		self::_delete_entry( $atts['id'], $form );
529
+		return $url;
530
+	}
531
+
532
+	//Delete entry if not redirected
533
+	public static function delete_entry_after_save( $atts ) {
534
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
535
+	}
536
+
537
+	private static function _delete_entry( $entry_id, $form ) {
538
+		if ( ! $form ) {
539
+			return;
540
+		}
541
+
542
+		$form->options = maybe_unserialize( $form->options );
543
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
544
+			FrmEntry::destroy( $entry_id );
545
+		}
546
+	}
547 547
 
548 548
 	/**
549 549
 	 * @param $atts
@@ -599,15 +599,15 @@  discard block
 block discarded – undo
599 599
 	}
600 600
 
601 601
 	public static function entry_sidebar( $entry ) {
602
-        $data = maybe_unserialize($entry->description);
603
-        $date_format = get_option('date_format');
604
-        $time_format = get_option('time_format');
602
+		$data = maybe_unserialize($entry->description);
603
+		$date_format = get_option('date_format');
604
+		$time_format = get_option('time_format');
605 605
 		if ( isset( $data['browser'] ) ) {
606 606
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
607 607
 		}
608 608
 
609 609
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
610
-    }
610
+	}
611 611
 
612 612
 	/***********************************************************************
613 613
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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
 		self::load_manage_entries_hooks();
11 11
 	}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             'id'      => 'formidable-entries-tab',
63 63
             'title'   => __( 'Overview', 'formidable' ),
64 64
 			'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>',
65
-        ));
65
+        ) );
66 66
 
67 67
         $screen->set_help_sidebar(
68 68
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
         global $frm_vars;
78 78
 		$form_id = FrmForm::get_current_form_id();
79 79
 
80
-		$columns[ $form_id . '_id' ] = 'ID';
81
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
80
+		$columns[$form_id . '_id'] = 'ID';
81
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
82 82
 
83 83
 		if ( $form_id ) {
84 84
 			self::get_columns_for_form( $form_id, $columns );
85 85
 		} else {
86
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
87
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
88
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
86
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
87
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
88
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
89 89
 		}
90 90
 
91
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
92
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
91
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
92
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
93 93
 		self::maybe_add_ip_col( $form_id, $columns );
94 94
 
95 95
         $frm_vars['cols'] = $columns;
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 				if ( $sub_form_cols ) {
117 117
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
118 118
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
119
-							unset( $sub_form_cols[ $k ] );
119
+							unset( $sub_form_cols[$k] );
120 120
 							continue;
121 121
 						}
122
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
123
-						unset($sub_form_col);
122
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
123
+						unset( $sub_form_col );
124 124
 					}
125 125
 				}
126
-				unset($sub_form_cols);
126
+				unset( $sub_form_cols );
127 127
 			} else {
128 128
 				$col_id = $form_col->field_key;
129 129
 				if ( $form_col->form_id != $form_id ) {
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
134 134
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
135 135
 				if ( $has_separate_value && ! $is_post_status ) {
136
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
136
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
137 137
 				}
138
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
138
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
139 139
 			}
140 140
 		}
141 141
 	}
142 142
 
143 143
 	private static function maybe_add_ip_col( $form_id, &$columns ) {
144 144
 		if ( FrmAppHelper::ips_saved() ) {
145
-			$columns[ $form_id . '_ip' ] = 'IP';
145
+			$columns[$form_id . '_ip'] = 'IP';
146 146
 		}
147 147
 	}
148 148
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
         global $frm_vars;
160 160
         //add a check so we don't create a loop
161
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
161
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
162 162
 
163 163
         return $check;
164 164
     }
@@ -171,19 +171,19 @@  discard block
 block discarded – undo
171 171
         }
172 172
 
173 173
         global $frm_vars;
174
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
174
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
175 175
             return; //don't continue if there's no previous value
176 176
         }
177 177
 
178 178
         foreach ( $meta_value as $mk => $mv ) {
179 179
             //remove blank values
180 180
             if ( empty( $mv ) ) {
181
-                unset( $meta_value[ $mk ] );
181
+                unset( $meta_value[$mk] );
182 182
             }
183 183
         }
184 184
 
185
-        $cur_form_prefix = reset($meta_value);
186
-        $cur_form_prefix = explode('_', $cur_form_prefix);
185
+        $cur_form_prefix = reset( $meta_value );
186
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
187 187
         $cur_form_prefix = $cur_form_prefix[0];
188 188
         $save = false;
189 189
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
             $meta_value[] = $prev_hidden;
204 204
             $save = true;
205
-            unset($form_prefix);
205
+            unset( $form_prefix );
206 206
         }
207 207
 
208 208
 		if ( $save ) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		foreach ( $fields as $field ) {
253 253
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
254 254
 				// Can't sort on checkboxes because they are stored serialized, or post fields
255
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
255
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
256 256
 			}
257 257
 		}
258 258
 
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 
279 279
 		if ( $form_id ) {
280 280
 			$result[] = $form_id . '_id';
281
-			$i--;
281
+			$i --;
282 282
 		}
283 283
 
284 284
 		$result[] = $form_id . '_item_key';
285
-		$i--;
285
+		$i --;
286 286
 
287 287
 		self::remove_excess_cols( compact( 'i', 'max_columns' ), $result );
288 288
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 				$result[] = $col_key;
326 326
 			}
327 327
 
328
-			$i--;
328
+			$i --;
329 329
 			unset( $col_key, $col );
330 330
 		}
331 331
 	}
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
356 356
 			$url = add_query_arg( 'paged', $total_pages );
357 357
             if ( headers_sent() ) {
358
-                echo FrmAppHelper::js_redirect($url);
358
+                echo FrmAppHelper::js_redirect( $url );
359 359
             } else {
360 360
                 wp_redirect( esc_url_raw( $url ) );
361 361
             }
362 362
             die();
363 363
         }
364 364
 
365
-        if ( empty($message) && isset($_GET['import-message']) ) {
365
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
366 366
             $message = __( 'Your import is complete', 'formidable' );
367 367
         }
368 368
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
     /* Back End CRUD */
381 381
 	public static function show( $id = 0 ) {
382
-        FrmAppHelper::permission_check('frm_view_entries');
382
+        FrmAppHelper::permission_check( 'frm_view_entries' );
383 383
 
384 384
         if ( ! $id ) {
385 385
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
             }
390 390
         }
391 391
 
392
-        $entry = FrmEntry::getOne($id, true);
392
+        $entry = FrmEntry::getOne( $id, true );
393 393
 		if ( ! $entry ) {
394 394
 			echo '<div id="form_show_entry_page" class="wrap">' .
395 395
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			return;
398 398
 		}
399 399
 
400
-        $data = maybe_unserialize($entry->description);
400
+        $data = maybe_unserialize( $entry->description );
401 401
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
402 402
 			$data = array( 'referrer' => $data );
403 403
 		}
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
     }
410 410
 
411 411
     public static function destroy() {
412
-        FrmAppHelper::permission_check('frm_delete_entries');
412
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
413 413
 
414 414
 		$params = FrmForm::get_admin_params();
415 415
 
416
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
416
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
417 417
             //unlink entry from post
418 418
             global $wpdb;
419 419
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
         if ( ! isset( $frm_vars['form_params'] ) ) {
493 493
             $frm_vars['form_params'] = array();
494 494
         }
495
-		$frm_vars['form_params'][ $form->id ] = $params;
495
+		$frm_vars['form_params'][$form->id] = $params;
496 496
 
497
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
497
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
498 498
             return;
499 499
         }
500 500
 
@@ -509,13 +509,13 @@  discard block
 block discarded – undo
509 509
 		 */
510 510
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
511 511
 
512
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
512
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
513 513
 
514 514
         if ( empty( $errors ) ) {
515 515
 			$_POST['frm_skip_cookie'] = 1;
516 516
             if ( $params['action'] == 'create' ) {
517
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
518
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
517
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
518
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
519 519
                 }
520 520
             }
521 521
 
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 	}
600 600
 
601 601
 	public static function entry_sidebar( $entry ) {
602
-        $data = maybe_unserialize($entry->description);
603
-        $date_format = get_option('date_format');
604
-        $time_format = get_option('time_format');
602
+        $data = maybe_unserialize( $entry->description );
603
+        $date_format = get_option( 'date_format' );
604
+        $time_format = get_option( 'time_format' );
605 605
 		if ( isset( $data['browser'] ) ) {
606 606
 			$browser = FrmEntriesHelper::get_browser( $data['browser'] );
607 607
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmListHelper.php 1 patch
Spacing   +14 added lines, -14 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
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 			return $this->get_pagenum();
210 210
 		}
211 211
 
212
-		if ( isset( $this->_pagination_args[ $key ] ) ) {
213
-			return $this->_pagination_args[ $key ];
212
+		if ( isset( $this->_pagination_args[$key] ) ) {
213
+			return $this->_pagination_args[$key];
214 214
 		}
215 215
 	}
216 216
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	private function hidden_search_inputs( $param_name ) {
268
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
269
-			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
268
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
269
+			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />';
270 270
 		}
271 271
 	}
272 272
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 		echo "<ul class='subsubsub'>\n";
311 311
 		foreach ( $views as $class => $view ) {
312
-			$views[ $class ] = "\t<li class='$class'>$view";
312
+			$views[$class] = "\t<li class='$class'>$view";
313 313
 		}
314 314
 		echo implode( " |</li>\n", $views ) . "</li>\n";
315 315
 		echo '</ul>';
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 
432 432
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
433 433
 		foreach ( $actions as $action => $link ) {
434
-			++$i;
434
+			++ $i;
435 435
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
436 436
 			$out .= "<span class='$action'>$link$sep</span>";
437 437
 		}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 
703 703
 		// If the primary column doesn't exist fall back to the
704 704
 		// first non-checkbox column.
705
-		if ( ! isset( $columns[ $default ] ) ) {
705
+		if ( ! isset( $columns[$default] ) ) {
706 706
 			$default = FrmListHelper::get_default_primary_column_name();
707 707
 		}
708 708
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 		 */
717 717
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
718 718
 
719
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
719
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
720 720
 			$column = $default;
721 721
 		}
722 722
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			// In 4.3, we added a fourth argument for primary column.
739 739
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
740 740
 			foreach ( $this->_column_headers as $key => $value ) {
741
-				$column_headers[ $key ] = $value;
741
+				$column_headers[$key] = $value;
742 742
 			}
743 743
 
744 744
 			return $column_headers;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 				$data[1] = false;
772 772
 			}
773 773
 
774
-			$sortable[ $id ] = $data;
774
+			$sortable[$id] = $data;
775 775
 		}
776 776
 
777 777
 		$primary = $this->get_primary_column_name();
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 			static $cb_counter = 1;
827 827
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
828 828
 				. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
829
-			$cb_counter++;
829
+			$cb_counter ++;
830 830
 		}
831 831
 
832 832
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 				$class[] = 'column-primary';
847 847
 			}
848 848
 
849
-			if ( isset( $sortable[ $column_key ] ) ) {
850
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
849
+			if ( isset( $sortable[$column_key] ) ) {
850
+				list( $orderby, $desc_first ) = $sortable[$column_key];
851 851
 
852 852
 				if ( $current_orderby == $orderby ) {
853 853
 					$order = 'asc' == $current_order ? 'desc' : 'asc';
Please login to merge, or discard this patch.