@@ -2,70 +2,70 @@ discard block |
||
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 |
||
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' ); |
@@ -135,76 +135,76 @@ discard block |
||
135 | 135 | $menu_name = FrmAppHelper::get_menu_name(); |
136 | 136 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
137 | 137 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
138 | - return $check; |
|
139 | - } |
|
138 | + return $check; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | if ( empty( $prev_value ) ) { |
142 | 142 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
143 | 143 | } |
144 | 144 | |
145 | - global $frm_vars; |
|
146 | - //add a check so we don't create a loop |
|
147 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
145 | + global $frm_vars; |
|
146 | + //add a check so we don't create a loop |
|
147 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
148 | 148 | |
149 | - return $check; |
|
150 | - } |
|
149 | + return $check; |
|
150 | + } |
|
151 | 151 | |
152 | - //add hidden columns back from other forms |
|
152 | + //add hidden columns back from other forms |
|
153 | 153 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
154 | 154 | $menu_name = FrmAppHelper::get_menu_name(); |
155 | 155 | $sanitized = sanitize_title( $menu_name ); |
156 | 156 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
157 | 157 | if ( $meta_key != $this_page_name ) { |
158 | - return; |
|
159 | - } |
|
160 | - |
|
161 | - global $frm_vars; |
|
162 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
163 | - return; //don't continue if there's no previous value |
|
164 | - } |
|
165 | - |
|
166 | - foreach ( $meta_value as $mk => $mv ) { |
|
167 | - //remove blank values |
|
168 | - if ( empty( $mv ) ) { |
|
169 | - unset( $meta_value[ $mk ] ); |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - $cur_form_prefix = reset($meta_value); |
|
174 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
175 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
176 | - $save = false; |
|
177 | - |
|
178 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
158 | + return; |
|
159 | + } |
|
160 | + |
|
161 | + global $frm_vars; |
|
162 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
163 | + return; //don't continue if there's no previous value |
|
164 | + } |
|
165 | + |
|
166 | + foreach ( $meta_value as $mk => $mv ) { |
|
167 | + //remove blank values |
|
168 | + if ( empty( $mv ) ) { |
|
169 | + unset( $meta_value[ $mk ] ); |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + $cur_form_prefix = reset($meta_value); |
|
174 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
175 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
176 | + $save = false; |
|
177 | + |
|
178 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
179 | 179 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
180 | - //don't add blank cols or process included cols |
|
181 | - continue; |
|
182 | - } |
|
180 | + //don't add blank cols or process included cols |
|
181 | + continue; |
|
182 | + } |
|
183 | 183 | |
184 | 184 | $form_prefix = explode( '_', $prev_hidden ); |
185 | - $form_prefix = $form_prefix[0]; |
|
186 | - if ( $form_prefix == $cur_form_prefix ) { |
|
187 | - //don't add back columns that are meant to be hidden |
|
188 | - continue; |
|
189 | - } |
|
185 | + $form_prefix = $form_prefix[0]; |
|
186 | + if ( $form_prefix == $cur_form_prefix ) { |
|
187 | + //don't add back columns that are meant to be hidden |
|
188 | + continue; |
|
189 | + } |
|
190 | 190 | |
191 | - $meta_value[] = $prev_hidden; |
|
192 | - $save = true; |
|
193 | - unset($form_prefix); |
|
194 | - } |
|
191 | + $meta_value[] = $prev_hidden; |
|
192 | + $save = true; |
|
193 | + unset($form_prefix); |
|
194 | + } |
|
195 | 195 | |
196 | 196 | if ( $save ) { |
197 | - $user = wp_get_current_user(); |
|
197 | + $user = wp_get_current_user(); |
|
198 | 198 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
199 | - } |
|
200 | - } |
|
199 | + } |
|
200 | + } |
|
201 | 201 | |
202 | 202 | public static function save_per_page( $save, $option, $value ) { |
203 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
204 | - $save = (int) $value; |
|
205 | - } |
|
206 | - return $save; |
|
207 | - } |
|
203 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
204 | + $save = (int) $value; |
|
205 | + } |
|
206 | + return $save; |
|
207 | + } |
|
208 | 208 | |
209 | 209 | public static function sortable_columns() { |
210 | 210 | $form_id = FrmForm::get_current_form_id(); |
@@ -230,46 +230,46 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | public static function hidden_columns( $result ) { |
233 | - global $frm_vars; |
|
233 | + global $frm_vars; |
|
234 | 234 | |
235 | 235 | $form_id = FrmForm::get_current_form_id(); |
236 | 236 | |
237 | - $return = false; |
|
238 | - foreach ( (array) $result as $r ) { |
|
239 | - if ( ! empty( $r ) ) { |
|
240 | - $form_prefix = explode( '_', $r ); |
|
241 | - $form_prefix = $form_prefix[0]; |
|
237 | + $return = false; |
|
238 | + foreach ( (array) $result as $r ) { |
|
239 | + if ( ! empty( $r ) ) { |
|
240 | + $form_prefix = explode( '_', $r ); |
|
241 | + $form_prefix = $form_prefix[0]; |
|
242 | 242 | |
243 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
244 | - $return = true; |
|
245 | - break; |
|
246 | - } |
|
243 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
244 | + $return = true; |
|
245 | + break; |
|
246 | + } |
|
247 | 247 | |
248 | - unset($form_prefix); |
|
249 | - } |
|
250 | - } |
|
248 | + unset($form_prefix); |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - if ( $return ) { |
|
252 | + if ( $return ) { |
|
253 | 253 | return $result; |
254 | 254 | } |
255 | 255 | |
256 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
257 | - $max_columns = 8; |
|
258 | - if ( $i <= $max_columns ) { |
|
256 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
257 | + $max_columns = 8; |
|
258 | + if ( $i <= $max_columns ) { |
|
259 | 259 | return $result; |
260 | 260 | } |
261 | 261 | |
262 | - global $frm_vars; |
|
263 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
264 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
265 | - } |
|
262 | + global $frm_vars; |
|
263 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
264 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
265 | + } |
|
266 | 266 | |
267 | 267 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
268 | 268 | if ( $has_custom_hidden_columns ) { |
269 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
270 | - } else { |
|
271 | - $cols = $frm_vars['cols']; |
|
272 | - $cols = array_reverse($cols, true); |
|
269 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
270 | + } else { |
|
271 | + $cols = $frm_vars['cols']; |
|
272 | + $cols = array_reverse($cols, true); |
|
273 | 273 | |
274 | 274 | if ( $form_id ) { |
275 | 275 | $result[] = $form_id . '_id'; |
@@ -277,59 +277,59 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | $result[] = $form_id . '_item_key'; |
280 | - $i--; |
|
280 | + $i--; |
|
281 | 281 | |
282 | 282 | foreach ( $cols as $col_key => $col ) { |
283 | - if ( $i > $max_columns ) { |
|
283 | + if ( $i > $max_columns ) { |
|
284 | 284 | $result[] = $col_key; |
285 | 285 | } |
286 | - //remove some columns by default |
|
287 | - $i--; |
|
288 | - unset($col_key, $col); |
|
289 | - } |
|
290 | - } |
|
286 | + //remove some columns by default |
|
287 | + $i--; |
|
288 | + unset($col_key, $col); |
|
289 | + } |
|
290 | + } |
|
291 | 291 | |
292 | - return $result; |
|
293 | - } |
|
292 | + return $result; |
|
293 | + } |
|
294 | 294 | |
295 | 295 | public static function display_list( $message = '', $errors = array() ) { |
296 | - global $wpdb, $frm_vars; |
|
296 | + global $wpdb, $frm_vars; |
|
297 | 297 | |
298 | 298 | $form = FrmForm::maybe_get_current_form(); |
299 | 299 | $params = FrmForm::get_admin_params( $form ); |
300 | 300 | |
301 | - if ( $form ) { |
|
302 | - $params['form'] = $form->id; |
|
303 | - $frm_vars['current_form'] = $form; |
|
301 | + if ( $form ) { |
|
302 | + $params['form'] = $form->id; |
|
303 | + $frm_vars['current_form'] = $form; |
|
304 | 304 | |
305 | 305 | self::get_delete_form_time( $form, $errors ); |
306 | 306 | } |
307 | 307 | |
308 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
308 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
309 | 309 | |
310 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
310 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
311 | 311 | |
312 | - $pagenum = $wp_list_table->get_pagenum(); |
|
312 | + $pagenum = $wp_list_table->get_pagenum(); |
|
313 | 313 | |
314 | - $wp_list_table->prepare_items(); |
|
314 | + $wp_list_table->prepare_items(); |
|
315 | 315 | |
316 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
317 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
316 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
317 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
318 | 318 | $url = add_query_arg( 'paged', $total_pages ); |
319 | - if ( headers_sent() ) { |
|
320 | - echo FrmAppHelper::js_redirect($url); |
|
321 | - } else { |
|
322 | - wp_redirect( esc_url_raw( $url ) ); |
|
323 | - } |
|
324 | - die(); |
|
325 | - } |
|
326 | - |
|
327 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
328 | - $message = __( 'Your import is complete', 'formidable' ); |
|
329 | - } |
|
319 | + if ( headers_sent() ) { |
|
320 | + echo FrmAppHelper::js_redirect($url); |
|
321 | + } else { |
|
322 | + wp_redirect( esc_url_raw( $url ) ); |
|
323 | + } |
|
324 | + die(); |
|
325 | + } |
|
326 | + |
|
327 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
328 | + $message = __( 'Your import is complete', 'formidable' ); |
|
329 | + } |
|
330 | 330 | |
331 | 331 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | 334 | private static function get_delete_form_time( $form, &$errors ) { |
335 | 335 | if ( 'trash' == $form->status ) { |
@@ -339,19 +339,19 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | - /* Back End CRUD */ |
|
342 | + /* Back End CRUD */ |
|
343 | 343 | public static function show( $id = 0 ) { |
344 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
344 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
345 | 345 | |
346 | - if ( ! $id ) { |
|
346 | + if ( ! $id ) { |
|
347 | 347 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
348 | 348 | |
349 | - if ( ! $id ) { |
|
349 | + if ( ! $id ) { |
|
350 | 350 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
351 | - } |
|
352 | - } |
|
351 | + } |
|
352 | + } |
|
353 | 353 | |
354 | - $entry = FrmEntry::getOne($id, true); |
|
354 | + $entry = FrmEntry::getOne($id, true); |
|
355 | 355 | if ( ! $entry ) { |
356 | 356 | echo '<div id="form_show_entry_page" class="wrap">' . |
357 | 357 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -359,110 +359,110 @@ discard block |
||
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | - $data = maybe_unserialize($entry->description); |
|
362 | + $data = maybe_unserialize($entry->description); |
|
363 | 363 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
364 | 364 | $data = array( 'referrer' => $data ); |
365 | 365 | } |
366 | 366 | |
367 | 367 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
368 | - $to_emails = array(); |
|
368 | + $to_emails = array(); |
|
369 | 369 | |
370 | 370 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
371 | - } |
|
371 | + } |
|
372 | 372 | |
373 | - public static function destroy() { |
|
374 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
373 | + public static function destroy() { |
|
374 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
375 | 375 | |
376 | 376 | $params = FrmForm::get_admin_params(); |
377 | 377 | |
378 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
379 | - //unlink entry from post |
|
380 | - global $wpdb; |
|
378 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
379 | + //unlink entry from post |
|
380 | + global $wpdb; |
|
381 | 381 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | - $message = ''; |
|
385 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
386 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
387 | - } |
|
384 | + $message = ''; |
|
385 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
386 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
387 | + } |
|
388 | 388 | |
389 | - self::display_list( $message ); |
|
390 | - } |
|
389 | + self::display_list( $message ); |
|
390 | + } |
|
391 | 391 | |
392 | - public static function destroy_all() { |
|
393 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
394 | - $frm_settings = FrmAppHelper::get_settings(); |
|
395 | - wp_die( $frm_settings->admin_permission ); |
|
396 | - } |
|
392 | + public static function destroy_all() { |
|
393 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
394 | + $frm_settings = FrmAppHelper::get_settings(); |
|
395 | + wp_die( $frm_settings->admin_permission ); |
|
396 | + } |
|
397 | 397 | |
398 | - global $wpdb; |
|
398 | + global $wpdb; |
|
399 | 399 | $params = FrmForm::get_admin_params(); |
400 | - $message = ''; |
|
401 | - $errors = array(); |
|
402 | - $form_id = (int) $params['form']; |
|
400 | + $message = ''; |
|
401 | + $errors = array(); |
|
402 | + $form_id = (int) $params['form']; |
|
403 | 403 | |
404 | - if ( $form_id ) { |
|
405 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
404 | + if ( $form_id ) { |
|
405 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
406 | 406 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
407 | 407 | |
408 | - if ( $action ) { |
|
409 | - // this action takes a while, so only trigger it if there are posts to delete |
|
410 | - foreach ( $entry_ids as $entry_id ) { |
|
411 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
412 | - unset( $entry_id ); |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - $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 ) ); |
|
417 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
418 | - if ( $results ) { |
|
408 | + if ( $action ) { |
|
409 | + // this action takes a while, so only trigger it if there are posts to delete |
|
410 | + foreach ( $entry_ids as $entry_id ) { |
|
411 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
412 | + unset( $entry_id ); |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + $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 ) ); |
|
417 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
418 | + if ( $results ) { |
|
419 | 419 | FrmEntry::clear_cache(); |
420 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
421 | - } |
|
422 | - } else { |
|
423 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
424 | - } |
|
425 | - |
|
426 | - self::display_list( $message, $errors ); |
|
427 | - } |
|
428 | - |
|
429 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
430 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
431 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
432 | - } |
|
433 | - |
|
434 | - public static function get_form( $filename, $form, $title, $description ) { |
|
435 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
436 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
437 | - } |
|
438 | - |
|
439 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
420 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
421 | + } |
|
422 | + } else { |
|
423 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
424 | + } |
|
425 | + |
|
426 | + self::display_list( $message, $errors ); |
|
427 | + } |
|
428 | + |
|
429 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
430 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
431 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
432 | + } |
|
433 | + |
|
434 | + public static function get_form( $filename, $form, $title, $description ) { |
|
435 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
436 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
437 | + } |
|
438 | + |
|
439 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
440 | 440 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
441 | 441 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
442 | - return; |
|
443 | - } |
|
442 | + return; |
|
443 | + } |
|
444 | 444 | |
445 | - global $frm_vars; |
|
445 | + global $frm_vars; |
|
446 | 446 | |
447 | 447 | $form = FrmForm::getOne( $form_id ); |
448 | - if ( ! $form ) { |
|
449 | - return; |
|
450 | - } |
|
448 | + if ( ! $form ) { |
|
449 | + return; |
|
450 | + } |
|
451 | 451 | |
452 | 452 | $params = FrmForm::get_params( $form ); |
453 | 453 | |
454 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
455 | - $frm_vars['form_params'] = array(); |
|
456 | - } |
|
454 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
455 | + $frm_vars['form_params'] = array(); |
|
456 | + } |
|
457 | 457 | $frm_vars['form_params'][ $form->id ] = $params; |
458 | 458 | |
459 | 459 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
460 | - return; |
|
461 | - } |
|
460 | + return; |
|
461 | + } |
|
462 | 462 | |
463 | - if ( $errors == '' && ! $ajax ) { |
|
463 | + if ( $errors == '' && ! $ajax ) { |
|
464 | 464 | $errors = FrmEntryValidate::validate( $_POST ); |
465 | - } |
|
465 | + } |
|
466 | 466 | |
467 | 467 | /** |
468 | 468 | * Use this filter to add trigger actions and add errors after |
@@ -473,39 +473,39 @@ discard block |
||
473 | 473 | |
474 | 474 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
475 | 475 | |
476 | - if ( empty( $errors ) ) { |
|
476 | + if ( empty( $errors ) ) { |
|
477 | 477 | $_POST['frm_skip_cookie'] = 1; |
478 | - if ( $params['action'] == 'create' ) { |
|
478 | + if ( $params['action'] == 'create' ) { |
|
479 | 479 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
480 | 480 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
481 | - } |
|
482 | - } |
|
481 | + } |
|
482 | + } |
|
483 | 483 | |
484 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
484 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
485 | 485 | unset( $_POST['frm_skip_cookie'] ); |
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
490 | - self::_delete_entry( $atts['id'], $form ); |
|
491 | - return $url; |
|
492 | - } |
|
493 | - |
|
494 | - //Delete entry if not redirected |
|
495 | - public static function delete_entry_after_save( $atts ) { |
|
496 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
497 | - } |
|
498 | - |
|
499 | - private static function _delete_entry( $entry_id, $form ) { |
|
500 | - if ( ! $form ) { |
|
501 | - return; |
|
502 | - } |
|
503 | - |
|
504 | - $form->options = maybe_unserialize( $form->options ); |
|
505 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
506 | - FrmEntry::destroy( $entry_id ); |
|
507 | - } |
|
508 | - } |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
490 | + self::_delete_entry( $atts['id'], $form ); |
|
491 | + return $url; |
|
492 | + } |
|
493 | + |
|
494 | + //Delete entry if not redirected |
|
495 | + public static function delete_entry_after_save( $atts ) { |
|
496 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
497 | + } |
|
498 | + |
|
499 | + private static function _delete_entry( $entry_id, $form ) { |
|
500 | + if ( ! $form ) { |
|
501 | + return; |
|
502 | + } |
|
503 | + |
|
504 | + $form->options = maybe_unserialize( $form->options ); |
|
505 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
506 | + FrmEntry::destroy( $entry_id ); |
|
507 | + } |
|
508 | + } |
|
509 | 509 | |
510 | 510 | public static function show_entry_shortcode( $atts ) { |
511 | 511 | return FrmEntryFormat::show_entry( $atts ); |
@@ -517,15 +517,15 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | public static function entry_sidebar( $entry ) { |
520 | - $data = maybe_unserialize($entry->description); |
|
521 | - $date_format = get_option('date_format'); |
|
522 | - $time_format = get_option('time_format'); |
|
520 | + $data = maybe_unserialize($entry->description); |
|
521 | + $date_format = get_option('date_format'); |
|
522 | + $time_format = get_option('time_format'); |
|
523 | 523 | if ( isset( $data['browser'] ) ) { |
524 | 524 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
525 | 525 | } |
526 | 526 | |
527 | 527 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
528 | - } |
|
528 | + } |
|
529 | 529 | |
530 | 530 | /*********************************************************************** |
531 | 531 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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,14 +107,14 @@ discard block |
||
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 ) { |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | $has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' ); |
125 | 125 | $is_post_status = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status'; |
126 | 126 | if ( $has_separate_value && ! $is_post_status ) { |
127 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
127 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
128 | 128 | } |
129 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
129 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | global $frm_vars; |
146 | 146 | //add a check so we don't create a loop |
147 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
147 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
148 | 148 | |
149 | 149 | return $check; |
150 | 150 | } |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | global $frm_vars; |
162 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
162 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
163 | 163 | return; //don't continue if there's no previous value |
164 | 164 | } |
165 | 165 | |
166 | 166 | foreach ( $meta_value as $mk => $mv ) { |
167 | 167 | //remove blank values |
168 | 168 | if ( empty( $mv ) ) { |
169 | - unset( $meta_value[ $mk ] ); |
|
169 | + unset( $meta_value[$mk] ); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - $cur_form_prefix = reset($meta_value); |
|
174 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
173 | + $cur_form_prefix = reset( $meta_value ); |
|
174 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
175 | 175 | $cur_form_prefix = $cur_form_prefix[0]; |
176 | 176 | $save = false; |
177 | 177 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $meta_value[] = $prev_hidden; |
192 | 192 | $save = true; |
193 | - unset($form_prefix); |
|
193 | + unset( $form_prefix ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | if ( $save ) { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | foreach ( $fields as $field ) { |
223 | 223 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
224 | 224 | // Can't sort on checkboxes because they are stored serialized, or post fields |
225 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
225 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | - unset($form_prefix); |
|
248 | + unset( $form_prefix ); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | return $result; |
254 | 254 | } |
255 | 255 | |
256 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
256 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
257 | 257 | $max_columns = 8; |
258 | 258 | if ( $i <= $max_columns ) { |
259 | 259 | return $result; |
260 | 260 | } |
261 | 261 | |
262 | 262 | global $frm_vars; |
263 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
264 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
263 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
264 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | $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'] ) ); |
@@ -269,23 +269,23 @@ discard block |
||
269 | 269 | $result = $frm_vars['current_form']->options['hidden_cols']; |
270 | 270 | } else { |
271 | 271 | $cols = $frm_vars['cols']; |
272 | - $cols = array_reverse($cols, true); |
|
272 | + $cols = array_reverse( $cols, true ); |
|
273 | 273 | |
274 | 274 | if ( $form_id ) { |
275 | 275 | $result[] = $form_id . '_id'; |
276 | - $i--; |
|
276 | + $i --; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | $result[] = $form_id . '_item_key'; |
280 | - $i--; |
|
280 | + $i --; |
|
281 | 281 | |
282 | 282 | foreach ( $cols as $col_key => $col ) { |
283 | 283 | if ( $i > $max_columns ) { |
284 | 284 | $result[] = $col_key; |
285 | 285 | } |
286 | 286 | //remove some columns by default |
287 | - $i--; |
|
288 | - unset($col_key, $col); |
|
287 | + $i --; |
|
288 | + unset( $col_key, $col ); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
318 | 318 | $url = add_query_arg( 'paged', $total_pages ); |
319 | 319 | if ( headers_sent() ) { |
320 | - echo FrmAppHelper::js_redirect($url); |
|
320 | + echo FrmAppHelper::js_redirect( $url ); |
|
321 | 321 | } else { |
322 | 322 | wp_redirect( esc_url_raw( $url ) ); |
323 | 323 | } |
324 | 324 | die(); |
325 | 325 | } |
326 | 326 | |
327 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
327 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
328 | 328 | $message = __( 'Your import is complete', 'formidable' ); |
329 | 329 | } |
330 | 330 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | /* Back End CRUD */ |
343 | 343 | public static function show( $id = 0 ) { |
344 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
344 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
345 | 345 | |
346 | 346 | if ( ! $id ) { |
347 | 347 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - $entry = FrmEntry::getOne($id, true); |
|
354 | + $entry = FrmEntry::getOne( $id, true ); |
|
355 | 355 | if ( ! $entry ) { |
356 | 356 | echo '<div id="form_show_entry_page" class="wrap">' . |
357 | 357 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | - $data = maybe_unserialize($entry->description); |
|
362 | + $data = maybe_unserialize( $entry->description ); |
|
363 | 363 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
364 | 364 | $data = array( 'referrer' => $data ); |
365 | 365 | } |
@@ -371,11 +371,11 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | public static function destroy() { |
374 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
374 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
375 | 375 | |
376 | 376 | $params = FrmForm::get_admin_params(); |
377 | 377 | |
378 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
378 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
379 | 379 | //unlink entry from post |
380 | 380 | global $wpdb; |
381 | 381 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | if ( ! isset( $frm_vars['form_params'] ) ) { |
455 | 455 | $frm_vars['form_params'] = array(); |
456 | 456 | } |
457 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
457 | + $frm_vars['form_params'][$form->id] = $params; |
|
458 | 458 | |
459 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
459 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
460 | 460 | return; |
461 | 461 | } |
462 | 462 | |
@@ -471,13 +471,13 @@ discard block |
||
471 | 471 | */ |
472 | 472 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
473 | 473 | |
474 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
474 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
475 | 475 | |
476 | 476 | if ( empty( $errors ) ) { |
477 | 477 | $_POST['frm_skip_cookie'] = 1; |
478 | 478 | if ( $params['action'] == 'create' ) { |
479 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
480 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
479 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
480 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | public static function entry_sidebar( $entry ) { |
520 | - $data = maybe_unserialize($entry->description); |
|
521 | - $date_format = get_option('date_format'); |
|
522 | - $time_format = get_option('time_format'); |
|
520 | + $data = maybe_unserialize( $entry->description ); |
|
521 | + $date_format = get_option( 'date_format' ); |
|
522 | + $time_format = get_option( 'time_format' ); |
|
523 | 523 | if ( isset( $data['browser'] ) ) { |
524 | 524 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
525 | 525 | } |
@@ -1,89 +1,89 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmHooksController { |
4 | - /** |
|
5 | - * Trigger plugin-wide hook loading |
|
6 | - */ |
|
7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | - |
|
10 | - $trigger_hooks = $hooks; |
|
11 | - $hooks = (array) $hooks; |
|
12 | - |
|
13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | - if ( is_admin() ) { |
|
15 | - $hooks[] = 'load_admin_hooks'; |
|
16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
17 | - $hooks[] = 'load_ajax_hooks'; |
|
18 | - $hooks[] = 'load_form_hooks'; |
|
19 | - } |
|
20 | - } |
|
21 | - |
|
22 | - if ( is_multisite() ) { |
|
23 | - $hooks[] = 'load_multisite_hooks'; |
|
24 | - } |
|
25 | - } else { |
|
26 | - // Make sure the hooks are only triggered once |
|
27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | - } |
|
29 | - unset( $trigger_hooks ); |
|
30 | - |
|
31 | - // Instansiate Controllers |
|
32 | - foreach ( $controllers as $c ) { |
|
33 | - foreach ( $hooks as $hook ) { |
|
4 | + /** |
|
5 | + * Trigger plugin-wide hook loading |
|
6 | + */ |
|
7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | + |
|
10 | + $trigger_hooks = $hooks; |
|
11 | + $hooks = (array) $hooks; |
|
12 | + |
|
13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | + if ( is_admin() ) { |
|
15 | + $hooks[] = 'load_admin_hooks'; |
|
16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
17 | + $hooks[] = 'load_ajax_hooks'; |
|
18 | + $hooks[] = 'load_form_hooks'; |
|
19 | + } |
|
20 | + } |
|
21 | + |
|
22 | + if ( is_multisite() ) { |
|
23 | + $hooks[] = 'load_multisite_hooks'; |
|
24 | + } |
|
25 | + } else { |
|
26 | + // Make sure the hooks are only triggered once |
|
27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | + } |
|
29 | + unset( $trigger_hooks ); |
|
30 | + |
|
31 | + // Instansiate Controllers |
|
32 | + foreach ( $controllers as $c ) { |
|
33 | + foreach ( $hooks as $hook ) { |
|
34 | 34 | call_user_func( array( $c, $hook ) ); |
35 | 35 | unset( $hook ); |
36 | - } |
|
36 | + } |
|
37 | 37 | unset( $c ); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - public static function trigger_load_form_hooks() { |
|
43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | - } |
|
42 | + public static function trigger_load_form_hooks() { |
|
43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public static function load_hooks() { |
47 | - if ( ! is_admin() ) { |
|
48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | - } |
|
47 | + if ( ! is_admin() ) { |
|
48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | + } |
|
50 | 50 | |
51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | 53 | |
54 | - // Entries controller |
|
55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
54 | + // Entries controller |
|
55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | 58 | |
59 | - // Form Actions Controller |
|
60 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
59 | + // Form Actions Controller |
|
60 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
61 | 61 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
62 | 62 | |
63 | - // Forms Controller |
|
64 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
63 | + // Forms Controller |
|
64 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
65 | 65 | add_action( 'init', 'FrmFormsController::front_head' ); |
66 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
67 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
68 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
66 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
67 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
68 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
69 | 69 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
70 | 70 | |
71 | 71 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
72 | 72 | |
73 | - // Form Shortcodes |
|
74 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
73 | + // Form Shortcodes |
|
74 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
75 | 75 | |
76 | - // Styles Controller |
|
77 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
78 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
79 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
80 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
81 | - } |
|
76 | + // Styles Controller |
|
77 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
78 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
79 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
80 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | public static function load_admin_hooks() { |
84 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
85 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
86 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
84 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
85 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
86 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
87 | 87 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
88 | 88 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
89 | 89 | register_activation_hook( FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::activation_install' ); |
@@ -91,119 +91,119 @@ discard block |
||
91 | 91 | // Addons Controller |
92 | 92 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
93 | 93 | |
94 | - // Entries Controller |
|
95 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
96 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
97 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
98 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
99 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
94 | + // Entries Controller |
|
95 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
96 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
97 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
98 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
99 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
100 | 100 | |
101 | - // Fields Controller |
|
102 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
101 | + // Fields Controller |
|
102 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
103 | 103 | |
104 | - // Form Actions Controller |
|
105 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
106 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
107 | - } |
|
108 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
104 | + // Form Actions Controller |
|
105 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
106 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
107 | + } |
|
108 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
109 | 109 | |
110 | - // Forms Controller |
|
111 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
112 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
110 | + // Forms Controller |
|
111 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
112 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
113 | 113 | |
114 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
115 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
114 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
115 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
116 | 116 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
117 | 117 | |
118 | - // Forms Model |
|
119 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
118 | + // Forms Model |
|
119 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
120 | 120 | |
121 | - // Settings Controller |
|
122 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
123 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
121 | + // Settings Controller |
|
122 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
123 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
124 | 124 | |
125 | - // Styles Controller |
|
126 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
127 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
125 | + // Styles Controller |
|
126 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
127 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
128 | 128 | |
129 | - // XML Controller |
|
130 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
131 | - } |
|
129 | + // XML Controller |
|
130 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | public static function load_ajax_hooks() { |
134 | 134 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
135 | 135 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
136 | 136 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
137 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
138 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
137 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
138 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
139 | 139 | |
140 | 140 | // Addons |
141 | 141 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
142 | 142 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
143 | 143 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
144 | 144 | |
145 | - // Fields Controller |
|
146 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
147 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
148 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
149 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
150 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
151 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
152 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
153 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
154 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
155 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
156 | - |
|
157 | - // Form Actions Controller |
|
158 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
159 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
160 | - |
|
161 | - // Forms Controller |
|
145 | + // Fields Controller |
|
146 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
147 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
148 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
149 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
150 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
151 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
152 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
153 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
154 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
155 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
156 | + |
|
157 | + // Form Actions Controller |
|
158 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
159 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
160 | + |
|
161 | + // Forms Controller |
|
162 | 162 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
163 | 163 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
164 | 164 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
165 | 165 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
166 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
167 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
168 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
169 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
170 | - |
|
171 | - // Styles Controller |
|
172 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
173 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
174 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
175 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
166 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
167 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
168 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
169 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
170 | + |
|
171 | + // Styles Controller |
|
172 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
173 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
174 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
175 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
176 | 176 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
177 | 177 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
178 | 178 | |
179 | - // XML Controller |
|
179 | + // XML Controller |
|
180 | 180 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
181 | 181 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
182 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
183 | - } |
|
182 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
183 | + } |
|
184 | 184 | |
185 | 185 | public static function load_form_hooks() { |
186 | - // Fields Controller |
|
187 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
188 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
189 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
190 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
186 | + // Fields Controller |
|
187 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
188 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
189 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
190 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
191 | 191 | |
192 | 192 | // Forms Controller |
193 | 193 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
194 | 194 | |
195 | - // Styles Controller |
|
196 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
197 | - } |
|
195 | + // Styles Controller |
|
196 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
197 | + } |
|
198 | 198 | |
199 | 199 | public static function load_view_hooks() { |
200 | - // Hooks go here when a view is loaded |
|
201 | - } |
|
200 | + // Hooks go here when a view is loaded |
|
201 | + } |
|
202 | 202 | |
203 | 203 | public static function load_multisite_hooks() { |
204 | 204 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
205 | 205 | |
206 | - // drop tables when mu site is deleted |
|
207 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
208 | - } |
|
206 | + // drop tables when mu site is deleted |
|
207 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
208 | + } |
|
209 | 209 | } |
@@ -196,9 +196,9 @@ |
||
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | - * Flatten multi-dimensional array for multi-file upload fields |
|
200 | - * @since 2.0.9 |
|
201 | - */ |
|
199 | + * Flatten multi-dimensional array for multi-file upload fields |
|
200 | + * @since 2.0.9 |
|
201 | + */ |
|
202 | 202 | public static function flatten_multi_file_upload( $field, &$val ) { |
203 | 203 | if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) { |
204 | 204 | $val = FrmAppHelper::array_flatten( $val ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if ( ! self::skip_field( $atts, $f ) ) { |
53 | 53 | self::fill_entry_values( $atts, $f, $values ); |
54 | 54 | } |
55 | - unset($f); |
|
55 | + unset( $f ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | self::fill_entry_user_info( $atts, $values ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'type' => $f->type, |
122 | 122 | ); |
123 | 123 | |
124 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
124 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public static function fill_entry_values( $atts, $f, array &$values ) { |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | self::prepare_field_output( $atts, $val ); |
154 | 154 | |
155 | 155 | if ( $atts['format'] != 'text' ) { |
156 | - $values[ $f->field_key ] = $val; |
|
156 | + $values[$f->field_key] = $val; |
|
157 | 157 | if ( $atts['entry'] && $f->type != 'textarea' ) { |
158 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
158 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
159 | 159 | if ( $prev_val != $val ) { |
160 | - $values[ $f->field_key . '-value' ] = $prev_val; |
|
160 | + $values[$f->field_key . '-value'] = $prev_val; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } else { |
164 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
164 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | private static function fill_missing_fields( $atts, &$values ) { |
169 | - if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) { |
|
169 | + if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) { |
|
170 | 170 | // In case include_blank is set |
171 | - $atts['entry']->metas[ $atts['field']->id ] = ''; |
|
171 | + $atts['entry']->metas[$atts['field']->id] = ''; |
|
172 | 172 | $atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) ); |
173 | 173 | self::fill_values_from_entry( $atts, $values ); |
174 | 174 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | private static function get_field_value( $atts, &$val ) { |
182 | 182 | $f = $atts['field']; |
183 | 183 | if ( $atts['entry'] ) { |
184 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
184 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
185 | 185 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); |
186 | 186 | |
187 | 187 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | - $data = self::get_entry_description_data( $atts ); |
|
255 | + $data = self::get_entry_description_data( $atts ); |
|
256 | 256 | |
257 | 257 | if ( $atts['default_email'] ) { |
258 | 258 | $atts['entry']->ip = '[ip]'; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
340 | 340 | |
341 | 341 | // see how many we have |
342 | - $i = count($matches['browser']); |
|
342 | + $i = count( $matches['browser'] ); |
|
343 | 343 | |
344 | 344 | if ( $i > 1 ) { |
345 | 345 | //we will have two since we are not using 'other' argument yet |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | self::convert_entry_to_content( $values, $atts, $content ); |
368 | 368 | |
369 | 369 | if ( 'text' == $atts['format'] ) { |
370 | - $content = implode('', $content); |
|
370 | + $content = implode( '', $content ); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | if ( $atts['clickable'] ) { |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | |
421 | 421 | // merge defaults, global settings, and shortcode options |
422 | 422 | foreach ( $default_settings as $key => $setting ) { |
423 | - if ( $atts[ $key ] != '' ) { |
|
423 | + if ( $atts[$key] != '' ) { |
|
424 | 424 | continue; |
425 | 425 | } |
426 | 426 | |
427 | - $atts[ $key ] = $setting; |
|
427 | + $atts[$key] = $setting; |
|
428 | 428 | unset( $key, $setting ); |
429 | 429 | } |
430 | 430 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'entry' => $this->entry, |
96 | 96 | 'form' => $this->form, |
97 | 97 | ); |
98 | - $to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args ); |
|
98 | + $to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args ); |
|
99 | 99 | |
100 | 100 | $this->to = array_unique( (array) $to ); |
101 | 101 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @return array |
434 | 434 | */ |
435 | 435 | private function package_header() { |
436 | - $header = array(); |
|
436 | + $header = array(); |
|
437 | 437 | |
438 | 438 | if ( ! empty( $this->cc ) ) { |
439 | 439 | $header[] = 'CC: ' . implode( ',', $this->cc ); |
@@ -546,12 +546,12 @@ discard block |
||
546 | 546 | $name = trim( str_replace( $email, '', $val ) ); |
547 | 547 | } else { |
548 | 548 | // If user enters a name without an email |
549 | - unset( $recipients[ $key ] ); |
|
549 | + unset( $recipients[$key] ); |
|
550 | 550 | continue; |
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
554 | - $recipients[ $key ] = $name . ' <' . $email . '>'; |
|
554 | + $recipients[$key] = $name . ' <' . $email . '>'; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $recipients; |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | ) ); |
669 | 669 | |
670 | 670 | // Remove phone number from to addresses |
671 | - unset( $this->to[ $key ] ); |
|
671 | + unset( $this->to[$key] ); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |