Completed
Push — master ( 105df6...cc22b2 )
by Jamie
03:31
created
classes/controllers/FrmEntriesController.php 1 patch
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -2,201 +2,201 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( '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, $wpdb;
68
+		global $frm_vars, $wpdb;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
72 72
 		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74
-        if ( ! $form_id ) {
75
-            return $columns;
76
-        }
74
+		if ( ! $form_id ) {
75
+			return $columns;
76
+		}
77 77
 
78
-        $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
78
+		$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
79 79
 
80
-        foreach ( $form_cols as $form_col ) {
80
+		foreach ( $form_cols as $form_col ) {
81 81
 			if ( FrmField::is_no_save_field( $form_col->type ) ) {
82
-                continue;
83
-            }
82
+				continue;
83
+			}
84 84
 
85
-            if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
85
+			if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
86 86
 				$sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] );
87 87
 
88
-                if ( $sub_form_cols ) {
89
-                    foreach ( $sub_form_cols as $k => $sub_form_col ) {
88
+				if ( $sub_form_cols ) {
89
+					foreach ( $sub_form_cols as $k => $sub_form_col ) {
90 90
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
91
-                            unset( $sub_form_cols[ $k ] );
92
-                            continue;
93
-                        }
91
+							unset( $sub_form_cols[ $k ] );
92
+							continue;
93
+						}
94 94
 						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
95
-                        unset($sub_form_col);
96
-                    }
97
-                }
98
-                unset($sub_form_cols);
99
-            } else {
100
-                $col_id = $form_col->field_key;
101
-                if ( $form_col->form_id != $form_id ) {
95
+						unset($sub_form_col);
96
+					}
97
+				}
98
+				unset($sub_form_cols);
99
+			} else {
100
+				$col_id = $form_col->field_key;
101
+				if ( $form_col->form_id != $form_id ) {
102 102
 					$col_id .= '-_-form' . $form_col->form_id;
103
-                }
103
+				}
104 104
 
105
-                if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
105
+				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
106 106
 					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
107
-                }
107
+				}
108 108
 				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
109
-            }
110
-        }
109
+			}
110
+		}
111 111
 
112 112
 		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
113 113
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
114 114
 		$columns[ $form_id . '_ip' ] = 'IP';
115 115
 
116
-        $frm_vars['cols'] = $columns;
116
+		$frm_vars['cols'] = $columns;
117 117
 
118 118
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
119 119
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
120 120
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
121
-        }
121
+		}
122 122
 
123
-        return $columns;
124
-    }
123
+		return $columns;
124
+	}
125 125
 
126 126
 	public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
127 127
 		$menu_name = FrmAppHelper::get_menu_name();
128 128
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
129 129
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
130
-            return $check;
131
-        }
130
+			return $check;
131
+		}
132 132
 
133 133
 		if ( empty( $prev_value ) ) {
134 134
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
135 135
 		}
136 136
 
137
-        global $frm_vars;
138
-        //add a check so we don't create a loop
139
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
137
+		global $frm_vars;
138
+		//add a check so we don't create a loop
139
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
140 140
 
141
-        return $check;
142
-    }
141
+		return $check;
142
+	}
143 143
 
144
-    //add hidden columns back from other forms
144
+	//add hidden columns back from other forms
145 145
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
146 146
 		$menu_name = FrmAppHelper::get_menu_name();
147 147
 		$sanitized = sanitize_title( $menu_name );
