|
@@ -7,7 +7,7 @@ discard block |
|
|
block discarded – undo |
|
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
|
} |
|
@@ -25,7 +25,7 @@ discard block |
|
|
block discarded – undo |
|
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,8 +33,8 @@ discard block |
|
|
block discarded – undo |
|
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
|
/** |
|
@@ -49,31 +49,31 @@ discard block |
|
|
block discarded – undo |
|
49
|
49
|
} |
|
50
|
50
|
|
|
51
|
51
|
public static function list_form() { |
|
52
|
|
- FrmAppHelper::permission_check('frm_view_forms'); |
|
|
52
|
+ FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
53
|
53
|
|
|
54
|
54
|
$params = FrmForm::list_page_params(); |
|
55
|
|
- $errors = self::process_bulk_form_actions( array()); |
|
56
|
|
- $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
|
55
|
+ $errors = self::process_bulk_form_actions( array() ); |
|
|
56
|
+ $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
57
|
57
|
|
|
58
|
58
|
return self::display_forms_list( $params, '', $errors ); |
|
59
|
59
|
} |
|
60
|
60
|
|
|
61
|
61
|
public static function new_form( $values = array() ) { |
|
62
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
62
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
63
|
63
|
|
|
64
|
64
|
global $frm_vars; |
|
65
|
65
|
|
|
66
|
|
- $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
67
|
|
- $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
|
66
|
+ $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
|
67
|
+ $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
68
|
68
|
|
|
69
|
69
|
if ( $action == 'create' ) { |
|
70
|
|
- self::create($values); |
|
|
70
|
+ self::create( $values ); |
|
71
|
71
|
return; |
|
72
|
72
|
} else if ( $action == 'new' ) { |
|
73
|
73
|
$frm_field_selection = FrmField::field_selection(); |
|
74
|
|
- $values = FrmFormsHelper::setup_new_vars($values); |
|
|
74
|
+ $values = FrmFormsHelper::setup_new_vars( $values ); |
|
75
|
75
|
$id = FrmForm::create( $values ); |
|
76
|
|
- $form = FrmForm::getOne($id); |
|
|
76
|
+ $form = FrmForm::getOne( $id ); |
|
77
|
77
|
|
|
78
|
78
|
self::create_default_email_action( $form ); |
|
79
|
79
|
|
|
@@ -101,7 +101,7 @@ discard block |
|
|
block discarded – undo |
|
101
|
101
|
} |
|
102
|
102
|
|
|
103
|
103
|
public static function create( $values = array() ) { |
|
104
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
104
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
105
|
105
|
|
|
106
|
106
|
global $frm_vars; |
|
107
|
107
|
if ( empty( $values ) ) { |
|
@@ -113,22 +113,22 @@ discard block |
|
|
block discarded – undo |
|
113
|
113
|
$values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
114
|
114
|
} |
|
115
|
115
|
|
|
116
|
|
- $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
|
116
|
+ $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
117
|
117
|
|
|
118
|
118
|
if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
119
|
119
|
$frm_settings = FrmAppHelper::get_settings(); |
|
120
|
120
|
$errors = array( 'form' => $frm_settings->admin_permission ); |
|
121
|
121
|
} else { |
|
122
|
|
- $errors = FrmForm::validate($values); |
|
|
122
|
+ $errors = FrmForm::validate( $values ); |
|
123
|
123
|
} |
|
124
|
124
|
|
|
125
|
|
- if ( count($errors) > 0 ) { |
|
|
125
|
+ if ( count( $errors ) > 0 ) { |
|
126
|
126
|
$hide_preview = true; |
|
127
|
127
|
$frm_field_selection = FrmField::field_selection(); |
|
128
|
128
|
$form = FrmForm::getOne( $id ); |
|
129
|
|
- $fields = FrmField::get_all_for_form($id); |
|
|
129
|
+ $fields = FrmField::get_all_for_form( $id ); |
|
130
|
130
|
|
|
131
|
|
- $values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true); |
|
|
131
|
+ $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true ); |
|
132
|
132
|
$values['fields'] = $fields; |
|
133
|
133
|
$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
|
134
|
134
|
|
|
@@ -141,32 +141,32 @@ discard block |
|
|
block discarded – undo |
|
141
|
141
|
} |
|
142
|
142
|
|
|
143
|
143
|
public static function edit( $values = false ) { |
|
144
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
144
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
145
|
145
|
|
|
146
|
146
|
$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
147
|
|
- return self::get_edit_vars($id); |
|
|
147
|
+ return self::get_edit_vars( $id ); |
|
148
|
148
|
} |
|
149
|
149
|
|
|
150
|
150
|
public static function settings( $id = false, $message = '' ) { |
|
151
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
151
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
152
|
152
|
|
|
153
|
|
- if ( ! $id || ! is_numeric($id) ) { |
|
|
153
|
+ if ( ! $id || ! is_numeric( $id ) ) { |
|
154
|
154
|
$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
155
|
155
|
} |
|
156
|
156
|
return self::get_settings_vars( $id, array(), $message ); |
|
157
|
157
|
} |
|
158
|
158
|
|
|
159
|
159
|
public static function update_settings() { |
|
160
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
160
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
161
|
161
|
|
|
162
|
162
|
$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
163
|
163
|
|
|
164
|
|
- $errors = FrmForm::validate($_POST); |
|
165
|
|
- if ( count($errors) > 0 ) { |
|
166
|
|
- return self::get_settings_vars($id, $errors); |
|
|
164
|
+ $errors = FrmForm::validate( $_POST ); |
|
|
165
|
+ if ( count( $errors ) > 0 ) { |
|
|
166
|
+ return self::get_settings_vars( $id, $errors ); |
|
167
|
167
|
} |
|
168
|
168
|
|
|
169
|
|
- do_action('frm_before_update_form_settings', $id); |
|
|
169
|
+ do_action( 'frm_before_update_form_settings', $id ); |
|
170
|
170
|
|
|
171
|
171
|
FrmForm::update( $id, $_POST ); |
|
172
|
172
|
|
|
@@ -210,7 +210,7 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
* @since 2.0 |
|
211
|
211
|
*/ |
|
212
|
212
|
public static function _create_from_template() { |
|
213
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
213
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
214
|
214
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
215
|
215
|
|
|
216
|
216
|
$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
|
@@ -225,7 +225,7 @@ discard block |
|
|
block discarded – undo |
|
225
|
225
|
} |
|
226
|
226
|
|
|
227
|
227
|
public static function duplicate() { |
|
228
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
228
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
229
|
229
|
|
|
230
|
230
|
$params = FrmForm::list_page_params(); |
|
231
|
231
|
$form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
@@ -233,7 +233,7 @@ discard block |
|
|
block discarded – undo |
|
233
|
233
|
if ( $form ) { |
|
234
|
234
|
return self::get_edit_vars( $form, array(), $message, true ); |
|
235
|
235
|
} else { |
|
236
|
|
- return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
|
236
|
+ return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
237
|
237
|
} |
|
238
|
238
|
} |
|
239
|
239
|
|
|
@@ -375,11 +375,11 @@ discard block |
|
|
block discarded – undo |
|
375
|
375
|
} |
|
376
|
376
|
|
|
377
|
377
|
public static function bulk_untrash( $ids ) { |
|
378
|
|
- FrmAppHelper::permission_check('frm_edit_forms'); |
|
|
378
|
+ FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
379
|
379
|
|
|
380
|
380
|
$count = FrmForm::set_status( $ids, 'published' ); |
|
381
|
381
|
|
|
382
|
|
- $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
|
382
|
+ $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
383
|
383
|
return $message; |
|
384
|
384
|
} |
|
385
|
385
|
|
|
@@ -404,11 +404,11 @@ discard block |
|
|
block discarded – undo |
|
404
|
404
|
), |
|
405
|
405
|
); |
|
406
|
406
|
|
|
407
|
|
- if ( ! isset( $available_status[ $status ] ) ) { |
|
|
407
|
+ if ( ! isset( $available_status[$status] ) ) { |
|
408
|
408
|
return; |
|
409
|
409
|
} |
|
410
|
410
|
|
|
411
|
|
- FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
|
411
|
+ FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
412
|
412
|
|
|
413
|
413
|
$params = FrmForm::list_page_params(); |
|
414
|
414
|
|
|
@@ -416,8 +416,8 @@ discard block |
|
|
block discarded – undo |
|
416
|
416
|
check_admin_referer( $status . '_form_' . $params['id'] ); |
|
417
|
417
|
|
|
418
|
418
|
$count = 0; |
|
419
|
|
- if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
420
|
|
- $count++; |
|
|
419
|
+ if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
|
420
|
+ $count ++; |
|
421
|
421
|
} |
|
422
|
422
|
|
|
423
|
423
|
$form_type = FrmAppHelper::get_simple_request( array( |
|
@@ -425,21 +425,21 @@ discard block |
|
|
block discarded – undo |
|
425
|
425
|
'type' => 'request', |
|
426
|
426
|
) ); |
|
427
|
427
|
|
|
428
|
|
- $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
|
428
|
+ $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
429
|
429
|
$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=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
|
430
|
430
|
|
|
431
|
|
- $message = $available_status[ $status ]['message']; |
|
|
431
|
+ $message = $available_status[$status]['message']; |
|
432
|
432
|
|
|
433
|
433
|
self::display_forms_list( $params, $message ); |
|
434
|
434
|
} |
|
435
|
435
|
|
|
436
|
436
|
public static function bulk_trash( $ids ) { |
|
437
|
|
- FrmAppHelper::permission_check('frm_delete_forms'); |
|
|
437
|
+ FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
438
|
438
|
|
|
439
|
439
|
$count = 0; |
|
440
|
440
|
foreach ( $ids as $id ) { |
|
441
|
441
|
if ( FrmForm::trash( $id ) ) { |
|
442
|
|
- $count++; |
|
|
442
|
+ $count ++; |
|
443
|
443
|
} |
|
444
|
444
|
} |
|
445
|
445
|
|
|
@@ -453,49 +453,49 @@ discard block |
|
|
block discarded – undo |
|
453
|
453
|
} |
|
454
|
454
|
|
|
455
|
455
|
public static function destroy() { |
|
456
|
|
- FrmAppHelper::permission_check('frm_delete_forms'); |
|
|
456
|
+ FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
457
|
457
|
|
|
458
|
458
|
$params = FrmForm::list_page_params(); |
|
459
|
459
|
|
|
460
|
460
|
//check nonce url |
|
461
|
|
- check_admin_referer('destroy_form_' . $params['id']); |
|
|
461
|
+ check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
462
|
462
|
|
|
463
|
463
|
$count = 0; |
|
464
|
464
|
if ( FrmForm::destroy( $params['id'] ) ) { |
|
465
|
|
- $count++; |
|
|
465
|
+ $count ++; |
|
466
|
466
|
} |
|
467
|
467
|
|
|
468
|
|
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
|
468
|
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
469
|
469
|
|
|
470
|
470
|
self::display_forms_list( $params, $message ); |
|
471
|
471
|
} |
|
472
|
472
|
|
|
473
|
473
|
public static function bulk_destroy( $ids ) { |
|
474
|
|
- FrmAppHelper::permission_check('frm_delete_forms'); |
|
|
474
|
+ FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
475
|
475
|
|
|
476
|
476
|
$count = 0; |
|
477
|
477
|
foreach ( $ids as $id ) { |
|
478
|
478
|
$d = FrmForm::destroy( $id ); |
|
479
|
479
|
if ( $d ) { |
|
480
|
|
- $count++; |
|
|
480
|
+ $count ++; |
|
481
|
481
|
} |
|
482
|
482
|
} |
|
483
|
483
|
|
|
484
|
|
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
|
484
|
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
485
|
485
|
|
|
486
|
486
|
return $message; |
|
487
|
487
|
} |
|
488
|
488
|
|
|
489
|
489
|
private static function delete_all() { |
|
490
|
490
|
//check nonce url |
|
491
|
|
- $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
|
491
|
+ $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
492
|
492
|
if ( $permission_error !== false ) { |
|
493
|
493
|
self::display_forms_list( array(), '', array( $permission_error ) ); |
|
494
|
494
|
return; |
|
495
|
495
|
} |
|
496
|
496
|
|
|
497
|
497
|
$count = FrmForm::scheduled_delete( time() ); |
|
498
|
|
- $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
|
498
|
+ $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
499
|
499
|
|
|
500
|
500
|
self::display_forms_list( array(), $message ); |
|
501
|
501
|
} |
|
@@ -507,7 +507,7 @@ discard block |
|
|
block discarded – undo |
|
507
|
507
|
* @since 2.0.15 |
|
508
|
508
|
*/ |
|
509
|
509
|
public static function insert_form_button() { |
|
510
|
|
- if ( current_user_can('frm_view_forms') ) { |
|
|
510
|
+ if ( current_user_can( 'frm_view_forms' ) ) { |
|
511
|
511
|
$menu_name = FrmAppHelper::get_menu_name(); |
|
512
|
512
|
$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' ) . '"> |
|
513
|
513
|
<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
|
@@ -531,17 +531,17 @@ discard block |
|
|
block discarded – undo |
|
531
|
531
|
), |
|
532
|
532
|
); |
|
533
|
533
|
|
|
534
|
|
- $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
|
534
|
+ $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
535
|
535
|
|
|
536
|
536
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
|
537
|
537
|
} |
|
538
|
538
|
|
|
539
|
539
|
public static function get_shortcode_opts() { |
|
540
|
|
- FrmAppHelper::permission_check('frm_view_forms'); |
|
|
540
|
+ FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
541
|
541
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
542
|
542
|
|
|
543
|
543
|
$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
|
544
|
|
- if ( empty($shortcode) ) { |
|
|
544
|
+ if ( empty( $shortcode ) ) { |
|
545
|
545
|
wp_die(); |
|
546
|
546
|
} |
|
547
|
547
|
|
|
@@ -680,11 +680,11 @@ discard block |
|
|
block discarded – undo |
|
680
|
680
|
} |
|
681
|
681
|
|
|
682
|
682
|
if ( $form->parent_form_id ) { |
|
683
|
|
- 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>' )); |
|
|
683
|
+ 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>' ) ); |
|
684
|
684
|
} |
|
685
|
685
|
|
|
686
|
686
|
$frm_field_selection = FrmField::field_selection(); |
|
687
|
|
- $fields = FrmField::get_all_for_form($form->id); |
|
|
687
|
+ $fields = FrmField::get_all_for_form( $form->id ); |
|
688
|
688
|
|
|
689
|
689
|
// Automatically add end section fields if they don't exist (2.0 migration) |
|
690
|
690
|
$reset_fields = false; |
|
@@ -694,7 +694,7 @@ discard block |
|
|
block discarded – undo |
|
694
|
694
|
$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
695
|
695
|
} |
|
696
|
696
|
|
|
697
|
|
- unset($end_section_values, $last_order, $open, $reset_fields); |
|
|
697
|
+ unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
698
|
698
|
|
|
699
|
699
|
$args = array( 'parent_form_id' => $form->id ); |
|
700
|
700
|
$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
|
@@ -708,8 +708,8 @@ discard block |
|
|
block discarded – undo |
|
708
|
708
|
$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
|
709
|
709
|
|
|
710
|
710
|
if ( $form->default_template ) { |
|
711
|
|
- wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
712
|
|
- } else if ( defined('DOING_AJAX') ) { |
|
|
711
|
+ wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
|
712
|
+ } else if ( defined( 'DOING_AJAX' ) ) { |
|
713
|
713
|
wp_die(); |
|
714
|
714
|
} else if ( $create_link ) { |
|
715
|
715
|
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
|
@@ -725,21 +725,21 @@ discard block |
|
|
block discarded – undo |
|
725
|
725
|
|
|
726
|
726
|
$form = FrmForm::getOne( $id ); |
|
727
|
727
|
|
|
728
|
|
- $fields = FrmField::get_all_for_form($id); |
|
729
|
|
- $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
|
728
|
+ $fields = FrmField::get_all_for_form( $id ); |
|
|
729
|
+ $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
730
|
730
|
|
|
731
|
|
- if ( isset($values['default_template']) && $values['default_template'] ) { |
|
732
|
|
- wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
|
731
|
+ if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
|
732
|
+ wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
733
|
733
|
} |
|
734
|
734
|
|
|
735
|
735
|
self::clean_submit_html( $values ); |
|
736
|
736
|
|
|
737
|
737
|
$action_controls = FrmFormActionsController::get_form_actions(); |
|
738
|
738
|
|
|
739
|
|
- $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
|
739
|
+ $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
740
|
740
|
$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
741
|
741
|
|
|
742
|
|
- $styles = apply_filters('frm_get_style_opts', array()); |
|
|
742
|
+ $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
743
|
743
|
|
|
744
|
744
|
$first_h3 = 'frm_first_h3'; |
|
745
|
745
|
|
|
@@ -760,10 +760,10 @@ discard block |
|
|
block discarded – undo |
|
760
|
760
|
} |
|
761
|
761
|
|
|
762
|
762
|
public static function mb_tags_box( $form_id, $class = '' ) { |
|
763
|
|
- $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
|
763
|
+ $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
764
|
764
|
$linked_forms = array(); |
|
765
|
765
|
$col = 'one'; |
|
766
|
|
- $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
|
766
|
+ $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
767
|
767
|
|
|
768
|
768
|
$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
|
769
|
769
|
$adv_shortcodes = self::get_advanced_shortcodes(); |
|
@@ -838,7 +838,7 @@ discard block |
|
|
block discarded – undo |
|
838
|
838
|
* Insert the form class setting into the form |
|
839
|
839
|
*/ |
|
840
|
840
|
public static function form_classes( $form ) { |
|
841
|
|
- if ( isset($form->options['form_class']) ) { |
|
|
841
|
+ if ( isset( $form->options['form_class'] ) ) { |
|
842
|
842
|
echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
|
843
|
843
|
} |
|
844
|
844
|
|
|
@@ -946,11 +946,11 @@ discard block |
|
|
block discarded – undo |
|
946
|
946
|
public static function add_default_templates( $path, $default = true, $template = true ) { |
|
947
|
947
|
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
948
|
948
|
|
|
949
|
|
- $path = untrailingslashit(trim($path)); |
|
|
949
|
+ $path = untrailingslashit( trim( $path ) ); |
|
950
|
950
|
$templates = glob( $path . '/*.php' ); |
|
951
|
951
|
|
|
952
|
|
- for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
953
|
|
- $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
|
952
|
+ for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
|
953
|
+ $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
954
|
954
|
$template_query = array( 'form_key' => $filename ); |
|
955
|
955
|
if ( $template ) { |
|
956
|
956
|
$template_query['is_template'] = 1; |
|
@@ -968,12 +968,12 @@ discard block |
|
|
block discarded – undo |
|
968
|
968
|
$values['default_template'] = 1; |
|
969
|
969
|
} |
|
970
|
970
|
|
|
971
|
|
- include( $templates[ $i ] ); |
|
|
971
|
+ include( $templates[$i] ); |
|
972
|
972
|
|
|
973
|
973
|
//get updated form |
|
974
|
|
- if ( isset($form) && ! empty($form) ) { |
|
|
974
|
+ if ( isset( $form ) && ! empty( $form ) ) { |
|
975
|
975
|
$old_id = $form->id; |
|
976
|
|
- $form = FrmForm::getOne($form->id); |
|
|
976
|
+ $form = FrmForm::getOne( $form->id ); |
|
977
|
977
|
} else { |
|
978
|
978
|
$old_id = false; |
|
979
|
979
|
$form = FrmForm::getAll( $template_query, '', 1 ); |
|
@@ -986,24 +986,24 @@ discard block |
|
|
block discarded – undo |
|
986
|
986
|
} |
|
987
|
987
|
|
|
988
|
988
|
public static function route() { |
|
989
|
|
- $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
|
989
|
+ $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
990
|
990
|
$vars = array(); |
|
991
|
991
|
if ( isset( $_POST['frm_compact_fields'] ) ) { |
|
992
|
992
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
993
|
993
|
|
|
994
|
|
- $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
995
|
|
- $json_vars = json_decode($json_vars, true); |
|
996
|
|
- if ( empty($json_vars) ) { |
|
|
994
|
+ $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
|
995
|
+ $json_vars = json_decode( $json_vars, true ); |
|
|
996
|
+ if ( empty( $json_vars ) ) { |
|
997
|
997
|
// json decoding failed so we should return an error message |
|
998
|
998
|
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
|
999
|
999
|
if ( 'edit' == $action ) { |
|
1000
|
1000
|
$action = 'update'; |
|
1001
|
1001
|
} |
|
1002
|
1002
|
|
|
1003
|
|
- add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
|
1003
|
+ add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
1004
|
1004
|
} else { |
|
1005
|
|
- $vars = FrmAppHelper::json_to_array($json_vars); |
|
1006
|
|
- $action = $vars[ $action ]; |
|
|
1005
|
+ $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
|
1006
|
+ $action = $vars[$action]; |
|
1007
|
1007
|
unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
|
1008
|
1008
|
$_REQUEST = array_merge( $_REQUEST, $vars ); |
|
1009
|
1009
|
$_POST = array_merge( $_POST, $_REQUEST ); |
|
@@ -1021,7 +1021,7 @@ discard block |
|
|
block discarded – undo |
|
1021
|
1021
|
|
|
1022
|
1022
|
switch ( $action ) { |
|
1023
|
1023
|
case 'new': |
|
1024
|
|
- return self::new_form($vars); |
|
|
1024
|
+ return self::new_form( $vars ); |
|
1025
|
1025
|
case 'create': |
|
1026
|
1026
|
case 'edit': |
|
1027
|
1027
|
case 'update': |
|
@@ -1044,7 +1044,7 @@ discard block |
|
|
block discarded – undo |
|
1044
|
1044
|
$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
|
1045
|
1045
|
} |
|
1046
|
1046
|
|
|
1047
|
|
- if ( strpos($action, 'bulk_') === 0 ) { |
|
|
1047
|
+ if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
1048
|
1048
|
FrmAppHelper::remove_get_action(); |
|
1049
|
1049
|
return self::list_form(); |
|
1050
|
1050
|
} |
|
@@ -1071,19 +1071,19 @@ discard block |
|
|
block discarded – undo |
|
1071
|
1071
|
|
|
1072
|
1072
|
public static function admin_bar_configure() { |
|
1073
|
1073
|
global $frm_vars; |
|
1074
|
|
- if ( empty($frm_vars['forms_loaded']) ) { |
|
|
1074
|
+ if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
1075
|
1075
|
return; |
|
1076
|
1076
|
} |
|
1077
|
1077
|
|
|
1078
|
1078
|
$actions = array(); |
|
1079
|
1079
|
foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
1080
|
|
- if ( is_object($form) ) { |
|
1081
|
|
- $actions[ $form->id ] = $form->name; |
|
|
1080
|
+ if ( is_object( $form ) ) { |
|
|
1081
|
+ $actions[$form->id] = $form->name; |
|
1082
|
1082
|
} |
|
1083
|
|
- unset($form); |
|
|
1083
|
+ unset( $form ); |
|
1084
|
1084
|
} |
|
1085
|
1085
|
|
|
1086
|
|
- if ( empty($actions) ) { |
|
|
1086
|
+ if ( empty( $actions ) ) { |
|
1087
|
1087
|
return; |
|
1088
|
1088
|
} |
|
1089
|
1089
|
|
|
@@ -1129,7 +1129,7 @@ discard block |
|
|
block discarded – undo |
|
1129
|
1129
|
//formidable shortcode |
|
1130
|
1130
|
public static function get_form_shortcode( $atts ) { |
|
1131
|
1131
|
global $frm_vars; |
|
1132
|
|
- if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
|
1132
|
+ if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
1133
|
1133
|
$sc = '[formidable'; |
|
1134
|
1134
|
if ( ! empty( $atts ) ) { |
|
1135
|
1135
|
foreach ( $atts as $k => $v ) { |
|
@@ -1289,8 +1289,8 @@ discard block |
|
|
block discarded – undo |
|
1289
|
1289
|
private static function get_saved_errors( $form, $params ) { |
|
1290
|
1290
|
global $frm_vars; |
|
1291
|
1291
|
|
|
1292
|
|
- if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { |
|
1293
|
|
- $errors = $frm_vars['created_entries'][ $form->id ]['errors']; |
|
|
1292
|
+ if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) { |
|
|
1293
|
+ $errors = $frm_vars['created_entries'][$form->id]['errors']; |
|
1294
|
1294
|
} else { |
|
1295
|
1295
|
$errors = array(); |
|
1296
|
1296
|
} |
|
@@ -1302,7 +1302,7 @@ discard block |
|
|
block discarded – undo |
|
1302
|
1302
|
*/ |
|
1303
|
1303
|
public static function just_created_entry( $form_id ) { |
|
1304
|
1304
|
global $frm_vars; |
|
1305
|
|
- return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; |
|
|
1305
|
+ return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0; |
|
1306
|
1306
|
} |
|
1307
|
1307
|
|
|
1308
|
1308
|
/** |
|
@@ -1310,7 +1310,7 @@ discard block |
|
|
block discarded – undo |
|
1310
|
1310
|
*/ |
|
1311
|
1311
|
private static function get_confirmation_method( $atts ) { |
|
1312
|
1312
|
$opt = 'success_action'; |
|
1313
|
|
- $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message'; |
|
|
1313
|
+ $method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message'; |
|
1314
|
1314
|
$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' ); |
|
1315
|
1315
|
|
|
1316
|
1316
|
if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) { |
|
@@ -1323,7 +1323,7 @@ discard block |
|
|
block discarded – undo |
|
1323
|
1323
|
public static function maybe_trigger_redirect( $form, $params, $args ) { |
|
1324
|
1324
|
if ( ! isset( $params['id'] ) ) { |
|
1325
|
1325
|
global $frm_vars; |
|
1326
|
|
- $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id']; |
|
|
1326
|
+ $params['id'] = $frm_vars['created_entries'][$form->id]['entry_id']; |
|
1327
|
1327
|
} |
|
1328
|
1328
|
|
|
1329
|
1329
|
$conf_method = self::get_confirmation_method( array( |
|
@@ -1363,7 +1363,7 @@ discard block |
|
|
block discarded – undo |
|
1363
|
1363
|
|
|
1364
|
1364
|
$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit'; |
|
1365
|
1365
|
$args['success_opt'] = $opt; |
|
1366
|
|
- if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) { |
|
|
1366
|
+ if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) { |
|
1367
|
1367
|
self::load_page_after_submit( $args ); |
|
1368
|
1368
|
} elseif ( $args['conf_method'] == 'redirect' ) { |
|
1369
|
1369
|
self::redirect_after_submit( $args ); |
|
@@ -1378,8 +1378,8 @@ discard block |
|
|
block discarded – undo |
|
1378
|
1378
|
private static function load_page_after_submit( $args ) { |
|
1379
|
1379
|
global $post; |
|
1380
|
1380
|
$opt = $args['success_opt']; |
|
1381
|
|
- if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) { |
|
1382
|
|
- $page = get_post( $args['form']->options[ $opt . '_page_id' ] ); |
|
|
1381
|
+ if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) { |
|
|
1382
|
+ $page = get_post( $args['form']->options[$opt . '_page_id'] ); |
|
1383
|
1383
|
$old_post = $post; |
|
1384
|
1384
|
$post = $page; |
|
1385
|
1385
|
$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] ); |
|
@@ -1397,11 +1397,11 @@ discard block |
|
|
block discarded – undo |
|
1397
|
1397
|
add_filter( 'frm_use_wpautop', '__return_false' ); |
|
1398
|
1398
|
|
|
1399
|
1399
|
$opt = $args['success_opt']; |
|
1400
|
|
- $success_url = trim( $args['form']->options[ $opt . '_url' ] ); |
|
|
1400
|
+ $success_url = trim( $args['form']->options[$opt . '_url'] ); |
|
1401
|
1401
|
$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] ); |
|
1402
|
1402
|
$success_url = do_shortcode( $success_url ); |
|
1403
|
1403
|
|
|
1404
|
|
- $success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' ); |
|
|
1404
|
+ $success_msg = isset( $args['form']->options[$opt . '_msg'] ) ? $args['form']->options[$opt . '_msg'] : __( 'Please wait while you are redirected.', 'formidable' ); |
|
1405
|
1405
|
|
|
1406
|
1406
|
$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args ); |
|
1407
|
1407
|
|
|
@@ -1409,7 +1409,7 @@ discard block |
|
|
block discarded – undo |
|
1409
|
1409
|
FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args ); |
|
1410
|
1410
|
|
|
1411
|
1411
|
add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' ); |
|
1412
|
|
- $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args); |
|
|
1412
|
+ $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args ); |
|
1413
|
1413
|
|
|
1414
|
1414
|
$doing_ajax = FrmAppHelper::doing_ajax(); |
|
1415
|
1415
|
|
|
@@ -1435,7 +1435,7 @@ discard block |
|
|
block discarded – undo |
|
1435
|
1435
|
*/ |
|
1436
|
1436
|
private static function get_redirect_message( $success_url, $success_msg, $args ) { |
|
1437
|
1437
|
$redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' . |
|
1438
|
|
- sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>') . |
|
|
1438
|
+ sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) . |
|
1439
|
1439
|
'</div></div>'; |
|
1440
|
1440
|
|
|
1441
|
1441
|
return apply_filters( 'frm_redirect_msg', $redirect_msg, array( |
|
@@ -1669,7 +1669,7 @@ discard block |
|
|
block discarded – undo |
|
1669
|
1669
|
private static function edit_in_place_value( $field ) { |
|
1670
|
1670
|
_deprecated_function( __METHOD__, '3.0' ); |
|
1671
|
1671
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
1672
|
|
- FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
|
1672
|
+ FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
1673
|
1673
|
|
|
1674
|
1674
|
$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
|
1675
|
1675
|
$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |