@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
8 | 8 | $menu_label .= ' (Lite)'; |
9 | 9 | } |
10 | - add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
10 | + add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
11 | 11 | |
12 | 12 | self::maybe_load_listing_hooks(); |
13 | 13 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | - add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
21 | + add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
22 | 22 | |
23 | - add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
24 | - add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
23 | + add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
24 | + add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function head() { |
28 | - wp_enqueue_script('formidable-editinplace'); |
|
28 | + wp_enqueue_script( 'formidable-editinplace' ); |
|
29 | 29 | |
30 | 30 | if ( wp_is_mobile() ) { |
31 | 31 | wp_enqueue_script( 'jquery-touch-punch' ); |
@@ -33,39 +33,39 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function register_widgets() { |
36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
37 | - register_widget('FrmShowForm'); |
|
36 | + require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
37 | + register_widget( 'FrmShowForm' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public static function list_form() { |
41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
41 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
42 | 42 | |
43 | 43 | $params = FrmForm::list_page_params(); |
44 | - $errors = self::process_bulk_form_actions( array()); |
|
45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
44 | + $errors = self::process_bulk_form_actions( array() ); |
|
45 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
46 | 46 | |
47 | 47 | return self::display_forms_list( $params, '', $errors ); |
48 | 48 | } |
49 | 49 | |
50 | 50 | public static function new_form( $values = array() ) { |
51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
51 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
52 | 52 | |
53 | 53 | global $frm_vars; |
54 | 54 | |
55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
56 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
55 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
56 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
57 | 57 | |
58 | 58 | if ( $action == 'create' ) { |
59 | - return self::create($values); |
|
59 | + return self::create( $values ); |
|
60 | 60 | } else if ( $action == 'new' ) { |
61 | 61 | $frm_field_selection = FrmField::field_selection(); |
62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
62 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
63 | 63 | $id = FrmForm::create( $values ); |
64 | - $form = FrmForm::getOne($id); |
|
64 | + $form = FrmForm::getOne( $id ); |
|
65 | 65 | |
66 | 66 | // add default email notification |
67 | 67 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
68 | - $action_control->create($form->id); |
|
68 | + $action_control->create( $form->id ); |
|
69 | 69 | |
70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function create( $values = array() ) { |
78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
78 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
79 | 79 | |
80 | 80 | global $frm_vars; |
81 | 81 | if ( empty( $values ) ) { |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
88 | 88 | } |
89 | 89 | |
90 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
90 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
91 | 91 | |
92 | 92 | if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
93 | 93 | $frm_settings = FrmAppHelper::get_settings(); |
94 | 94 | $errors = array( 'form' => $frm_settings->admin_permission ); |
95 | 95 | } else { |
96 | - $errors = FrmForm::validate($values); |
|
96 | + $errors = FrmForm::validate( $values ); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( count($errors) > 0 ) { |
|
99 | + if ( count( $errors ) > 0 ) { |
|
100 | 100 | $hide_preview = true; |
101 | 101 | $frm_field_selection = FrmField::field_selection(); |
102 | 102 | $form = FrmForm::getOne( $id ); |
103 | - $fields = FrmField::get_all_for_form($id); |
|
103 | + $fields = FrmField::get_all_for_form( $id ); |
|
104 | 104 | |
105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
105 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
107 | 107 | |
108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -114,32 +114,32 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | public static function edit( $values = false ) { |
117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
117 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
118 | 118 | |
119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
120 | - return self::get_edit_vars($id); |
|
120 | + return self::get_edit_vars( $id ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function settings( $id = false, $message = '' ) { |
124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
124 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
125 | 125 | |
126 | - if ( ! $id || ! is_numeric($id) ) { |
|
126 | + if ( ! $id || ! is_numeric( $id ) ) { |
|
127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
128 | 128 | } |
129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
130 | 130 | } |
131 | 131 | |
132 | 132 | public static function update_settings() { |
133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
133 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
134 | 134 | |
135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
136 | 136 | |
137 | - $errors = FrmForm::validate($_POST); |
|
138 | - if ( count($errors) > 0 ) { |
|
139 | - return self::get_settings_vars($id, $errors); |
|
137 | + $errors = FrmForm::validate( $_POST ); |
|
138 | + if ( count( $errors ) > 0 ) { |
|
139 | + return self::get_settings_vars( $id, $errors ); |
|
140 | 140 | } |
141 | 141 | |
142 | - do_action('frm_before_update_form_settings', $id); |
|
142 | + do_action( 'frm_before_update_form_settings', $id ); |
|
143 | 143 | |
144 | 144 | FrmForm::update( $id, $_POST ); |
145 | 145 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | private static function edit_in_place_value( $field ) { |
163 | 163 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
164 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
164 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
165 | 165 | |
166 | 166 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
167 | 167 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @since 2.0 |
220 | 220 | */ |
221 | 221 | public static function _create_from_template() { |
222 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
222 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
223 | 223 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
224 | 224 | |
225 | 225 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | public static function duplicate() { |
237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
237 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
238 | 238 | |
239 | 239 | $params = FrmForm::list_page_params(); |
240 | 240 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
241 | + $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
242 | 242 | if ( $form ) { |
243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
244 | 244 | } else { |
245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
245 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | public static function bulk_untrash( $ids ) { |
308 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
308 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
309 | 309 | |
310 | 310 | $count = FrmForm::set_status( $ids, 'published' ); |
311 | 311 | |
312 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
312 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
313 | 313 | return $message; |
314 | 314 | } |
315 | 315 | |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | 'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ), |
329 | 329 | ); |
330 | 330 | |
331 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
331 | + if ( ! isset( $available_status[$status] ) ) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
335 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
336 | 336 | |
337 | 337 | $params = FrmForm::list_page_params(); |
338 | 338 | |
@@ -340,25 +340,25 @@ discard block |
||
340 | 340 | check_admin_referer( $status . '_form_' . $params['id'] ); |
341 | 341 | |
342 | 342 | $count = 0; |
343 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
344 | - $count++; |
|
343 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
344 | + $count ++; |
|
345 | 345 | } |
346 | 346 | |
347 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
347 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
348 | 348 | $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
349 | 349 | |
350 | - $message = $available_status[ $status ]['message']; |
|
350 | + $message = $available_status[$status]['message']; |
|
351 | 351 | |
352 | 352 | self::display_forms_list( $params, $message ); |
353 | 353 | } |
354 | 354 | |
355 | 355 | public static function bulk_trash( $ids ) { |
356 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
356 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
357 | 357 | |
358 | 358 | $count = 0; |
359 | 359 | foreach ( $ids as $id ) { |
360 | 360 | if ( FrmForm::trash( $id ) ) { |
361 | - $count++; |
|
361 | + $count ++; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -369,49 +369,49 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | public static function destroy() { |
372 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
372 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
373 | 373 | |
374 | 374 | $params = FrmForm::list_page_params(); |
375 | 375 | |
376 | 376 | //check nonce url |
377 | - check_admin_referer('destroy_form_' . $params['id']); |
|
377 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
378 | 378 | |
379 | 379 | $count = 0; |
380 | 380 | if ( FrmForm::destroy( $params['id'] ) ) { |
381 | - $count++; |
|
381 | + $count ++; |
|
382 | 382 | } |
383 | 383 | |
384 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
384 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
385 | 385 | |
386 | 386 | self::display_forms_list( $params, $message ); |
387 | 387 | } |
388 | 388 | |
389 | 389 | public static function bulk_destroy( $ids ) { |
390 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
390 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
391 | 391 | |
392 | 392 | $count = 0; |
393 | 393 | foreach ( $ids as $id ) { |
394 | 394 | $d = FrmForm::destroy( $id ); |
395 | 395 | if ( $d ) { |
396 | - $count++; |
|
396 | + $count ++; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
400 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
401 | 401 | |
402 | 402 | return $message; |
403 | 403 | } |
404 | 404 | |
405 | 405 | private static function delete_all() { |
406 | 406 | //check nonce url |
407 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
407 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
408 | 408 | if ( $permission_error !== false ) { |
409 | 409 | self::display_forms_list( array(), '', array( $permission_error ) ); |
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
413 | 413 | $count = FrmForm::scheduled_delete( time() ); |
414 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
414 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
415 | 415 | |
416 | 416 | self::display_forms_list( array(), $message ); |
417 | 417 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @since 2.0.15 |
429 | 429 | */ |
430 | 430 | public static function insert_form_button() { |
431 | - if ( current_user_can('frm_view_forms') ) { |
|
431 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
432 | 432 | $menu_name = FrmAppHelper::get_menu_name(); |
433 | 433 | $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"> |
434 | 434 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
@@ -449,17 +449,17 @@ discard block |
||
449 | 449 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
450 | 450 | ); |
451 | 451 | |
452 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
452 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
453 | 453 | |
454 | 454 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
455 | 455 | } |
456 | 456 | |
457 | 457 | public static function get_shortcode_opts() { |
458 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
458 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
459 | 459 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
460 | 460 | |
461 | 461 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
462 | - if ( empty($shortcode) ) { |
|
462 | + if ( empty( $shortcode ) ) { |
|
463 | 463 | wp_die(); |
464 | 464 | } |
465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | ); |
480 | 480 | break; |
481 | 481 | } |
482 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
482 | + $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
483 | 483 | |
484 | 484 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
485 | 485 | // allow other shortcodes to use the required form id option |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | if ( $form->parent_form_id ) { |
599 | - wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' )); |
|
599 | + wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $frm_field_selection = FrmField::field_selection(); |
603 | - $fields = FrmField::get_all_for_form($form->id); |
|
603 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
604 | 604 | |
605 | 605 | // Automatically add end section fields if they don't exist (2.0 migration) |
606 | 606 | $reset_fields = false; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
611 | 611 | } |
612 | 612 | |
613 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
613 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
614 | 614 | |
615 | 615 | $args = array( 'parent_form_id' => $form->id ); |
616 | 616 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
@@ -623,8 +623,8 @@ discard block |
||
623 | 623 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
624 | 624 | |
625 | 625 | if ( $form->default_template ) { |
626 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
627 | - } else if ( defined('DOING_AJAX') ) { |
|
626 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
627 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
628 | 628 | wp_die(); |
629 | 629 | } else if ( $create_link ) { |
630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -640,28 +640,28 @@ discard block |
||
640 | 640 | |
641 | 641 | $form = FrmForm::getOne( $id ); |
642 | 642 | |
643 | - $fields = FrmField::get_all_for_form($id); |
|
644 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
643 | + $fields = FrmField::get_all_for_form( $id ); |
|
644 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
645 | 645 | |
646 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
647 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
646 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
647 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | $action_controls = FrmFormActionsController::get_form_actions(); |
651 | 651 | |
652 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
652 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
653 | 653 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
654 | 654 | |
655 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
655 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
656 | 656 | |
657 | 657 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
658 | 658 | } |
659 | 659 | |
660 | 660 | public static function mb_tags_box( $form_id, $class = '' ) { |
661 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
661 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
662 | 662 | $linked_forms = array(); |
663 | 663 | $col = 'one'; |
664 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
664 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
665 | 665 | |
666 | 666 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
667 | 667 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -739,13 +739,13 @@ discard block |
||
739 | 739 | |
740 | 740 | // Insert the form class setting into the form |
741 | 741 | public static function form_classes( $form ) { |
742 | - if ( isset($form->options['form_class']) ) { |
|
742 | + if ( isset( $form->options['form_class'] ) ) { |
|
743 | 743 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
747 | 747 | public static function get_email_html() { |
748 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
748 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
749 | 749 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
750 | 750 | echo FrmEntryFormat::show_entry( array( |
751 | 751 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
@@ -842,11 +842,11 @@ discard block |
||
842 | 842 | public static function add_default_templates( $path, $default = true, $template = true ) { |
843 | 843 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
844 | 844 | |
845 | - $path = untrailingslashit(trim($path)); |
|
845 | + $path = untrailingslashit( trim( $path ) ); |
|
846 | 846 | $templates = glob( $path . '/*.php' ); |
847 | 847 | |
848 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
849 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
848 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
849 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
850 | 850 | $template_query = array( 'form_key' => $filename ); |
851 | 851 | if ( $template ) { |
852 | 852 | $template_query['is_template'] = 1; |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | $values['default_template'] = 1; |
865 | 865 | } |
866 | 866 | |
867 | - include( $templates[ $i ] ); |
|
867 | + include( $templates[$i] ); |
|
868 | 868 | |
869 | 869 | //get updated form |
870 | - if ( isset($form) && ! empty($form) ) { |
|
870 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
871 | 871 | $old_id = $form->id; |
872 | - $form = FrmForm::getOne($form->id); |
|
872 | + $form = FrmForm::getOne( $form->id ); |
|
873 | 873 | } else { |
874 | 874 | $old_id = false; |
875 | 875 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -882,24 +882,24 @@ discard block |
||
882 | 882 | } |
883 | 883 | |
884 | 884 | public static function route() { |
885 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
885 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
886 | 886 | $vars = array(); |
887 | 887 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
888 | 888 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
889 | 889 | |
890 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
891 | - $json_vars = json_decode($json_vars, true); |
|
892 | - if ( empty($json_vars) ) { |
|
890 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
891 | + $json_vars = json_decode( $json_vars, true ); |
|
892 | + if ( empty( $json_vars ) ) { |
|
893 | 893 | // json decoding failed so we should return an error message |
894 | 894 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
895 | 895 | if ( 'edit' == $action ) { |
896 | 896 | $action = 'update'; |
897 | 897 | } |
898 | 898 | |
899 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
899 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
900 | 900 | } else { |
901 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
902 | - $action = $vars[ $action ]; |
|
901 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
902 | + $action = $vars[$action]; |
|
903 | 903 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
904 | 904 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
905 | 905 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | |
918 | 918 | switch ( $action ) { |
919 | 919 | case 'new': |
920 | - return self::new_form($vars); |
|
920 | + return self::new_form( $vars ); |
|
921 | 921 | case 'create': |
922 | 922 | case 'edit': |
923 | 923 | case 'update': |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
941 | 941 | } |
942 | 942 | |
943 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
943 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
944 | 944 | FrmAppHelper::remove_get_action(); |
945 | 945 | return self::list_form(); |
946 | 946 | } |
@@ -967,27 +967,27 @@ discard block |
||
967 | 967 | |
968 | 968 | public static function admin_bar_configure() { |
969 | 969 | global $frm_vars; |
970 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
970 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
971 | 971 | return; |
972 | 972 | } |
973 | 973 | |
974 | 974 | $actions = array(); |
975 | 975 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
976 | - if ( is_object($form) ) { |
|
977 | - $actions[ $form->id ] = $form->name; |
|
976 | + if ( is_object( $form ) ) { |
|
977 | + $actions[$form->id] = $form->name; |
|
978 | 978 | } |
979 | - unset($form); |
|
979 | + unset( $form ); |
|
980 | 980 | } |
981 | 981 | |
982 | - if ( empty($actions) ) { |
|
982 | + if ( empty( $actions ) ) { |
|
983 | 983 | return; |
984 | 984 | } |
985 | 985 | |
986 | - asort($actions); |
|
986 | + asort( $actions ); |
|
987 | 987 | |
988 | 988 | global $wp_admin_bar; |
989 | 989 | |
990 | - if ( count($actions) == 1 ) { |
|
990 | + if ( count( $actions ) == 1 ) { |
|
991 | 991 | $wp_admin_bar->add_menu( array( |
992 | 992 | 'title' => 'Edit Form', |
993 | 993 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $wp_admin_bar->add_menu( array( |
1009 | 1009 | 'parent' => 'frm-forms', |
1010 | 1010 | 'id' => 'edit_form_' . $form_id, |
1011 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
1011 | + 'title' => empty( $name ) ? __( '(no title)' ) : $name, |
|
1012 | 1012 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
1013 | 1013 | ) ); |
1014 | 1014 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | //formidable shortcode |
1019 | 1019 | public static function get_form_shortcode( $atts ) { |
1020 | 1020 | global $frm_vars; |
1021 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
1021 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
1022 | 1022 | $sc = '[formidable'; |
1023 | 1023 | if ( ! empty( $atts ) ) { |
1024 | 1024 | foreach ( $atts as $k => $v ) { |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
1033 | 1033 | 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
1034 | 1034 | 'exclude_fields' => array(), 'minimize' => false, |
1035 | - ), $atts); |
|
1036 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
1035 | + ), $atts ); |
|
1036 | + do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
1037 | 1037 | |
1038 | 1038 | return self::show_form( |
1039 | 1039 | $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
@@ -1121,51 +1121,51 @@ discard block |
||
1121 | 1121 | |
1122 | 1122 | $frm_settings = FrmAppHelper::get_settings(); |
1123 | 1123 | |
1124 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1124 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1125 | 1125 | |
1126 | 1126 | $user_ID = get_current_user_id(); |
1127 | 1127 | $params = FrmForm::get_params( $form ); |
1128 | 1128 | $message = $errors = ''; |
1129 | 1129 | |
1130 | 1130 | if ( $params['posted_form_id'] == $form->id && $_POST ) { |
1131 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
1131 | + $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array(); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
1135 | 1135 | $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
1136 | 1136 | |
1137 | 1137 | if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
1138 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
1139 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
1140 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
1138 | + do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
1139 | + if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
1140 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form ); |
|
1141 | 1141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1142 | 1142 | } |
1143 | 1143 | return; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - if ( ! empty($errors) ) { |
|
1147 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
1146 | + if ( ! empty( $errors ) ) { |
|
1147 | + $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array(); |
|
1148 | 1148 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1149 | 1149 | return; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
1153 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
1152 | + do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
1153 | + if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
1154 | 1154 | return; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
1158 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
1159 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
1157 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true ); |
|
1158 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0; |
|
1159 | + $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' ); |
|
1160 | 1160 | |
1161 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
1162 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
1161 | + if ( $created && is_numeric( $created ) && $conf_method != 'message' ) { |
|
1162 | + do_action( 'frm_success_action', $conf_method, $form, $form->options, $created ); |
|
1163 | 1163 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
1164 | 1164 | return; |
1165 | 1165 | } |
1166 | 1166 | |
1167 | - if ( $created && is_numeric($created) ) { |
|
1168 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1167 | + if ( $created && is_numeric( $created ) ) { |
|
1168 | + $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1169 | 1169 | $class = 'frm_message'; |
1170 | 1170 | } else { |
1171 | 1171 | $message = $frm_settings->failed_msg; |
@@ -1176,9 +1176,9 @@ discard block |
||
1176 | 1176 | 'message' => $message, 'form' => $form, |
1177 | 1177 | 'entry_id' => $created, 'class' => $class, |
1178 | 1178 | ) ); |
1179 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
1179 | + $message = apply_filters( 'frm_main_feedback', $message, $form, $created ); |
|
1180 | 1180 | |
1181 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
1181 | + if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) { |
|
1182 | 1182 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1183 | 1183 | } else { |
1184 | 1184 | global $frm_vars; |