148 148
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
149 149
 		if ( $meta_key != $this_page_name ) {
150
-            return;
151
-        }
152
-
153
-        global $frm_vars;
154
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
-            return; //don't continue if there's no previous value
156
-        }
157
-
158
-        foreach ( $meta_value as $mk => $mv ) {
159
-            //remove blank values
160
-            if ( empty( $mv )  ) {
161
-                unset( $meta_value[ $mk ] );
162
-            }
163
-        }
164
-
165
-        $cur_form_prefix = reset($meta_value);
166
-        $cur_form_prefix = explode('_', $cur_form_prefix);
167
-        $cur_form_prefix = $cur_form_prefix[0];
168
-        $save = false;
169
-
170
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
150
+			return;
151
+		}
152
+
153
+		global $frm_vars;
154
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
155
+			return; //don't continue if there's no previous value
156
+		}
157
+
158
+		foreach ( $meta_value as $mk => $mv ) {
159
+			//remove blank values
160
+			if ( empty( $mv )  ) {
161
+				unset( $meta_value[ $mk ] );
162
+			}
163
+		}
164
+
165
+		$cur_form_prefix = reset($meta_value);
166
+		$cur_form_prefix = explode('_', $cur_form_prefix);
167
+		$cur_form_prefix = $cur_form_prefix[0];
168
+		$save = false;
169
+
170
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
171 171
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
172
-                //don't add blank cols or process included cols
173
-                continue;
174
-            }
172
+				//don't add blank cols or process included cols
173
+				continue;
174
+			}
175 175
 
176 176
 			$form_prefix = explode( '_', $prev_hidden );
177
-            $form_prefix = $form_prefix[0];
178
-            if ( $form_prefix == $cur_form_prefix ) {
179
-                //don't add back columns that are meant to be hidden
180
-                continue;
181
-            }
177
+			$form_prefix = $form_prefix[0];
178
+			if ( $form_prefix == $cur_form_prefix ) {
179
+				//don't add back columns that are meant to be hidden
180
+				continue;
181
+			}
182 182
 
183
-            $meta_value[] = $prev_hidden;
184
-            $save = true;
185
-            unset($form_prefix);
186
-        }
183
+			$meta_value[] = $prev_hidden;
184
+			$save = true;
185
+			unset($form_prefix);
186
+		}
187 187
 
188 188
 		if ( $save ) {
189
-            $user = wp_get_current_user();
189
+			$user = wp_get_current_user();
190 190
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
191
-        }
192
-    }
191
+		}
192
+	}
193 193
 
194 194
 	public static function save_per_page( $save, $option, $value ) {
195
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
-            $save = (int) $value;
197
-        }
198
-        return $save;
199
-    }
195
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
196
+			$save = (int) $value;
197
+		}
198
+		return $save;
199
+	}
200 200
 
201 201
 	public static function sortable_columns() {
202 202
 		$form_id = FrmForm::get_current_form_id();
@@ -222,122 +222,122 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public static function hidden_columns( $result ) {
225
-        global $frm_vars;
225
+		global $frm_vars;
226 226
 
227 227
 		$form_id = FrmForm::get_current_form_id();
228 228
 
229
-        $return = false;
230
-        foreach ( (array) $result as $r ) {
231
-            if ( ! empty( $r ) ) {
232
-                $form_prefix = explode( '_', $r );
233
-                $form_prefix = $form_prefix[0];
229
+		$return = false;
230
+		foreach ( (array) $result as $r ) {
231
+			if ( ! empty( $r ) ) {
232
+				$form_prefix = explode( '_', $r );
233
+				$form_prefix = $form_prefix[0];
234 234
 
235
-                if ( (int) $form_prefix == (int) $form_id ) {
236
-                    $return = true;
237
-                    break;
238
-                }
235
+				if ( (int) $form_prefix == (int) $form_id ) {
236
+					$return = true;
237
+					break;
238
+				}
239 239
 
240
-                unset($form_prefix);
241
-            }
242
-        }
240
+				unset($form_prefix);
241
+			}
242
+		}
243 243
 
244
-        if ( $return ) {
244
+		if ( $return ) {
245 245
 			return $result;
246 246
 		}
247 247
 
248
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
-        $max_columns = 8;
250
-        if ( $i <= $max_columns ) {
248
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
249
+		$max_columns = 8;
250
+		if ( $i <= $max_columns ) {
251 251
 			return $result;
252 252
 		}
253 253
 
254
-        global $frm_vars;
255
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
-        }
254
+		global $frm_vars;
255
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
256
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
257
+		}
258 258
 
259
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
-            $result = $frm_vars['current_form']->options['hidden_cols'];
261
-        } else {
262
-            $cols = $frm_vars['cols'];
263
-            $cols = array_reverse($cols, true);
259
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
260
+			$result = $frm_vars['current_form']->options['hidden_cols'];
261
+		} else {
262
+			$cols = $frm_vars['cols'];
263
+			$cols = array_reverse($cols, true);
264 264
 
265 265
 			$result[] = $form_id . '_id';
266
-            $i--;
266
+			$i--;
267 267
 
268 268
 			$result[] = $form_id . '_item_key';
269
-            $i--;
269
+			$i--;
270 270
 
271 271
 			foreach ( $cols as $col_key => $col ) {
272
-                if ( $i > $max_columns ) {
272
+				if ( $i > $max_columns ) {
273 273
 					$result[] = $col_key;
274 274
 				}
275
-                //remove some columns by default
276
-                $i--;
277
-                unset($col_key, $col);
278
-            }
279
-        }
275
+				//remove some columns by default
276
+				$i--;
277
+				unset($col_key, $col);
278
+			}
279
+		}
280 280
 
281
-        return $result;
282
-    }
281
+		return $result;
282
+	}
283 283
 
284 284
 	public static function display_list( $message = '', $errors = array() ) {
285
-        global $wpdb, $frm_vars;
285
+		global $wpdb, $frm_vars;
286 286
 
287 287
 		$form = FrmForm::get_current_form();
288 288
 		$params = FrmForm::get_admin_params( $form );
289 289
 
290
-        if ( $form ) {
291
-            $params['form'] = $form->id;
292
-            $frm_vars['current_form'] = $form;
290
+		if ( $form ) {
291
+			$params['form'] = $form->id;
292
+			$frm_vars['current_form'] = $form;
293 293
 
294
-	        if ( 'trash' == $form->status ) {
295
-	            $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
-	            $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
-	            $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
-	            unset( $time_to_delete, $delete_timestamp );
299
-	        }
294
+			if ( 'trash' == $form->status ) {
295
+				$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
296
+				$time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
297
+				$errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
298
+				unset( $time_to_delete, $delete_timestamp );
299
+			}
300 300
 		}
301 301
 
302
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
302
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
303 303
 
304
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
304
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
305 305
 
306
-        $pagenum = $wp_list_table->get_pagenum();
306
+		$pagenum = $wp_list_table->get_pagenum();
307 307
 
308
-        $wp_list_table->prepare_items();
308
+		$wp_list_table->prepare_items();
309 309
 
310
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
310
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
311
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
312 312
 			$url = add_query_arg( 'paged', $total_pages );
313
-            if ( headers_sent() ) {
314
-                echo FrmAppHelper::js_redirect($url);
315
-            } else {
316
-                wp_redirect( esc_url_raw( $url ) );
317
-            }
318
-            die();
319
-        }
320
-
321
-        if ( empty($message) && isset($_GET['import-message']) ) {
322
-            $message = __( 'Your import is complete', 'formidable' );
323
-        }
313
+			if ( headers_sent() ) {
314
+				echo FrmAppHelper::js_redirect($url);
315
+			} else {
316
+				wp_redirect( esc_url_raw( $url ) );
317
+			}
318
+			die();
319
+		}
320
+
321
+		if ( empty($message) && isset($_GET['import-message']) ) {
322
+			$message = __( 'Your import is complete', 'formidable' );
323
+		}
324 324
 
325 325
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
326
-    }
326
+	}
327 327
 
