@@ -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,39 +184,39 @@ 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' ); |
|
| 214 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 212 | + FrmForm::update( $id, $values ); |
|
| 213 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 214 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 215 | 215 | wp_die( esc_html( $message ) ); |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | return self::get_edit_vars( $id, array(), $message ); |
| 218 | - } |
|
| 219 | - } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * Redirect to the url for creating from a template |
@@ -242,30 +242,30 @@ discard block |
||
| 242 | 242 | wp_die(); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public static function duplicate() { |
|
| 245 | + public static function duplicate() { |
|
| 246 | 246 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 247 | 247 | |
| 248 | 248 | $params = FrmForm::list_page_params(); |
| 249 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 250 | - $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 251 | - if ( $form ) { |
|
| 249 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 250 | + $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 251 | + if ( $form ) { |
|
| 252 | 252 | return self::get_edit_vars( $form, array(), $message, true ); |
| 253 | - } else { |
|
| 253 | + } else { |
|
| 254 | 254 | return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
| 255 | - } |
|
| 256 | - } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - public static function page_preview() { |
|
| 258 | + public static function page_preview() { |
|
| 259 | 259 | $params = FrmForm::list_page_params(); |
| 260 | - if ( ! $params['form'] ) { |
|
| 261 | - return; |
|
| 262 | - } |
|
| 260 | + if ( ! $params['form'] ) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 264 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 265 | 265 | if ( $form ) { |
| 266 | 266 | return self::show_form( $form->id, '', true, true ); |
| 267 | 267 | } |
| 268 | - } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @since 3.0 |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | echo self::page_preview(); // WPCS: XSS ok. |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - public static function preview() { |
|
| 278 | - do_action( 'frm_wp' ); |
|
| 277 | + public static function preview() { |
|
| 278 | + do_action( 'frm_wp' ); |
|
| 279 | 279 | |
| 280 | - global $frm_vars; |
|
| 281 | - $frm_vars['preview'] = true; |
|
| 280 | + global $frm_vars; |
|
| 281 | + $frm_vars['preview'] = true; |
|
| 282 | 282 | |
| 283 | 283 | self::load_wp(); |
| 284 | 284 | |
@@ -392,18 +392,18 @@ discard block |
||
| 392 | 392 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - public static function untrash() { |
|
| 395 | + public static function untrash() { |
|
| 396 | 396 | self::change_form_status( 'untrash' ); |
| 397 | - } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | 399 | public static function bulk_untrash( $ids ) { |
| 400 | 400 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 401 | 401 | |
| 402 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 402 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 403 | 403 | |
| 404 | 404 | $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
| 405 | - return $message; |
|
| 406 | - } |
|
| 405 | + return $message; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * @since 3.06 |
@@ -416,9 +416,9 @@ discard block |
||
| 416 | 416 | wp_die(); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public static function trash() { |
|
| 419 | + public static function trash() { |
|
| 420 | 420 | self::change_form_status( 'trash' ); |
| 421 | - } |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * @param string $status |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | public static function bulk_trash( $ids ) { |
| 472 | 472 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 473 | 473 | |
| 474 | - $count = 0; |
|
| 475 | - foreach ( $ids as $id ) { |
|
| 476 | - if ( FrmForm::trash( $id ) ) { |
|
| 477 | - $count++; |
|
| 478 | - } |
|
| 479 | - } |
|
| 474 | + $count = 0; |
|
| 475 | + foreach ( $ids as $id ) { |
|
| 476 | + if ( FrmForm::trash( $id ) ) { |
|
| 477 | + $count++; |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | 481 | $current_page = FrmAppHelper::get_simple_request( |
| 482 | 482 | array( |
@@ -491,56 +491,56 @@ discard block |
||
| 491 | 491 | '</a>' |
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | - return $message; |
|
| 495 | - } |
|
| 494 | + return $message; |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | - public static function destroy() { |
|
| 497 | + public static function destroy() { |
|
| 498 | 498 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 499 | 499 | |
| 500 | 500 | $params = FrmForm::list_page_params(); |
| 501 | 501 | |
| 502 | - //check nonce url |
|
| 502 | + //check nonce url |
|
| 503 | 503 | check_admin_referer( 'destroy_form_' . $params['id'] ); |
| 504 | 504 | |
| 505 | - $count = 0; |
|
| 506 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 507 | - $count++; |
|
| 508 | - } |
|
| 505 | + $count = 0; |
|
| 506 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 507 | + $count++; |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 511 | 511 | |
| 512 | 512 | self::display_forms_list( $params, $message ); |
| 513 | - } |
|
| 513 | + } |
|
| 514 | 514 | |
| 515 | 515 | public static function bulk_destroy( $ids ) { |
| 516 | 516 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 517 | 517 | |
| 518 | - $count = 0; |
|
| 519 | - foreach ( $ids as $id ) { |
|
| 520 | - $d = FrmForm::destroy( $id ); |
|
| 521 | - if ( $d ) { |
|
| 522 | - $count++; |
|
| 523 | - } |
|
| 524 | - } |
|
| 518 | + $count = 0; |
|
| 519 | + foreach ( $ids as $id ) { |
|
| 520 | + $d = FrmForm::destroy( $id ); |
|
| 521 | + if ( $d ) { |
|
| 522 | + $count++; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | 526 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 527 | 527 | |
| 528 | - return $message; |
|
| 529 | - } |
|
| 528 | + return $message; |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - private static function delete_all() { |
|
| 532 | - //check nonce url |
|
| 531 | + private static function delete_all() { |
|
| 532 | + //check nonce url |
|
| 533 | 533 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
| 534 | - if ( $permission_error !== false ) { |
|
| 534 | + if ( $permission_error !== false ) { |
|
| 535 | 535 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 536 | - return; |
|
| 537 | - } |
|
| 536 | + return; |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | 539 | $count = FrmForm::scheduled_delete( time() ); |
| 540 | 540 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 541 | 541 | |
| 542 | 542 | self::display_forms_list( array(), $message ); |
| 543 | - } |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | 546 | * Create a custom template from a form |
@@ -583,11 +583,11 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
| 586 | - * Inserts Formidable button |
|
| 587 | - * Hook exists since 2.5.0 |
|
| 588 | - * |
|
| 589 | - * @since 2.0.15 |
|
| 590 | - */ |
|
| 586 | + * Inserts Formidable button |
|
| 587 | + * Hook exists since 2.5.0 |
|
| 588 | + * |
|
| 589 | + * @since 2.0.15 |
|
| 590 | + */ |
|
| 591 | 591 | public static function insert_form_button() { |
| 592 | 592 | if ( current_user_can( 'frm_view_forms' ) ) { |
| 593 | 593 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -598,45 +598,45 @@ discard block |
||
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - public static function insert_form_popup() { |
|
| 601 | + public static function insert_form_popup() { |
|
| 602 | 602 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 603 | 603 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 604 | - return; |
|
| 605 | - } |
|
| 604 | + return; |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | - FrmAppHelper::load_admin_wide_js(); |
|
| 607 | + FrmAppHelper::load_admin_wide_js(); |
|
| 608 | 608 | |
| 609 | - $shortcodes = array( |
|
| 609 | + $shortcodes = array( |
|
| 610 | 610 | 'formidable' => array( |
| 611 | 611 | 'name' => __( 'Form', 'formidable' ), |
| 612 | 612 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 613 | 613 | ), |
| 614 | - ); |
|
| 614 | + ); |
|
| 615 | 615 | |
| 616 | 616 | $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
| 617 | 617 | |
| 618 | 618 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 619 | - } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | - public static function get_shortcode_opts() { |
|
| 621 | + public static function get_shortcode_opts() { |
|
| 622 | 622 | FrmAppHelper::permission_check( 'frm_view_forms' ); |
| 623 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 623 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 624 | 624 | |
| 625 | 625 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 626 | 626 | if ( empty( $shortcode ) ) { |
| 627 | - wp_die(); |
|
| 628 | - } |
|
| 627 | + wp_die(); |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | 630 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 631 | 631 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 632 | 632 | |
| 633 | - $form_id = ''; |
|
| 634 | - $opts = array(); |
|
| 633 | + $form_id = ''; |
|
| 634 | + $opts = array(); |
|
| 635 | 635 | switch ( $shortcode ) { |
| 636 | - case 'formidable': |
|
| 637 | - $opts = array( |
|
| 636 | + case 'formidable': |
|
| 637 | + $opts = array( |
|
| 638 | 638 | 'form_id' => 'id', |
| 639 | - //'key' => ', |
|
| 639 | + //'key' => ', |
|
| 640 | 640 | 'title' => array( |
| 641 | 641 | 'val' => 1, |
| 642 | 642 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | 'val' => 1, |
| 650 | 650 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 651 | 651 | ), |
| 652 | - ); |
|
| 653 | - } |
|
| 652 | + ); |
|
| 653 | + } |
|
| 654 | 654 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 655 | 655 | |
| 656 | 656 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -661,38 +661,38 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 663 | 663 | |
| 664 | - echo '</div>'; |
|
| 664 | + echo '</div>'; |
|
| 665 | 665 | |
| 666 | - wp_die(); |
|
| 667 | - } |
|
| 666 | + wp_die(); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 670 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 670 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 671 | 671 | |
| 672 | - global $wpdb, $frm_vars; |
|
| 672 | + global $wpdb, $frm_vars; |
|
| 673 | 673 | |
| 674 | 674 | if ( empty( $params ) ) { |
| 675 | 675 | $params = FrmForm::list_page_params(); |
| 676 | - } |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 678 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 679 | 679 | |
| 680 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 680 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 681 | 681 | |
| 682 | - $wp_list_table->prepare_items(); |
|
| 682 | + $wp_list_table->prepare_items(); |
|
| 683 | 683 | |
| 684 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 685 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 684 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 685 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 686 | 686 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 687 | - die(); |
|
| 688 | - } |
|
| 687 | + die(); |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | 690 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | public static function get_columns( $columns ) { |
| 694 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 695 | - $columns['id'] = 'ID'; |
|
| 694 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 695 | + $columns['id'] = 'ID'; |
|
| 696 | 696 | |
| 697 | 697 | $type = FrmAppHelper::get_simple_request( |
| 698 | 698 | array( |
@@ -702,18 +702,18 @@ discard block |
||
| 702 | 702 | ) |
| 703 | 703 | ); |
| 704 | 704 | |
| 705 | - if ( 'template' == $type ) { |
|
| 706 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 707 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 708 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 709 | - } else { |
|
| 710 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 711 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 712 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 713 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 714 | - } |
|
| 705 | + if ( 'template' == $type ) { |
|
| 706 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 707 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 708 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 709 | + } else { |
|
| 710 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 711 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 712 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 713 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 716 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 717 | 717 | |
| 718 | 718 | add_screen_option( |
| 719 | 719 | 'per_page', |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | ) |
| 725 | 725 | ); |
| 726 | 726 | |
| 727 | - return $columns; |
|
| 727 | + return $columns; |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | public static function get_sortable_columns() { |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | public static function save_per_page( $save, $option, $value ) { |
| 757 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 758 | - $save = (int) $value; |
|
| 759 | - } |
|
| 760 | - return $save; |
|
| 761 | - } |
|
| 757 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 758 | + $save = (int) $value; |
|
| 759 | + } |
|
| 760 | + return $save; |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | 763 | /** |
| 764 | 764 | * Show the template listing page |
@@ -804,27 +804,27 @@ discard block |
||
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 807 | - global $frm_vars; |
|
| 807 | + global $frm_vars; |
|
| 808 | 808 | |
| 809 | - $form = FrmForm::getOne( $id ); |
|
| 810 | - if ( ! $form ) { |
|
| 811 | - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 812 | - } |
|
| 809 | + $form = FrmForm::getOne( $id ); |
|
| 810 | + if ( ! $form ) { |
|
| 811 | + wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | - if ( $form->parent_form_id ) { |
|
| 814 | + if ( $form->parent_form_id ) { |
|
| 815 | 815 | 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>' ) ); |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | 818 | $frm_field_selection = FrmField::field_selection(); |
| 819 | 819 | $fields = FrmField::get_all_for_form( $form->id ); |
| 820 | 820 | |
| 821 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 822 | - $reset_fields = false; |
|
| 823 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 821 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 822 | + $reset_fields = false; |
|
| 823 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 824 | 824 | |
| 825 | - if ( $reset_fields ) { |
|
| 826 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 827 | - } |
|
| 825 | + if ( $reset_fields ) { |
|
| 826 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | 829 | unset( $end_section_values, $last_order, $open, $reset_fields ); |
| 830 | 830 | |
@@ -832,30 +832,30 @@ discard block |
||
| 832 | 832 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 833 | 833 | $values['fields'] = $fields; |
| 834 | 834 | |
| 835 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 836 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 837 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 838 | - } |
|
| 835 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 836 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 837 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | 840 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 841 | 841 | |
| 842 | - if ( $form->default_template ) { |
|
| 842 | + if ( $form->default_template ) { |
|
| 843 | 843 | wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) ); |
| 844 | 844 | } elseif ( defined( 'DOING_AJAX' ) ) { |
| 845 | - wp_die(); |
|
| 846 | - } else if ( $create_link ) { |
|
| 845 | + wp_die(); |
|
| 846 | + } else if ( $create_link ) { |
|
| 847 | 847 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 848 | - } else { |
|
| 848 | + } else { |
|
| 849 | 849 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 850 | - } |
|
| 851 | - } |
|
| 850 | + } |
|
| 851 | + } |
|
| 852 | 852 | |
| 853 | 853 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 854 | 854 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 855 | 855 | |
| 856 | - global $frm_vars; |
|
| 856 | + global $frm_vars; |
|
| 857 | 857 | |
| 858 | - $form = FrmForm::getOne( $id ); |
|
| 858 | + $form = FrmForm::getOne( $id ); |
|
| 859 | 859 | |
| 860 | 860 | $fields = FrmField::get_all_for_form( $id ); |
| 861 | 861 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
@@ -866,17 +866,17 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | self::clean_submit_html( $values ); |
| 868 | 868 | |
| 869 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 869 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 870 | 870 | |
| 871 | 871 | $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
| 872 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 872 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 873 | 873 | |
| 874 | 874 | $styles = apply_filters( 'frm_get_style_opts', array() ); |
| 875 | 875 | |
| 876 | 876 | $first_h3 = 'frm_first_h3'; |
| 877 | 877 | |
| 878 | 878 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 879 | - } |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | 882 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -891,10 +891,10 @@ discard block |
||
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 894 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 895 | 895 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 896 | - $linked_forms = array(); |
|
| 897 | - $col = 'one'; |
|
| 896 | + $linked_forms = array(); |
|
| 897 | + $col = 'one'; |
|
| 898 | 898 | $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
| 899 | 899 | |
| 900 | 900 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 904 | 904 | |
| 905 | 905 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 906 | - } |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | 908 | /** |
| 909 | 909 | * @since 3.04.01 |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | '' => '', |
| 998 | 998 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 999 | 999 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 1000 | - ); |
|
| 1000 | + ); |
|
| 1001 | 1001 | |
| 1002 | 1002 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 1003 | 1003 | unset( $entry_shortcodes['post_id'] ); |
@@ -1047,21 +1047,21 @@ discard block |
||
| 1047 | 1047 | wp_die(); |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 1050 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 1051 | 1051 | self::get_entry_by_param( $entry ); |
| 1052 | - if ( ! $entry ) { |
|
| 1053 | - return $content; |
|
| 1054 | - } |
|
| 1052 | + if ( ! $entry ) { |
|
| 1053 | + return $content; |
|
| 1054 | + } |
|
| 1055 | 1055 | |
| 1056 | - if ( is_object( $form ) ) { |
|
| 1057 | - $form = $form->id; |
|
| 1058 | - } |
|
| 1056 | + if ( is_object( $form ) ) { |
|
| 1057 | + $form = $form->id; |
|
| 1058 | + } |
|
| 1059 | 1059 | |
| 1060 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1061 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1060 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1061 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1062 | 1062 | |
| 1063 | - return $content; |
|
| 1064 | - } |
|
| 1063 | + return $content; |
|
| 1064 | + } |
|
| 1065 | 1065 | |
| 1066 | 1066 | private static function get_entry_by_param( &$entry ) { |
| 1067 | 1067 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -1073,153 +1073,153 @@ discard block |
||
| 1073 | 1073 | } |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1077 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1078 | - } |
|
| 1076 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1077 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1078 | + } |
|
| 1079 | 1079 | |
| 1080 | - public static function process_bulk_form_actions( $errors ) { |
|
| 1081 | - if ( ! $_REQUEST ) { |
|
| 1082 | - return $errors; |
|
| 1083 | - } |
|
| 1080 | + public static function process_bulk_form_actions( $errors ) { |
|
| 1081 | + if ( ! $_REQUEST ) { |
|
| 1082 | + return $errors; |
|
| 1083 | + } |
|
| 1084 | 1084 | |
| 1085 | 1085 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1086 | - if ( $bulkaction == -1 ) { |
|
| 1086 | + if ( $bulkaction == -1 ) { |
|
| 1087 | 1087 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1088 | - } |
|
| 1088 | + } |
|
| 1089 | 1089 | |
| 1090 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1091 | - FrmAppHelper::remove_get_action(); |
|
| 1090 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1091 | + FrmAppHelper::remove_get_action(); |
|
| 1092 | 1092 | |
| 1093 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1094 | - } |
|
| 1093 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1094 | + } |
|
| 1095 | 1095 | |
| 1096 | 1096 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 1097 | - if ( empty( $ids ) ) { |
|
| 1098 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1099 | - return $errors; |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1103 | - if ( $permission_error !== false ) { |
|
| 1104 | - $errors[] = $permission_error; |
|
| 1105 | - return $errors; |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - if ( ! is_array( $ids ) ) { |
|
| 1109 | - $ids = explode( ',', $ids ); |
|
| 1110 | - } |
|
| 1111 | - |
|
| 1112 | - switch ( $bulkaction ) { |
|
| 1113 | - case 'delete': |
|
| 1114 | - $message = self::bulk_destroy( $ids ); |
|
| 1097 | + if ( empty( $ids ) ) { |
|
| 1098 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1099 | + return $errors; |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1103 | + if ( $permission_error !== false ) { |
|
| 1104 | + $errors[] = $permission_error; |
|
| 1105 | + return $errors; |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + if ( ! is_array( $ids ) ) { |
|
| 1109 | + $ids = explode( ',', $ids ); |
|
| 1110 | + } |
|
| 1111 | + |
|
| 1112 | + switch ( $bulkaction ) { |
|
| 1113 | + case 'delete': |
|
| 1114 | + $message = self::bulk_destroy( $ids ); |
|
| 1115 | 1115 | break; |
| 1116 | - case 'trash': |
|
| 1117 | - $message = self::bulk_trash( $ids ); |
|
| 1116 | + case 'trash': |
|
| 1117 | + $message = self::bulk_trash( $ids ); |
|
| 1118 | 1118 | break; |
| 1119 | - case 'untrash': |
|
| 1120 | - $message = self::bulk_untrash( $ids ); |
|
| 1121 | - } |
|
| 1119 | + case 'untrash': |
|
| 1120 | + $message = self::bulk_untrash( $ids ); |
|
| 1121 | + } |
|
| 1122 | 1122 | |
| 1123 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1123 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1124 | 1124 | $errors['message'] = $message; |
| 1125 | - } |
|
| 1125 | + } |
|
| 1126 | 1126 | |
| 1127 | - return $errors; |
|
| 1128 | - } |
|
| 1127 | + return $errors; |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | - public static function route() { |
|
| 1130 | + public static function route() { |
|
| 1131 | 1131 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1132 | - $vars = array(); |
|
| 1132 | + $vars = array(); |
|
| 1133 | 1133 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1134 | 1134 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1135 | 1135 | |
| 1136 | 1136 | $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
| 1137 | 1137 | $json_vars = json_decode( $json_vars, true ); |
| 1138 | 1138 | if ( empty( $json_vars ) ) { |
| 1139 | - // json decoding failed so we should return an error message |
|
| 1139 | + // json decoding failed so we should return an error message |
|
| 1140 | 1140 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1141 | - if ( 'edit' == $action ) { |
|
| 1142 | - $action = 'update'; |
|
| 1143 | - } |
|
| 1141 | + if ( 'edit' == $action ) { |
|
| 1142 | + $action = 'update'; |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | 1145 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| 1146 | - } else { |
|
| 1146 | + } else { |
|
| 1147 | 1147 | $vars = FrmAppHelper::json_to_array( $json_vars ); |
| 1148 | - $action = $vars[ $action ]; |
|
| 1148 | + $action = $vars[ $action ]; |
|
| 1149 | 1149 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1150 | 1150 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1151 | 1151 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1152 | - } |
|
| 1153 | - } else { |
|
| 1152 | + } |
|
| 1153 | + } else { |
|
| 1154 | 1154 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1155 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1156 | - // override the action for this page |
|
| 1157 | - $action = 'delete_all'; |
|
| 1158 | - } |
|
| 1159 | - } |
|
| 1155 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1156 | + // override the action for this page |
|
| 1157 | + $action = 'delete_all'; |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | 1161 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1162 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1162 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1163 | 1163 | |
| 1164 | - switch ( $action ) { |
|
| 1165 | - case 'new': |
|
| 1164 | + switch ( $action ) { |
|
| 1165 | + case 'new': |
|
| 1166 | 1166 | return self::new_form( $vars ); |
| 1167 | 1167 | case 'add_new': |
| 1168 | 1168 | case 'list_templates': |
| 1169 | - case 'create': |
|
| 1170 | - case 'edit': |
|
| 1171 | - case 'update': |
|
| 1172 | - case 'duplicate': |
|
| 1173 | - case 'trash': |
|
| 1174 | - case 'untrash': |
|
| 1175 | - case 'destroy': |
|
| 1176 | - case 'delete_all': |
|
| 1177 | - case 'settings': |
|
| 1178 | - case 'update_settings': |
|
| 1169 | + case 'create': |
|
| 1170 | + case 'edit': |
|
| 1171 | + case 'update': |
|
| 1172 | + case 'duplicate': |
|
| 1173 | + case 'trash': |
|
| 1174 | + case 'untrash': |
|
| 1175 | + case 'destroy': |
|
| 1176 | + case 'delete_all': |
|
| 1177 | + case 'settings': |
|
| 1178 | + case 'update_settings': |
|
| 1179 | 1179 | return self::$action( $vars ); |
| 1180 | - default: |
|
| 1180 | + default: |
|
| 1181 | 1181 | do_action( 'frm_form_action_' . $action ); |
| 1182 | 1182 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1183 | - return; |
|
| 1184 | - } |
|
| 1183 | + return; |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | 1186 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1187 | - if ( $action == -1 ) { |
|
| 1187 | + if ( $action == -1 ) { |
|
| 1188 | 1188 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1189 | - } |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | 1191 | if ( strpos( $action, 'bulk_' ) === 0 ) { |
| 1192 | - FrmAppHelper::remove_get_action(); |
|
| 1193 | - return self::list_form(); |
|
| 1194 | - } |
|
| 1192 | + FrmAppHelper::remove_get_action(); |
|
| 1193 | + return self::list_form(); |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | - return self::display_forms_list(); |
|
| 1197 | - } |
|
| 1198 | - } |
|
| 1196 | + return self::display_forms_list(); |
|
| 1197 | + } |
|
| 1198 | + } |
|
| 1199 | 1199 | |
| 1200 | - public static function json_error( $errors ) { |
|
| 1201 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1202 | - return $errors; |
|
| 1203 | - } |
|
| 1200 | + public static function json_error( $errors ) { |
|
| 1201 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1202 | + return $errors; |
|
| 1203 | + } |
|
| 1204 | 1204 | |
| 1205 | 1205 | |
| 1206 | - /* FRONT-END FORMS */ |
|
| 1207 | - public static function admin_bar_css() { |
|
| 1206 | + /* FRONT-END FORMS */ |
|
| 1207 | + public static function admin_bar_css() { |
|
| 1208 | 1208 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1209 | - return; |
|
| 1210 | - } |
|
| 1209 | + return; |
|
| 1210 | + } |
|
| 1211 | 1211 | |
| 1212 | 1212 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1213 | 1213 | FrmAppHelper::load_font_style(); |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | public static function admin_bar_configure() { |
| 1217 | - global $frm_vars; |
|
| 1217 | + global $frm_vars; |
|
| 1218 | 1218 | if ( empty( $frm_vars['forms_loaded'] ) ) { |
| 1219 | - return; |
|
| 1220 | - } |
|
| 1219 | + return; |
|
| 1220 | + } |
|
| 1221 | 1221 | |
| 1222 | - $actions = array(); |
|
| 1222 | + $actions = array(); |
|
| 1223 | 1223 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1224 | 1224 | if ( is_object( $form ) ) { |
| 1225 | 1225 | $actions[ $form->id ] = $form->name; |
@@ -1274,18 +1274,18 @@ discard block |
||
| 1274 | 1274 | } |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | - //formidable shortcode |
|
| 1277 | + //formidable shortcode |
|
| 1278 | 1278 | public static function get_form_shortcode( $atts ) { |
| 1279 | - global $frm_vars; |
|
| 1279 | + global $frm_vars; |
|
| 1280 | 1280 | if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
| 1281 | - $sc = '[formidable'; |
|
| 1281 | + $sc = '[formidable'; |
|
| 1282 | 1282 | if ( ! empty( $atts ) ) { |
| 1283 | 1283 | foreach ( $atts as $k => $v ) { |
| 1284 | 1284 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1285 | 1285 | } |
| 1286 | 1286 | } |
| 1287 | 1287 | return $sc . ']'; |
| 1288 | - } |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | 1290 | $shortcode_atts = shortcode_atts( |
| 1291 | 1291 | array( |
@@ -1303,27 +1303,27 @@ discard block |
||
| 1303 | 1303 | ); |
| 1304 | 1304 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1305 | 1305 | |
| 1306 | - return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1307 | - } |
|
| 1306 | + return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1310 | - if ( empty( $id ) ) { |
|
| 1311 | - $id = $key; |
|
| 1312 | - } |
|
| 1309 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1310 | + if ( empty( $id ) ) { |
|
| 1311 | + $id = $key; |
|
| 1312 | + } |
|
| 1313 | 1313 | |
| 1314 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1315 | - if ( ! $form ) { |
|
| 1316 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1317 | - } |
|
| 1314 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1315 | + if ( ! $form ) { |
|
| 1316 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1317 | + } |
|
| 1318 | 1318 | |
| 1319 | 1319 | FrmAppController::maybe_update_styles(); |
| 1320 | 1320 | |
| 1321 | 1321 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1322 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1322 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1323 | 1323 | |
| 1324 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1324 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1325 | 1325 | |
| 1326 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1326 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1327 | 1327 | |
| 1328 | 1328 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1329 | 1329 | // don't show a draft form on a page |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | return $form; |
| 1349 | - } |
|
| 1349 | + } |
|
| 1350 | 1350 | |
| 1351 | 1351 | private static function maybe_get_form_to_show( $id ) { |
| 1352 | 1352 | $form = false; |
@@ -1375,21 +1375,21 @@ discard block |
||
| 1375 | 1375 | 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'] ); |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1378 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1379 | 1379 | ob_start(); |
| 1380 | 1380 | |
| 1381 | 1381 | do_action( 'frm_before_get_form', $atts ); |
| 1382 | 1382 | |
| 1383 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1383 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1384 | 1384 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1385 | 1385 | |
| 1386 | - $contents = ob_get_contents(); |
|
| 1387 | - ob_end_clean(); |
|
| 1386 | + $contents = ob_get_contents(); |
|
| 1387 | + ob_end_clean(); |
|
| 1388 | 1388 | |
| 1389 | 1389 | self::maybe_minimize_form( $atts, $contents ); |
| 1390 | 1390 | |
| 1391 | - return $contents; |
|
| 1392 | - } |
|
| 1391 | + return $contents; |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | 1394 | public static function enqueue_scripts( $params ) { |
| 1395 | 1395 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1742,10 +1742,10 @@ discard block |
||
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | public static function defer_script_loading( $tag, $handle ) { |
| 1745 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1746 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1745 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1746 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1747 | 1747 | } |
| 1748 | - return $tag; |
|
| 1748 | + return $tag; |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | public static function footer_js( $location = 'footer' ) { |