@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 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 | + } |
|
| 14 | 14 | |
| 15 | 15 | public static function maybe_load_listing_hooks() { |
| 16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function head() { |
|
| 27 | + public static function head() { |
|
| 28 | 28 | wp_enqueue_script( 'formidable-editinplace' ); |
| 29 | 29 | |
| 30 | - if ( wp_is_mobile() ) { |
|
| 31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + if ( wp_is_mobile() ) { |
|
| 31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | 36 | require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public static function new_form( $values = array() ) { |
| 76 | 76 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 77 | 77 | |
| 78 | - global $frm_vars; |
|
| 78 | + global $frm_vars; |
|
| 79 | 79 | |
| 80 | 80 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 81 | 81 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | } else if ( $action == 'new' ) { |
| 87 | 87 | $frm_field_selection = FrmField::field_selection(); |
| 88 | 88 | $values = FrmFormsHelper::setup_new_vars( $values ); |
| 89 | - $id = FrmForm::create( $values ); |
|
| 89 | + $id = FrmForm::create( $values ); |
|
| 90 | 90 | $form = FrmForm::getOne( $id ); |
| 91 | 91 | |
| 92 | 92 | self::create_default_email_action( $form ); |
| 93 | 93 | |
| 94 | 94 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 95 | 95 | |
| 96 | - $values['id'] = $id; |
|
| 96 | + $values['id'] = $id; |
|
| 97 | 97 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 98 | - } |
|
| 99 | - } |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Create the default email action |
@@ -105,41 +105,41 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param object $form |
| 107 | 107 | */ |
| 108 | - private static function create_default_email_action( $form ) { |
|
| 109 | - $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 108 | + private static function create_default_email_action( $form ) { |
|
| 109 | + $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 110 | 110 | |
| 111 | - if ( $create_email ) { |
|
| 112 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 113 | - $action_control->create( $form->id ); |
|
| 114 | - } |
|
| 115 | - } |
|
| 111 | + if ( $create_email ) { |
|
| 112 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 113 | + $action_control->create( $form->id ); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | public static function create( $values = array() ) { |
| 118 | 118 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 119 | 119 | |
| 120 | - global $frm_vars; |
|
| 121 | - if ( empty( $values ) ) { |
|
| 122 | - $values = $_POST; |
|
| 123 | - } |
|
| 120 | + global $frm_vars; |
|
| 121 | + if ( empty( $values ) ) { |
|
| 122 | + $values = $_POST; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - //Set radio button and checkbox meta equal to "other" value |
|
| 126 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 127 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 128 | - } |
|
| 125 | + //Set radio button and checkbox meta equal to "other" value |
|
| 126 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 127 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 131 | 131 | |
| 132 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 133 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 134 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 135 | - } else { |
|
| 132 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 133 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 134 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 135 | + } else { |
|
| 136 | 136 | $errors = FrmForm::validate( $values ); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | if ( count( $errors ) > 0 ) { |
| 140 | - $hide_preview = true; |
|
| 140 | + $hide_preview = true; |
|
| 141 | 141 | $frm_field_selection = FrmField::field_selection(); |
| 142 | - $form = FrmForm::getOne( $id ); |
|
| 142 | + $form = FrmForm::getOne( $id ); |
|
| 143 | 143 | $fields = FrmField::get_all_for_form( $id ); |
| 144 | 144 | |
| 145 | 145 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true ); |
@@ -147,30 +147,30 @@ discard block |
||
| 147 | 147 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 148 | 148 | |
| 149 | 149 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 150 | - } else { |
|
| 151 | - FrmForm::update( $id, $values, true ); |
|
| 150 | + } else { |
|
| 151 | + FrmForm::update( $id, $values, true ); |
|
| 152 | 152 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 153 | 153 | die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok. |
| 154 | - } |
|
| 155 | - } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public static function edit( $values = false ) { |
|
| 157 | + public static function edit( $values = false ) { |
|
| 158 | 158 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 159 | 159 | |
| 160 | 160 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 161 | 161 | return self::get_edit_vars( $id ); |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - public static function settings( $id = false, $message = '' ) { |
|
| 164 | + public static function settings( $id = false, $message = '' ) { |
|
| 165 | 165 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 166 | 166 | |
| 167 | 167 | if ( ! $id || ! is_numeric( $id ) ) { |
| 168 | 168 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | return self::get_settings_vars( $id, array(), $message ); |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public static function update_settings() { |
|
| 173 | + public static function update_settings() { |
|
| 174 | 174 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 175 | 175 | |
| 176 | 176 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
@@ -184,33 +184,33 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | FrmForm::update( $id, $_POST ); |
| 186 | 186 | |
| 187 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 187 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 188 | 188 | return self::get_settings_vars( $id, array(), $message ); |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | public static function update( $values = array() ) { |
| 192 | 192 | if ( empty( $values ) ) { |
| 193 | - $values = $_POST; |
|
| 194 | - } |
|
| 193 | + $values = $_POST; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - //Set radio button and checkbox meta equal to "other" value |
|
| 197 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 198 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 199 | - } |
|
| 196 | + //Set radio button and checkbox meta equal to "other" value |
|
| 197 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 198 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $errors = FrmForm::validate( $values ); |
|
| 202 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 203 | - if ( $permission_error !== false ) { |
|
| 204 | - $errors['form'] = $permission_error; |
|
| 205 | - } |
|
| 201 | + $errors = FrmForm::validate( $values ); |
|
| 202 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 203 | + if ( $permission_error !== false ) { |
|
| 204 | + $errors['form'] = $permission_error; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 208 | 208 | |
| 209 | 209 | if ( count( $errors ) > 0 ) { |
| 210 | - return self::get_edit_vars( $id, $errors ); |
|
| 210 | + return self::get_edit_vars( $id, $errors ); |
|
| 211 | 211 | } else { |
| 212 | - FrmForm::update( $id, $values ); |
|
| 213 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 212 | + FrmForm::update( $id, $values ); |
|
| 213 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 214 | 214 | |
| 215 | 215 | if ( self::is_too_long( $values ) ) { |
| 216 | 216 | $message .= '<br/> ' . sprintf( |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | ); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 224 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 225 | 225 | wp_die( esc_html( $message ) ); |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | return self::get_edit_vars( $id, array(), $message ); |
| 228 | - } |
|
| 229 | - } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Check if the value at the end of the form was included. |
@@ -263,30 +263,30 @@ discard block |
||
| 263 | 263 | wp_die(); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - public static function duplicate() { |
|
| 266 | + public static function duplicate() { |
|
| 267 | 267 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 268 | 268 | |
| 269 | 269 | $params = FrmForm::list_page_params(); |
| 270 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 271 | - $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 272 | - if ( $form ) { |
|
| 270 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 271 | + $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 272 | + if ( $form ) { |
|
| 273 | 273 | return self::get_edit_vars( $form, array(), $message, true ); |
| 274 | - } else { |
|
| 274 | + } else { |
|
| 275 | 275 | return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
| 276 | - } |
|
| 277 | - } |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - public static function page_preview() { |
|
| 279 | + public static function page_preview() { |
|
| 280 | 280 | $params = FrmForm::list_page_params(); |
| 281 | - if ( ! $params['form'] ) { |
|
| 282 | - return; |
|
| 283 | - } |
|
| 281 | + if ( ! $params['form'] ) { |
|
| 282 | + return; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 285 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 286 | 286 | if ( $form ) { |
| 287 | 287 | return self::show_form( $form->id, '', true, true ); |
| 288 | 288 | } |
| 289 | - } |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | 292 | * @since 3.0 |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | echo self::page_preview(); // WPCS: XSS ok. |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - public static function preview() { |
|
| 299 | - do_action( 'frm_wp' ); |
|
| 298 | + public static function preview() { |
|
| 299 | + do_action( 'frm_wp' ); |
|
| 300 | 300 | |
| 301 | - global $frm_vars; |
|
| 302 | - $frm_vars['preview'] = true; |
|
| 301 | + global $frm_vars; |
|
| 302 | + $frm_vars['preview'] = true; |
|
| 303 | 303 | |
| 304 | 304 | self::load_wp(); |
| 305 | 305 | |
@@ -413,18 +413,18 @@ discard block |
||
| 413 | 413 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - public static function untrash() { |
|
| 416 | + public static function untrash() { |
|
| 417 | 417 | self::change_form_status( 'untrash' ); |
| 418 | - } |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | public static function bulk_untrash( $ids ) { |
| 421 | 421 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 422 | 422 | |
| 423 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 423 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 424 | 424 | |
| 425 | 425 | $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
| 426 | - return $message; |
|
| 427 | - } |
|
| 426 | + return $message; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * @since 3.06 |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | wp_die(); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public static function trash() { |
|
| 440 | + public static function trash() { |
|
| 441 | 441 | self::change_form_status( 'trash' ); |
| 442 | - } |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | 444 | /** |
| 445 | 445 | * @param string $status |
@@ -492,12 +492,12 @@ discard block |
||
| 492 | 492 | public static function bulk_trash( $ids ) { |
| 493 | 493 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 494 | 494 | |
| 495 | - $count = 0; |
|
| 496 | - foreach ( $ids as $id ) { |
|
| 497 | - if ( FrmForm::trash( $id ) ) { |
|
| 498 | - $count++; |
|
| 499 | - } |
|
| 500 | - } |
|
| 495 | + $count = 0; |
|
| 496 | + foreach ( $ids as $id ) { |
|
| 497 | + if ( FrmForm::trash( $id ) ) { |
|
| 498 | + $count++; |
|
| 499 | + } |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | $current_page = FrmAppHelper::get_simple_request( |
| 503 | 503 | array( |
@@ -512,56 +512,56 @@ discard block |
||
| 512 | 512 | '</a>' |
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | - return $message; |
|
| 516 | - } |
|
| 515 | + return $message; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - public static function destroy() { |
|
| 518 | + public static function destroy() { |
|
| 519 | 519 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 520 | 520 | |
| 521 | 521 | $params = FrmForm::list_page_params(); |
| 522 | 522 | |
| 523 | - //check nonce url |
|
| 523 | + //check nonce url |
|
| 524 | 524 | check_admin_referer( 'destroy_form_' . $params['id'] ); |
| 525 | 525 | |
| 526 | - $count = 0; |
|
| 527 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 528 | - $count++; |
|
| 529 | - } |
|
| 526 | + $count = 0; |
|
| 527 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 528 | + $count++; |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | 531 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 532 | 532 | |
| 533 | 533 | self::display_forms_list( $params, $message ); |
| 534 | - } |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | 536 | public static function bulk_destroy( $ids ) { |
| 537 | 537 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 538 | 538 | |
| 539 | - $count = 0; |
|
| 540 | - foreach ( $ids as $id ) { |
|
| 541 | - $d = FrmForm::destroy( $id ); |
|
| 542 | - if ( $d ) { |
|
| 543 | - $count++; |
|
| 544 | - } |
|
| 545 | - } |
|
| 539 | + $count = 0; |
|
| 540 | + foreach ( $ids as $id ) { |
|
| 541 | + $d = FrmForm::destroy( $id ); |
|
| 542 | + if ( $d ) { |
|
| 543 | + $count++; |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 548 | 548 | |
| 549 | - return $message; |
|
| 550 | - } |
|
| 549 | + return $message; |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - private static function delete_all() { |
|
| 553 | - //check nonce url |
|
| 552 | + private static function delete_all() { |
|
| 553 | + //check nonce url |
|
| 554 | 554 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
| 555 | - if ( $permission_error !== false ) { |
|
| 555 | + if ( $permission_error !== false ) { |
|
| 556 | 556 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 557 | - return; |
|
| 558 | - } |
|
| 557 | + return; |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | 560 | $count = FrmForm::scheduled_delete( time() ); |
| 561 | 561 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 562 | 562 | |
| 563 | 563 | self::display_forms_list( array(), $message ); |
| 564 | - } |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | 567 | * Create a custom template from a form |
@@ -604,11 +604,11 @@ discard block |
||
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
| 607 | - * Inserts Formidable button |
|
| 608 | - * Hook exists since 2.5.0 |
|
| 609 | - * |
|
| 610 | - * @since 2.0.15 |
|
| 611 | - */ |
|
| 607 | + * Inserts Formidable button |
|
| 608 | + * Hook exists since 2.5.0 |
|
| 609 | + * |
|
| 610 | + * @since 2.0.15 |
|
| 611 | + */ |
|
| 612 | 612 | public static function insert_form_button() { |
| 613 | 613 | if ( current_user_can( 'frm_view_forms' ) ) { |
| 614 | 614 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -619,45 +619,45 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - public static function insert_form_popup() { |
|
| 622 | + public static function insert_form_popup() { |
|
| 623 | 623 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 624 | 624 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 625 | - return; |
|
| 626 | - } |
|
| 625 | + return; |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - FrmAppHelper::load_admin_wide_js(); |
|
| 628 | + FrmAppHelper::load_admin_wide_js(); |
|
| 629 | 629 | |
| 630 | - $shortcodes = array( |
|
| 630 | + $shortcodes = array( |
|
| 631 | 631 | 'formidable' => array( |
| 632 | 632 | 'name' => __( 'Form', 'formidable' ), |
| 633 | 633 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 634 | 634 | ), |
| 635 | - ); |
|
| 635 | + ); |
|
| 636 | 636 | |
| 637 | 637 | $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
| 638 | 638 | |
| 639 | 639 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 640 | - } |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - public static function get_shortcode_opts() { |
|
| 642 | + public static function get_shortcode_opts() { |
|
| 643 | 643 | FrmAppHelper::permission_check( 'frm_view_forms' ); |
| 644 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 644 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 645 | 645 | |
| 646 | 646 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 647 | 647 | if ( empty( $shortcode ) ) { |
| 648 | - wp_die(); |
|
| 649 | - } |
|
| 648 | + wp_die(); |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 652 | 652 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 653 | 653 | |
| 654 | - $form_id = ''; |
|
| 655 | - $opts = array(); |
|
| 654 | + $form_id = ''; |
|
| 655 | + $opts = array(); |
|
| 656 | 656 | switch ( $shortcode ) { |
| 657 | - case 'formidable': |
|
| 658 | - $opts = array( |
|
| 657 | + case 'formidable': |
|
| 658 | + $opts = array( |
|
| 659 | 659 | 'form_id' => 'id', |
| 660 | - //'key' => ', |
|
| 660 | + //'key' => ', |
|
| 661 | 661 | 'title' => array( |
| 662 | 662 | 'val' => 1, |
| 663 | 663 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -670,8 +670,8 @@ discard block |
||
| 670 | 670 | 'val' => 1, |
| 671 | 671 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 672 | 672 | ), |
| 673 | - ); |
|
| 674 | - } |
|
| 673 | + ); |
|
| 674 | + } |
|
| 675 | 675 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 676 | 676 | |
| 677 | 677 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -682,38 +682,38 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 684 | 684 | |
| 685 | - echo '</div>'; |
|
| 685 | + echo '</div>'; |
|
| 686 | 686 | |
| 687 | - wp_die(); |
|
| 688 | - } |
|
| 687 | + wp_die(); |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | 690 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 691 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 691 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 692 | 692 | |
| 693 | - global $wpdb, $frm_vars; |
|
| 693 | + global $wpdb, $frm_vars; |
|
| 694 | 694 | |
| 695 | 695 | if ( empty( $params ) ) { |
| 696 | 696 | $params = FrmForm::list_page_params(); |
| 697 | - } |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 699 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 700 | 700 | |
| 701 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 701 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 702 | 702 | |
| 703 | - $wp_list_table->prepare_items(); |
|
| 703 | + $wp_list_table->prepare_items(); |
|
| 704 | 704 | |
| 705 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 706 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 705 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 706 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 707 | 707 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 708 | - die(); |
|
| 709 | - } |
|
| 708 | + die(); |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | 711 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | public static function get_columns( $columns ) { |
| 715 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 716 | - $columns['id'] = 'ID'; |
|
| 715 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 716 | + $columns['id'] = 'ID'; |
|
| 717 | 717 | |
| 718 | 718 | $type = FrmAppHelper::get_simple_request( |
| 719 | 719 | array( |
@@ -723,18 +723,18 @@ discard block |
||
| 723 | 723 | ) |
| 724 | 724 | ); |
| 725 | 725 | |
| 726 | - if ( 'template' == $type ) { |
|
| 727 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 728 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 729 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 730 | - } else { |
|
| 731 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 732 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 733 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 734 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 735 | - } |
|
| 726 | + if ( 'template' == $type ) { |
|
| 727 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 728 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 729 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 730 | + } else { |
|
| 731 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 732 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 733 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 734 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 737 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 738 | 738 | |
| 739 | 739 | add_screen_option( |
| 740 | 740 | 'per_page', |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | ) |
| 746 | 746 | ); |
| 747 | 747 | |
| 748 | - return $columns; |
|
| 748 | + return $columns; |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | public static function get_sortable_columns() { |
@@ -775,11 +775,11 @@ discard block |
||
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | public static function save_per_page( $save, $option, $value ) { |
| 778 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 779 | - $save = (int) $value; |
|
| 780 | - } |
|
| 781 | - return $save; |
|
| 782 | - } |
|
| 778 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 779 | + $save = (int) $value; |
|
| 780 | + } |
|
| 781 | + return $save; |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | 784 | /** |
| 785 | 785 | * Show the template listing page |
@@ -834,27 +834,27 @@ discard block |
||
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 837 | - global $frm_vars; |
|
| 837 | + global $frm_vars; |
|
| 838 | 838 | |
| 839 | - $form = FrmForm::getOne( $id ); |
|
| 840 | - if ( ! $form ) { |
|
| 841 | - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 842 | - } |
|
| 839 | + $form = FrmForm::getOne( $id ); |
|
| 840 | + if ( ! $form ) { |
|
| 841 | + wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | - if ( $form->parent_form_id ) { |
|
| 844 | + if ( $form->parent_form_id ) { |
|
| 845 | 845 | wp_die( sprintf( esc_html__( '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>' ) ); |
| 846 | - } |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | 848 | $frm_field_selection = FrmField::field_selection(); |
| 849 | 849 | $fields = FrmField::get_all_for_form( $form->id ); |
| 850 | 850 | |
| 851 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 852 | - $reset_fields = false; |
|
| 853 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 851 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 852 | + $reset_fields = false; |
|
| 853 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 854 | 854 | |
| 855 | - if ( $reset_fields ) { |
|
| 856 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 857 | - } |
|
| 855 | + if ( $reset_fields ) { |
|
| 856 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 857 | + } |
|
| 858 | 858 | |
| 859 | 859 | unset( $end_section_values, $last_order, $open, $reset_fields ); |
| 860 | 860 | |
@@ -862,45 +862,45 @@ discard block |
||
| 862 | 862 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 863 | 863 | $values['fields'] = $fields; |
| 864 | 864 | |
| 865 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 866 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 867 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 868 | - } |
|
| 865 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 866 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 867 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | 870 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 871 | 871 | |
| 872 | 872 | if ( defined( 'DOING_AJAX' ) ) { |
| 873 | - wp_die(); |
|
| 874 | - } else if ( $create_link ) { |
|
| 873 | + wp_die(); |
|
| 874 | + } else if ( $create_link ) { |
|
| 875 | 875 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 876 | - } else { |
|
| 876 | + } else { |
|
| 877 | 877 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 878 | - } |
|
| 879 | - } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | 881 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 882 | 882 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 883 | 883 | |
| 884 | - global $frm_vars; |
|
| 884 | + global $frm_vars; |
|
| 885 | 885 | |
| 886 | - $form = FrmForm::getOne( $id ); |
|
| 886 | + $form = FrmForm::getOne( $id ); |
|
| 887 | 887 | |
| 888 | 888 | $fields = FrmField::get_all_for_form( $id ); |
| 889 | 889 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
| 890 | 890 | |
| 891 | 891 | self::clean_submit_html( $values ); |
| 892 | 892 | |
| 893 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 893 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 894 | 894 | |
| 895 | 895 | $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
| 896 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 896 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 897 | 897 | |
| 898 | 898 | $styles = apply_filters( 'frm_get_style_opts', array() ); |
| 899 | 899 | |
| 900 | 900 | $first_h3 = 'frm_first_h3'; |
| 901 | 901 | |
| 902 | 902 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 903 | - } |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | 905 | /** |
| 906 | 906 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -915,10 +915,10 @@ discard block |
||
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 918 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 919 | 919 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 920 | - $linked_forms = array(); |
|
| 921 | - $col = 'one'; |
|
| 920 | + $linked_forms = array(); |
|
| 921 | + $col = 'one'; |
|
| 922 | 922 | $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
| 923 | 923 | |
| 924 | 924 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 928 | 928 | |
| 929 | 929 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 930 | - } |
|
| 930 | + } |
|
| 931 | 931 | |
| 932 | 932 | /** |
| 933 | 933 | * @since 3.04.01 |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | '' => '', |
| 1022 | 1022 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 1023 | 1023 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 1024 | - ); |
|
| 1024 | + ); |
|
| 1025 | 1025 | |
| 1026 | 1026 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 1027 | 1027 | unset( $entry_shortcodes['post_id'] ); |
@@ -1071,21 +1071,21 @@ discard block |
||
| 1071 | 1071 | wp_die(); |
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 1074 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 1075 | 1075 | self::get_entry_by_param( $entry ); |
| 1076 | - if ( ! $entry ) { |
|
| 1077 | - return $content; |
|
| 1078 | - } |
|
| 1076 | + if ( ! $entry ) { |
|
| 1077 | + return $content; |
|
| 1078 | + } |
|
| 1079 | 1079 | |
| 1080 | - if ( is_object( $form ) ) { |
|
| 1081 | - $form = $form->id; |
|
| 1082 | - } |
|
| 1080 | + if ( is_object( $form ) ) { |
|
| 1081 | + $form = $form->id; |
|
| 1082 | + } |
|
| 1083 | 1083 | |
| 1084 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1085 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1084 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1085 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1086 | 1086 | |
| 1087 | - return $content; |
|
| 1088 | - } |
|
| 1087 | + return $content; |
|
| 1088 | + } |
|
| 1089 | 1089 | |
| 1090 | 1090 | private static function get_entry_by_param( &$entry ) { |
| 1091 | 1091 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -1097,153 +1097,153 @@ discard block |
||
| 1097 | 1097 | } |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1101 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1102 | - } |
|
| 1100 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1101 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1102 | + } |
|
| 1103 | 1103 | |
| 1104 | - public static function process_bulk_form_actions( $errors ) { |
|
| 1105 | - if ( ! $_REQUEST ) { |
|
| 1106 | - return $errors; |
|
| 1107 | - } |
|
| 1104 | + public static function process_bulk_form_actions( $errors ) { |
|
| 1105 | + if ( ! $_REQUEST ) { |
|
| 1106 | + return $errors; |
|
| 1107 | + } |
|
| 1108 | 1108 | |
| 1109 | 1109 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1110 | - if ( $bulkaction == -1 ) { |
|
| 1110 | + if ( $bulkaction == -1 ) { |
|
| 1111 | 1111 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1112 | - } |
|
| 1112 | + } |
|
| 1113 | 1113 | |
| 1114 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1115 | - FrmAppHelper::remove_get_action(); |
|
| 1114 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1115 | + FrmAppHelper::remove_get_action(); |
|
| 1116 | 1116 | |
| 1117 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1118 | - } |
|
| 1117 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1118 | + } |
|
| 1119 | 1119 | |
| 1120 | 1120 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 1121 | - if ( empty( $ids ) ) { |
|
| 1122 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1123 | - return $errors; |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1127 | - if ( $permission_error !== false ) { |
|
| 1128 | - $errors[] = $permission_error; |
|
| 1129 | - return $errors; |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - if ( ! is_array( $ids ) ) { |
|
| 1133 | - $ids = explode( ',', $ids ); |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - switch ( $bulkaction ) { |
|
| 1137 | - case 'delete': |
|
| 1138 | - $message = self::bulk_destroy( $ids ); |
|
| 1121 | + if ( empty( $ids ) ) { |
|
| 1122 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1123 | + return $errors; |
|
| 1124 | + } |
|
| 1125 | + |
|
| 1126 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1127 | + if ( $permission_error !== false ) { |
|
| 1128 | + $errors[] = $permission_error; |
|
| 1129 | + return $errors; |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + if ( ! is_array( $ids ) ) { |
|
| 1133 | + $ids = explode( ',', $ids ); |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + switch ( $bulkaction ) { |
|
| 1137 | + case 'delete': |
|
| 1138 | + $message = self::bulk_destroy( $ids ); |
|
| 1139 | 1139 | break; |
| 1140 | - case 'trash': |
|
| 1141 | - $message = self::bulk_trash( $ids ); |
|
| 1140 | + case 'trash': |
|
| 1141 | + $message = self::bulk_trash( $ids ); |
|
| 1142 | 1142 | break; |
| 1143 | - case 'untrash': |
|
| 1144 | - $message = self::bulk_untrash( $ids ); |
|
| 1145 | - } |
|
| 1143 | + case 'untrash': |
|
| 1144 | + $message = self::bulk_untrash( $ids ); |
|
| 1145 | + } |
|
| 1146 | 1146 | |
| 1147 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1147 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1148 | 1148 | $errors['message'] = $message; |
| 1149 | - } |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - return $errors; |
|
| 1152 | - } |
|
| 1151 | + return $errors; |
|
| 1152 | + } |
|
| 1153 | 1153 | |
| 1154 | - public static function route() { |
|
| 1154 | + public static function route() { |
|
| 1155 | 1155 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1156 | - $vars = array(); |
|
| 1156 | + $vars = array(); |
|
| 1157 | 1157 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1158 | 1158 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1159 | 1159 | |
| 1160 | 1160 | $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
| 1161 | 1161 | $json_vars = json_decode( $json_vars, true ); |
| 1162 | 1162 | if ( empty( $json_vars ) ) { |
| 1163 | - // json decoding failed so we should return an error message |
|
| 1163 | + // json decoding failed so we should return an error message |
|
| 1164 | 1164 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1165 | - if ( 'edit' == $action ) { |
|
| 1166 | - $action = 'update'; |
|
| 1167 | - } |
|
| 1165 | + if ( 'edit' == $action ) { |
|
| 1166 | + $action = 'update'; |
|
| 1167 | + } |
|
| 1168 | 1168 | |
| 1169 | 1169 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| 1170 | - } else { |
|
| 1170 | + } else { |
|
| 1171 | 1171 | $vars = FrmAppHelper::json_to_array( $json_vars ); |
| 1172 | - $action = $vars[ $action ]; |
|
| 1172 | + $action = $vars[ $action ]; |
|
| 1173 | 1173 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1174 | 1174 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1175 | 1175 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1176 | - } |
|
| 1177 | - } else { |
|
| 1176 | + } |
|
| 1177 | + } else { |
|
| 1178 | 1178 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1179 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1180 | - // override the action for this page |
|
| 1181 | - $action = 'delete_all'; |
|
| 1182 | - } |
|
| 1183 | - } |
|
| 1179 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1180 | + // override the action for this page |
|
| 1181 | + $action = 'delete_all'; |
|
| 1182 | + } |
|
| 1183 | + } |
|
| 1184 | 1184 | |
| 1185 | 1185 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1186 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1186 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1187 | 1187 | |
| 1188 | - switch ( $action ) { |
|
| 1189 | - case 'new': |
|
| 1188 | + switch ( $action ) { |
|
| 1189 | + case 'new': |
|
| 1190 | 1190 | return self::new_form( $vars ); |
| 1191 | 1191 | case 'add_new': |
| 1192 | 1192 | case 'list_templates': |
| 1193 | - case 'create': |
|
| 1194 | - case 'edit': |
|
| 1195 | - case 'update': |
|
| 1196 | - case 'duplicate': |
|
| 1197 | - case 'trash': |
|
| 1198 | - case 'untrash': |
|
| 1199 | - case 'destroy': |
|
| 1200 | - case 'delete_all': |
|
| 1201 | - case 'settings': |
|
| 1202 | - case 'update_settings': |
|
| 1193 | + case 'create': |
|
| 1194 | + case 'edit': |
|
| 1195 | + case 'update': |
|
| 1196 | + case 'duplicate': |
|
| 1197 | + case 'trash': |
|
| 1198 | + case 'untrash': |
|
| 1199 | + case 'destroy': |
|
| 1200 | + case 'delete_all': |
|
| 1201 | + case 'settings': |
|
| 1202 | + case 'update_settings': |
|
| 1203 | 1203 | return self::$action( $vars ); |
| 1204 | - default: |
|
| 1204 | + default: |
|
| 1205 | 1205 | do_action( 'frm_form_action_' . $action ); |
| 1206 | 1206 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1207 | - return; |
|
| 1208 | - } |
|
| 1207 | + return; |
|
| 1208 | + } |
|
| 1209 | 1209 | |
| 1210 | 1210 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1211 | - if ( $action == -1 ) { |
|
| 1211 | + if ( $action == -1 ) { |
|
| 1212 | 1212 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1213 | - } |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | 1215 | if ( strpos( $action, 'bulk_' ) === 0 ) { |
| 1216 | - FrmAppHelper::remove_get_action(); |
|
| 1217 | - return self::list_form(); |
|
| 1218 | - } |
|
| 1216 | + FrmAppHelper::remove_get_action(); |
|
| 1217 | + return self::list_form(); |
|
| 1218 | + } |
|
| 1219 | 1219 | |
| 1220 | - return self::display_forms_list(); |
|
| 1221 | - } |
|
| 1222 | - } |
|
| 1220 | + return self::display_forms_list(); |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1223 | 1223 | |
| 1224 | - public static function json_error( $errors ) { |
|
| 1225 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1226 | - return $errors; |
|
| 1227 | - } |
|
| 1224 | + public static function json_error( $errors ) { |
|
| 1225 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1226 | + return $errors; |
|
| 1227 | + } |
|
| 1228 | 1228 | |
| 1229 | 1229 | |
| 1230 | - /* FRONT-END FORMS */ |
|
| 1231 | - public static function admin_bar_css() { |
|
| 1230 | + /* FRONT-END FORMS */ |
|
| 1231 | + public static function admin_bar_css() { |
|
| 1232 | 1232 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1233 | - return; |
|
| 1234 | - } |
|
| 1233 | + return; |
|
| 1234 | + } |
|
| 1235 | 1235 | |
| 1236 | 1236 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1237 | 1237 | FrmAppHelper::load_font_style(); |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | public static function admin_bar_configure() { |
| 1241 | - global $frm_vars; |
|
| 1241 | + global $frm_vars; |
|
| 1242 | 1242 | if ( empty( $frm_vars['forms_loaded'] ) ) { |
| 1243 | - return; |
|
| 1244 | - } |
|
| 1243 | + return; |
|
| 1244 | + } |
|
| 1245 | 1245 | |
| 1246 | - $actions = array(); |
|
| 1246 | + $actions = array(); |
|
| 1247 | 1247 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1248 | 1248 | if ( is_object( $form ) ) { |
| 1249 | 1249 | $actions[ $form->id ] = $form->name; |
@@ -1298,18 +1298,18 @@ discard block |
||
| 1298 | 1298 | } |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | - //formidable shortcode |
|
| 1301 | + //formidable shortcode |
|
| 1302 | 1302 | public static function get_form_shortcode( $atts ) { |
| 1303 | - global $frm_vars; |
|
| 1303 | + global $frm_vars; |
|
| 1304 | 1304 | if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
| 1305 | - $sc = '[formidable'; |
|
| 1305 | + $sc = '[formidable'; |
|
| 1306 | 1306 | if ( ! empty( $atts ) ) { |
| 1307 | 1307 | foreach ( $atts as $k => $v ) { |
| 1308 | 1308 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1309 | 1309 | } |
| 1310 | 1310 | } |
| 1311 | 1311 | return $sc . ']'; |
| 1312 | - } |
|
| 1312 | + } |
|
| 1313 | 1313 | |
| 1314 | 1314 | $shortcode_atts = shortcode_atts( |
| 1315 | 1315 | array( |
@@ -1327,27 +1327,27 @@ discard block |
||
| 1327 | 1327 | ); |
| 1328 | 1328 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1329 | 1329 | |
| 1330 | - return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1331 | - } |
|
| 1330 | + return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1331 | + } |
|
| 1332 | 1332 | |
| 1333 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1334 | - if ( empty( $id ) ) { |
|
| 1335 | - $id = $key; |
|
| 1336 | - } |
|
| 1333 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1334 | + if ( empty( $id ) ) { |
|
| 1335 | + $id = $key; |
|
| 1336 | + } |
|
| 1337 | 1337 | |
| 1338 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1339 | - if ( ! $form ) { |
|
| 1340 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1341 | - } |
|
| 1338 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1339 | + if ( ! $form ) { |
|
| 1340 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1341 | + } |
|
| 1342 | 1342 | |
| 1343 | 1343 | FrmAppController::maybe_update_styles(); |
| 1344 | 1344 | |
| 1345 | 1345 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1346 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1346 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1347 | 1347 | |
| 1348 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1348 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1349 | 1349 | |
| 1350 | - $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); |
|
| 1350 | + $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); |
|
| 1351 | 1351 | |
| 1352 | 1352 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1353 | 1353 | // don't show a draft form on a page |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | return $form; |
| 1373 | - } |
|
| 1373 | + } |
|
| 1374 | 1374 | |
| 1375 | 1375 | private static function maybe_get_form_to_show( $id ) { |
| 1376 | 1376 | $form = false; |
@@ -1399,21 +1399,21 @@ discard block |
||
| 1399 | 1399 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1402 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1403 | 1403 | ob_start(); |
| 1404 | 1404 | |
| 1405 | 1405 | do_action( 'frm_before_get_form', $atts ); |
| 1406 | 1406 | |
| 1407 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1407 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1408 | 1408 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1409 | 1409 | |
| 1410 | - $contents = ob_get_contents(); |
|
| 1411 | - ob_end_clean(); |
|
| 1410 | + $contents = ob_get_contents(); |
|
| 1411 | + ob_end_clean(); |
|
| 1412 | 1412 | |
| 1413 | 1413 | self::maybe_minimize_form( $atts, $contents ); |
| 1414 | 1414 | |
| 1415 | - return $contents; |
|
| 1416 | - } |
|
| 1415 | + return $contents; |
|
| 1416 | + } |
|
| 1417 | 1417 | |
| 1418 | 1418 | public static function enqueue_scripts( $params ) { |
| 1419 | 1419 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1766,10 +1766,10 @@ discard block |
||
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | public static function defer_script_loading( $tag, $handle ) { |
| 1769 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1770 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1769 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1770 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1771 | 1771 | } |
| 1772 | - return $tag; |
|
| 1772 | + return $tag; |
|
| 1773 | 1773 | } |
| 1774 | 1774 | |
| 1775 | 1775 | public static function footer_js( $location = 'footer' ) { |