328
-    /* Back End CRUD */
328
+	/* Back End CRUD */
329 329
 	public static function show( $id = 0 ) {
330
-        FrmAppHelper::permission_check('frm_view_entries');
330
+		FrmAppHelper::permission_check('frm_view_entries');
331 331
 
332
-        if ( ! $id ) {
332
+		if ( ! $id ) {
333 333
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
334 334
 
335
-            if ( ! $id ) {
335
+			if ( ! $id ) {
336 336
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
337
-            }
338
-        }
337
+			}
338
+		}
339 339
 
340
-        $entry = FrmEntry::getOne($id, true);
340
+		$entry = FrmEntry::getOne($id, true);
341 341
 		if ( ! $entry ) {
342 342
 			echo '<div id="form_show_entry_page" class="wrap">' .
343 343
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -345,110 +345,110 @@  discard block
 block discarded – undo
345 345
 			return;
346 346
 		}
347 347
 
348
-        $data = maybe_unserialize($entry->description);
348
+		$data = maybe_unserialize($entry->description);
349 349
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
350 350
 			$data = array( 'referrer' => $data );
351 351
 		}
352 352
 
353 353
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
354
-        $to_emails = array();
354
+		$to_emails = array();
355 355
 
356 356
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
357
-    }
357
+	}
358 358
 
359
-    public static function destroy() {
360
-        FrmAppHelper::permission_check('frm_delete_entries');
359
+	public static function destroy() {
360
+		FrmAppHelper::permission_check('frm_delete_entries');
361 361
 
362 362
 		$params = FrmForm::get_admin_params();
363 363
 
364
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
365
-            //unlink entry from post
366
-            global $wpdb;
364
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
365
+			//unlink entry from post
366
+			global $wpdb;
367 367
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
368
-        }
368
+		}
369 369
 
370
-        $message = '';
371
-        if ( FrmEntry::destroy( $params['id'] ) ) {
372
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
373
-        }
370
+		$message = '';
371
+		if ( FrmEntry::destroy( $params['id'] ) ) {
372
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
373
+		}
374 374
 
375
-        self::display_list( $message );
376
-    }
375
+		self::display_list( $message );
376
+	}
377 377
 
378
-    public static function destroy_all() {
379
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
380
-            $frm_settings = FrmAppHelper::get_settings();
381
-            wp_die( $frm_settings->admin_permission );
382
-        }
378
+	public static function destroy_all() {
379
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
380
+			$frm_settings = FrmAppHelper::get_settings();
381
+			wp_die( $frm_settings->admin_permission );
382
+		}
383 383
 
384
-        global $wpdb;
384
+		global $wpdb;
385 385
 		$params = FrmForm::get_admin_params();
386
-        $message = '';
387
-        $errors = array();
388
-        $form_id = (int) $params['form'];
386
+		$message = '';
387
+		$errors = array();
388
+		$form_id = (int) $params['form'];
389 389
 
390
-        if ( $form_id ) {
391
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
390
+		if ( $form_id ) {
391
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
392 392
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
393 393
 
394
-            if ( $action ) {
395
-                // this action takes a while, so only trigger it if there are posts to delete
396
-                foreach ( $entry_ids as $entry_id ) {
397
-                    do_action( 'frm_before_destroy_entry', $entry_id );
398
-                    unset( $entry_id );
399
-                }
400
-            }
401
-
402
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
403
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
404
-            if ( $results ) {
394
+			if ( $action ) {
395
+				// this action takes a while, so only trigger it if there are posts to delete
396
+				foreach ( $entry_ids as $entry_id ) {
397
+					do_action( 'frm_before_destroy_entry', $entry_id );
398
+					unset( $entry_id );
399
+				}
400
+			}
401
+
402
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
403
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
404
+			if ( $results ) {
405 405
 				FrmEntry::clear_cache();
406
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
407
-            }
408
-        } else {
409
-            $errors = __( 'No entries were specified', 'formidable' );
410
-        }
411
-
412
-        self::display_list( $message, $errors );
413
-    }
414
-
415
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
416
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
417
-        return FrmFormsController::show_form( $id, $key, $title, $description );
418
-    }
419
-
420
-    public static function get_form( $filename, $form, $title, $description ) {
421
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
422
-        return FrmFormsController::get_form( $form, $title, $description );
423
-    }
424
-
425
-    public static function process_entry( $errors = '', $ajax = false ) {
406
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
407
+			}
408
+		} else {
409
+			$errors = __( 'No entries were specified', 'formidable' );
410
+		}
411
+
412
+		self::display_list( $message, $errors );
413
+	}
414
+
415
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
416
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
417
+		return FrmFormsController::show_form( $id, $key, $title, $description );
418
+	}
419
+
420
+	public static function get_form( $filename, $form, $title, $description ) {
421
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
422
+		return FrmFormsController::get_form( $form, $title, $description );
423
+	}
424
+
425
+	public static function process_entry( $errors = '', $ajax = false ) {
426 426
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
427 427
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
428
-            return;
429
-        }
428
+			return;
429
+		}
430 430
 
431
-        global $frm_vars;
431
+		global $frm_vars;
432 432
 
433 433
 		$form = FrmForm::getOne( $form_id );
434
-        if ( ! $form ) {
435
-            return;
436
-        }
434
+		if ( ! $form ) {
435
+			return;
436
+		}
437 437
 
438 438
 		$params = FrmForm::get_params( $form );
439 439
 
440
-        if ( ! isset( $frm_vars['form_params'] ) ) {
441
-            $frm_vars['form_params'] = array();
442
-        }
440
+		if ( ! isset( $frm_vars['form_params'] ) ) {
441
+			$frm_vars['form_params'] = array();
442
+		}
443 443
 		$frm_vars['form_params'][ $form->id ] = $params;
444 444
 
445 445
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
446
-            return;
447
-        }
446
+			return;
447
+		}
448 448
 
449
-        if ( $errors == '' && ! $ajax ) {
449
+		if ( $errors == '' && ! $ajax ) {
450 450
 			$errors = FrmEntryValidate::validate( $_POST );
451
-        }
451
+		}
452 452
 
453 453
 		/**
454 454
 		 * Use this filter to add trigger actions and add errors after
@@ -459,104 +459,104 @@  discard block
 block discarded – undo
459 459
 
460 460
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
461 461
 
462
-        if ( empty( $errors ) ) {
462
+		if ( empty( $errors ) ) {
463 463
 			$_POST['frm_skip_cookie'] = 1;
464
-            if ( $params['action'] == 'create' ) {
464
+			if ( $params['action'] == 'create' ) {
465 465
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
466 466
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
467
-                }
468
-            }
467
+				}
468
+			}
469 469
 
470
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
470
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
471 471
 			unset( $_POST['frm_skip_cookie'] );
472
-        }
473
-    }
474
-
475
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
476
-        self::_delete_entry( $atts['id'], $form );
477
-        return $url;
478
-    }
479
-
480
-    //Delete entry if not redirected
481
-    public static function delete_entry_after_save( $atts ) {
482
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
483
-    }
484
-
485
-    private static function _delete_entry( $entry_id, $form ) {
486
-        if ( ! $form ) {
487
-            return;
488
-        }
489
-
490
-        $form->options = maybe_unserialize( $form->options );
491
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
492
-            FrmEntry::destroy( $entry_id );
493
-        }
494
-    }
472
+		}
473
+	}
474
+
475
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
476
+		self::_delete_entry( $atts['id'], $form );
477
+		return $url;
478
+	}
479
+
480
+	//Delete entry if not redirected
481
+	public static function delete_entry_after_save( $atts ) {
482
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
483
+	}
484
+
485
+	private static function _delete_entry( $entry_id, $form ) {
486
+		if ( ! $form ) {
487
+			return;
488
+		}
489
+
490
+		$form->options = maybe_unserialize( $form->options );
491
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
492
+			FrmEntry::destroy( $entry_id );
493
+		}
494
+	}
495 495
 
496 496
 	public static function show_entry_shortcode( $atts ) {
497 497
 		return FrmEntryFormat::show_entry( $atts );
498 498
 	}
499 499
 
500
-    public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
501
-        $field = FrmField::getOne($meta->field_id);
502
-        if ( ! $field ) {
503
-            return $value;
504
-        }
500
+	public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
501
+		$field = FrmField::getOne($meta->field_id);
502
+		if ( ! $field ) {
503
+			return $value;
504
+		}
505 505
 
506
-        $value = self::filter_display_value($value, $field, $atts);
507
-        return $value;
508
-    }
506
+		$value = self::filter_display_value($value, $field, $atts);
507
+		return $value;
508
+	}
509 509
 
510 510
 	public static function &filter_shortcode_value( $value, $tag, $atts, $field ) {
511
-        $plain_text = add_filter('frm_plain_text_email', true);
511
+		$plain_text = add_filter('frm_plain_text_email', true);
512 512
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
513 513
 
514
-        if ( isset($atts['show']) && $atts['show'] == 'value' ) {
515
-            return $value;
516
-        }
514
+		if ( isset($atts['show']) && $atts['show'] == 'value' ) {
515
+			return $value;
516
+		}
517 517
 
518
-        return self::filter_display_value($value, $field, $atts);
519
-    }
518
+		return self::filter_display_value($value, $field, $atts);
519
+	}
520 520
 
521
-    public static function &filter_display_value( $value, $field, $atts = array() ) {
522
-        $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
521
+	public static function &filter_display_value( $value, $field, $atts = array() ) {
522
+		$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
523 523
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) )
524
-		     || ! FrmField::is_option_true( $field, 'separate_value' )
525
-		     || $saved_value || $value === false ) {
526
-            return $value;
527
-        }
528
-
529
-        $f_values = $f_labels = array();
530
-
531
-        foreach ( $field->options as $opt_key => $opt ) {
532
-            if ( ! is_array($opt) ) {
533
-                continue;
534
-            }
535
-
536
-            $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
537
-            $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
538
-            if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
539
-                unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
540
-            }
541
-            unset($opt_key, $opt);
542
-        }
543
-
544
-        if ( ! empty($f_values) ) {
545
-            foreach ( (array) $value as $v_key => $val ) {
546
-                if ( in_array($val, $f_values) ) {
547
-                    $opt = array_search($val, $f_values);
548
-                    if ( is_array($value) ) {
549
-                        $value[ $v_key ] = $f_labels[ $opt ];
550
-                    } else {
551
-                        $value = $f_labels[ $opt ];
552
-                    }
553
-                }
554
-                unset($v_key, $val);
555
-            }
556
-        }
557
-
558
-        return $value;
559
-    }
524
+			 || ! FrmField::is_option_true( $field, 'separate_value' )
525
+			 || $saved_value || $value === false ) {
526
+			return $value;
527
+		}
528
+
529
+		$f_values = $f_labels = array();
530
+
531
+		foreach ( $field->options as $opt_key => $opt ) {
532
+			if ( ! is_array($opt) ) {
533
+				continue;
534
+			}
535
+
536
+			$f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt);
537
+			$f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ];
538
+			if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) {
539
+				unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] );
540
+			}
541
+			unset($opt_key, $opt);
542
+		}
543
+
544
+		if ( ! empty($f_values) ) {
545
+			foreach ( (array) $value as $v_key => $val ) {
546
+				if ( in_array($val, $f_values) ) {
547
+					$opt = array_search($val, $f_values);
548
+					if ( is_array($value) ) {
549
+						$value[ $v_key ] = $f_labels[ $opt ];
550
+					} else {
551
+						$value = $f_labels[ $opt ];
552
+					}
553
+				}
554
+				unset($v_key, $val);
555
+			}
556
+		}
557
+
558
+		return $value;
559
+	}
560 560
 
561 561
 	public static function get_params( $form = null ) {
562 562
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	public static function entry_sidebar( $entry ) {
567
-        $data = maybe_unserialize($entry->description);
568
-        $date_format = get_option('date_format');
569
-        $time_format = get_option('time_format');
567
+		$data = maybe_unserialize($entry->description);
568
+		$date_format = get_option('date_format');
569
+		$time_format = get_option('time_format');
570 570
 		if ( isset( $data['browser'] ) ) {
571 571
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
572 572
 		}
573 573
 
574 574
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
575
-    }
575
+	}
576 576
 }
Please login to merge, or discard this patch.