@@ -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,45 +832,45 @@ 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 | 842 | if ( defined( 'DOING_AJAX' ) ) { |
| 843 | - wp_die(); |
|
| 844 | - } else if ( $create_link ) { |
|
| 843 | + wp_die(); |
|
| 844 | + } else if ( $create_link ) { |
|
| 845 | 845 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 846 | - } else { |
|
| 846 | + } else { |
|
| 847 | 847 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 848 | - } |
|
| 849 | - } |
|
| 848 | + } |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | 851 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 852 | 852 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 853 | 853 | |
| 854 | - global $frm_vars; |
|
| 854 | + global $frm_vars; |
|
| 855 | 855 | |
| 856 | - $form = FrmForm::getOne( $id ); |
|
| 856 | + $form = FrmForm::getOne( $id ); |
|
| 857 | 857 | |
| 858 | 858 | $fields = FrmField::get_all_for_form( $id ); |
| 859 | 859 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
| 860 | 860 | |
| 861 | 861 | self::clean_submit_html( $values ); |
| 862 | 862 | |
| 863 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 863 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 864 | 864 | |
| 865 | 865 | $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
| 866 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 866 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 867 | 867 | |
| 868 | 868 | $styles = apply_filters( 'frm_get_style_opts', array() ); |
| 869 | 869 | |
| 870 | 870 | $first_h3 = 'frm_first_h3'; |
| 871 | 871 | |
| 872 | 872 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 873 | - } |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | 875 | /** |
| 876 | 876 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -885,10 +885,10 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 888 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 889 | 889 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 890 | - $linked_forms = array(); |
|
| 891 | - $col = 'one'; |
|
| 890 | + $linked_forms = array(); |
|
| 891 | + $col = 'one'; |
|
| 892 | 892 | $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
| 893 | 893 | |
| 894 | 894 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 898 | 898 | |
| 899 | 899 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 900 | - } |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | 902 | /** |
| 903 | 903 | * @since 3.04.01 |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | '' => '', |
| 992 | 992 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 993 | 993 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 994 | - ); |
|
| 994 | + ); |
|
| 995 | 995 | |
| 996 | 996 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 997 | 997 | unset( $entry_shortcodes['post_id'] ); |
@@ -1041,21 +1041,21 @@ discard block |
||
| 1041 | 1041 | wp_die(); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 1044 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 1045 | 1045 | self::get_entry_by_param( $entry ); |
| 1046 | - if ( ! $entry ) { |
|
| 1047 | - return $content; |
|
| 1048 | - } |
|
| 1046 | + if ( ! $entry ) { |
|
| 1047 | + return $content; |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - if ( is_object( $form ) ) { |
|
| 1051 | - $form = $form->id; |
|
| 1052 | - } |
|
| 1050 | + if ( is_object( $form ) ) { |
|
| 1051 | + $form = $form->id; |
|
| 1052 | + } |
|
| 1053 | 1053 | |
| 1054 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1055 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1054 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1055 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1056 | 1056 | |
| 1057 | - return $content; |
|
| 1058 | - } |
|
| 1057 | + return $content; |
|
| 1058 | + } |
|
| 1059 | 1059 | |
| 1060 | 1060 | private static function get_entry_by_param( &$entry ) { |
| 1061 | 1061 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -1067,153 +1067,153 @@ discard block |
||
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1071 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1072 | - } |
|
| 1070 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1071 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1072 | + } |
|
| 1073 | 1073 | |
| 1074 | - public static function process_bulk_form_actions( $errors ) { |
|
| 1075 | - if ( ! $_REQUEST ) { |
|
| 1076 | - return $errors; |
|
| 1077 | - } |
|
| 1074 | + public static function process_bulk_form_actions( $errors ) { |
|
| 1075 | + if ( ! $_REQUEST ) { |
|
| 1076 | + return $errors; |
|
| 1077 | + } |
|
| 1078 | 1078 | |
| 1079 | 1079 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1080 | - if ( $bulkaction == -1 ) { |
|
| 1080 | + if ( $bulkaction == -1 ) { |
|
| 1081 | 1081 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1082 | - } |
|
| 1082 | + } |
|
| 1083 | 1083 | |
| 1084 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1085 | - FrmAppHelper::remove_get_action(); |
|
| 1084 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1085 | + FrmAppHelper::remove_get_action(); |
|
| 1086 | 1086 | |
| 1087 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1088 | - } |
|
| 1087 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1088 | + } |
|
| 1089 | 1089 | |
| 1090 | 1090 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 1091 | - if ( empty( $ids ) ) { |
|
| 1092 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1093 | - return $errors; |
|
| 1094 | - } |
|
| 1095 | - |
|
| 1096 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1097 | - if ( $permission_error !== false ) { |
|
| 1098 | - $errors[] = $permission_error; |
|
| 1099 | - return $errors; |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - if ( ! is_array( $ids ) ) { |
|
| 1103 | - $ids = explode( ',', $ids ); |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - switch ( $bulkaction ) { |
|
| 1107 | - case 'delete': |
|
| 1108 | - $message = self::bulk_destroy( $ids ); |
|
| 1091 | + if ( empty( $ids ) ) { |
|
| 1092 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1093 | + return $errors; |
|
| 1094 | + } |
|
| 1095 | + |
|
| 1096 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1097 | + if ( $permission_error !== false ) { |
|
| 1098 | + $errors[] = $permission_error; |
|
| 1099 | + return $errors; |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + if ( ! is_array( $ids ) ) { |
|
| 1103 | + $ids = explode( ',', $ids ); |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + switch ( $bulkaction ) { |
|
| 1107 | + case 'delete': |
|
| 1108 | + $message = self::bulk_destroy( $ids ); |
|
| 1109 | 1109 | break; |
| 1110 | - case 'trash': |
|
| 1111 | - $message = self::bulk_trash( $ids ); |
|
| 1110 | + case 'trash': |
|
| 1111 | + $message = self::bulk_trash( $ids ); |
|
| 1112 | 1112 | break; |
| 1113 | - case 'untrash': |
|
| 1114 | - $message = self::bulk_untrash( $ids ); |
|
| 1115 | - } |
|
| 1113 | + case 'untrash': |
|
| 1114 | + $message = self::bulk_untrash( $ids ); |
|
| 1115 | + } |
|
| 1116 | 1116 | |
| 1117 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1117 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1118 | 1118 | $errors['message'] = $message; |
| 1119 | - } |
|
| 1119 | + } |
|
| 1120 | 1120 | |
| 1121 | - return $errors; |
|
| 1122 | - } |
|
| 1121 | + return $errors; |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - public static function route() { |
|
| 1124 | + public static function route() { |
|
| 1125 | 1125 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1126 | - $vars = array(); |
|
| 1126 | + $vars = array(); |
|
| 1127 | 1127 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1128 | 1128 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1129 | 1129 | |
| 1130 | 1130 | $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
| 1131 | 1131 | $json_vars = json_decode( $json_vars, true ); |
| 1132 | 1132 | if ( empty( $json_vars ) ) { |
| 1133 | - // json decoding failed so we should return an error message |
|
| 1133 | + // json decoding failed so we should return an error message |
|
| 1134 | 1134 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1135 | - if ( 'edit' == $action ) { |
|
| 1136 | - $action = 'update'; |
|
| 1137 | - } |
|
| 1135 | + if ( 'edit' == $action ) { |
|
| 1136 | + $action = 'update'; |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | 1139 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| 1140 | - } else { |
|
| 1140 | + } else { |
|
| 1141 | 1141 | $vars = FrmAppHelper::json_to_array( $json_vars ); |
| 1142 | - $action = $vars[ $action ]; |
|
| 1142 | + $action = $vars[ $action ]; |
|
| 1143 | 1143 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1144 | 1144 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1145 | 1145 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1146 | - } |
|
| 1147 | - } else { |
|
| 1146 | + } |
|
| 1147 | + } else { |
|
| 1148 | 1148 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1149 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1150 | - // override the action for this page |
|
| 1151 | - $action = 'delete_all'; |
|
| 1152 | - } |
|
| 1153 | - } |
|
| 1149 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1150 | + // override the action for this page |
|
| 1151 | + $action = 'delete_all'; |
|
| 1152 | + } |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | 1155 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1156 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1156 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1157 | 1157 | |
| 1158 | - switch ( $action ) { |
|
| 1159 | - case 'new': |
|
| 1158 | + switch ( $action ) { |
|
| 1159 | + case 'new': |
|
| 1160 | 1160 | return self::new_form( $vars ); |
| 1161 | 1161 | case 'add_new': |
| 1162 | 1162 | case 'list_templates': |
| 1163 | - case 'create': |
|
| 1164 | - case 'edit': |
|
| 1165 | - case 'update': |
|
| 1166 | - case 'duplicate': |
|
| 1167 | - case 'trash': |
|
| 1168 | - case 'untrash': |
|
| 1169 | - case 'destroy': |
|
| 1170 | - case 'delete_all': |
|
| 1171 | - case 'settings': |
|
| 1172 | - case 'update_settings': |
|
| 1163 | + case 'create': |
|
| 1164 | + case 'edit': |
|
| 1165 | + case 'update': |
|
| 1166 | + case 'duplicate': |
|
| 1167 | + case 'trash': |
|
| 1168 | + case 'untrash': |
|
| 1169 | + case 'destroy': |
|
| 1170 | + case 'delete_all': |
|
| 1171 | + case 'settings': |
|
| 1172 | + case 'update_settings': |
|
| 1173 | 1173 | return self::$action( $vars ); |
| 1174 | - default: |
|
| 1174 | + default: |
|
| 1175 | 1175 | do_action( 'frm_form_action_' . $action ); |
| 1176 | 1176 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1177 | - return; |
|
| 1178 | - } |
|
| 1177 | + return; |
|
| 1178 | + } |
|
| 1179 | 1179 | |
| 1180 | 1180 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1181 | - if ( $action == -1 ) { |
|
| 1181 | + if ( $action == -1 ) { |
|
| 1182 | 1182 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1183 | - } |
|
| 1183 | + } |
|
| 1184 | 1184 | |
| 1185 | 1185 | if ( strpos( $action, 'bulk_' ) === 0 ) { |
| 1186 | - FrmAppHelper::remove_get_action(); |
|
| 1187 | - return self::list_form(); |
|
| 1188 | - } |
|
| 1186 | + FrmAppHelper::remove_get_action(); |
|
| 1187 | + return self::list_form(); |
|
| 1188 | + } |
|
| 1189 | 1189 | |
| 1190 | - return self::display_forms_list(); |
|
| 1191 | - } |
|
| 1192 | - } |
|
| 1190 | + return self::display_forms_list(); |
|
| 1191 | + } |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | - public static function json_error( $errors ) { |
|
| 1195 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1196 | - return $errors; |
|
| 1197 | - } |
|
| 1194 | + public static function json_error( $errors ) { |
|
| 1195 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1196 | + return $errors; |
|
| 1197 | + } |
|
| 1198 | 1198 | |
| 1199 | 1199 | |
| 1200 | - /* FRONT-END FORMS */ |
|
| 1201 | - public static function admin_bar_css() { |
|
| 1200 | + /* FRONT-END FORMS */ |
|
| 1201 | + public static function admin_bar_css() { |
|
| 1202 | 1202 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1203 | - return; |
|
| 1204 | - } |
|
| 1203 | + return; |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | 1206 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1207 | 1207 | FrmAppHelper::load_font_style(); |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | public static function admin_bar_configure() { |
| 1211 | - global $frm_vars; |
|
| 1211 | + global $frm_vars; |
|
| 1212 | 1212 | if ( empty( $frm_vars['forms_loaded'] ) ) { |
| 1213 | - return; |
|
| 1214 | - } |
|
| 1213 | + return; |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | - $actions = array(); |
|
| 1216 | + $actions = array(); |
|
| 1217 | 1217 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1218 | 1218 | if ( is_object( $form ) ) { |
| 1219 | 1219 | $actions[ $form->id ] = $form->name; |
@@ -1268,18 +1268,18 @@ discard block |
||
| 1268 | 1268 | } |
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - //formidable shortcode |
|
| 1271 | + //formidable shortcode |
|
| 1272 | 1272 | public static function get_form_shortcode( $atts ) { |
| 1273 | - global $frm_vars; |
|
| 1273 | + global $frm_vars; |
|
| 1274 | 1274 | if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
| 1275 | - $sc = '[formidable'; |
|
| 1275 | + $sc = '[formidable'; |
|
| 1276 | 1276 | if ( ! empty( $atts ) ) { |
| 1277 | 1277 | foreach ( $atts as $k => $v ) { |
| 1278 | 1278 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1279 | 1279 | } |
| 1280 | 1280 | } |
| 1281 | 1281 | return $sc . ']'; |
| 1282 | - } |
|
| 1282 | + } |
|
| 1283 | 1283 | |
| 1284 | 1284 | $shortcode_atts = shortcode_atts( |
| 1285 | 1285 | array( |
@@ -1297,27 +1297,27 @@ discard block |
||
| 1297 | 1297 | ); |
| 1298 | 1298 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1299 | 1299 | |
| 1300 | - return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1301 | - } |
|
| 1300 | + return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1301 | + } |
|
| 1302 | 1302 | |
| 1303 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1304 | - if ( empty( $id ) ) { |
|
| 1305 | - $id = $key; |
|
| 1306 | - } |
|
| 1303 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1304 | + if ( empty( $id ) ) { |
|
| 1305 | + $id = $key; |
|
| 1306 | + } |
|
| 1307 | 1307 | |
| 1308 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1309 | - if ( ! $form ) { |
|
| 1310 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1311 | - } |
|
| 1308 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1309 | + if ( ! $form ) { |
|
| 1310 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1311 | + } |
|
| 1312 | 1312 | |
| 1313 | 1313 | FrmAppController::maybe_update_styles(); |
| 1314 | 1314 | |
| 1315 | 1315 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1316 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1316 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1317 | 1317 | |
| 1318 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1318 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1319 | 1319 | |
| 1320 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1320 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1321 | 1321 | |
| 1322 | 1322 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1323 | 1323 | // don't show a draft form on a page |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | 1342 | return $form; |
| 1343 | - } |
|
| 1343 | + } |
|
| 1344 | 1344 | |
| 1345 | 1345 | private static function maybe_get_form_to_show( $id ) { |
| 1346 | 1346 | $form = false; |
@@ -1369,21 +1369,21 @@ discard block |
||
| 1369 | 1369 | 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'] ); |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1372 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1373 | 1373 | ob_start(); |
| 1374 | 1374 | |
| 1375 | 1375 | do_action( 'frm_before_get_form', $atts ); |
| 1376 | 1376 | |
| 1377 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1377 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1378 | 1378 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1379 | 1379 | |
| 1380 | - $contents = ob_get_contents(); |
|
| 1381 | - ob_end_clean(); |
|
| 1380 | + $contents = ob_get_contents(); |
|
| 1381 | + ob_end_clean(); |
|
| 1382 | 1382 | |
| 1383 | 1383 | self::maybe_minimize_form( $atts, $contents ); |
| 1384 | 1384 | |
| 1385 | - return $contents; |
|
| 1386 | - } |
|
| 1385 | + return $contents; |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | 1388 | public static function enqueue_scripts( $params ) { |
| 1389 | 1389 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1736,10 +1736,10 @@ discard block |
||
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | public static function defer_script_loading( $tag, $handle ) { |
| 1739 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1740 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1739 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1740 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1741 | 1741 | } |
| 1742 | - return $tag; |
|
| 1742 | + return $tag; |
|
| 1743 | 1743 | } |
| 1744 | 1744 | |
| 1745 | 1745 | public static function footer_js( $location = 'footer' ) { |
@@ -16,28 +16,28 @@ discard block |
||
| 16 | 16 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
| 17 | 17 | $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form ); |
| 18 | 18 | |
| 19 | - return $target_url; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | - $defaults = array( |
|
| 24 | - 'blank' => true, |
|
| 25 | - 'field_id' => false, |
|
| 26 | - 'onchange' => false, |
|
| 27 | - 'exclude' => false, |
|
| 28 | - 'class' => '', |
|
| 19 | + return $target_url; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
| 23 | + $defaults = array( |
|
| 24 | + 'blank' => true, |
|
| 25 | + 'field_id' => false, |
|
| 26 | + 'onchange' => false, |
|
| 27 | + 'exclude' => false, |
|
| 28 | + 'class' => '', |
|
| 29 | 29 | 'inc_children' => 'exclude', |
| 30 | - ); |
|
| 31 | - $args = wp_parse_args( $args, $defaults ); |
|
| 30 | + ); |
|
| 31 | + $args = wp_parse_args( $args, $defaults ); |
|
| 32 | 32 | |
| 33 | - if ( ! $args['field_id'] ) { |
|
| 34 | - $args['field_id'] = $field_name; |
|
| 35 | - } |
|
| 33 | + if ( ! $args['field_id'] ) { |
|
| 34 | + $args['field_id'] = $field_name; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | $query = array(); |
| 38 | - if ( $args['exclude'] ) { |
|
| 38 | + if ( $args['exclude'] ) { |
|
| 39 | 39 | $query['id !'] = $args['exclude']; |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | $where = apply_filters( 'frm_forms_dropdown', $query, $field_name ); |
| 43 | 43 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
| 46 | 46 | self::add_html_attr( $args['class'], 'class', $add_html ); |
| 47 | 47 | |
| 48 | - ?> |
|
| 48 | + ?> |
|
| 49 | 49 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo wp_strip_all_tags( implode( ' ', $add_html ) ); // WPCS: XSS ok. ?>> |
| 50 | 50 | <?php if ( $args['blank'] ) { ?> |
| 51 | 51 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | <?php } ?> |
| 58 | 58 | </select> |
| 59 | 59 | <?php |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param string $class |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function form_switcher() { |
|
| 75 | + public static function form_switcher() { |
|
| 76 | 76 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 77 | 77 | $forms = FrmForm::get_published_forms( $where ); |
| 78 | 78 | |
@@ -84,32 +84,32 @@ discard block |
||
| 84 | 84 | unset( $args['form'] ); |
| 85 | 85 | } elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) { |
| 86 | 86 | unset( $args['id'] ); |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 90 | 90 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
| 91 | - $args['frm_action'] = 'list'; |
|
| 92 | - $args['form'] = 0; |
|
| 91 | + $args['frm_action'] = 'list'; |
|
| 92 | + $args['form'] = 0; |
|
| 93 | 93 | } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
| 94 | - $args['frm_action'] = 'edit'; |
|
| 94 | + $args['frm_action'] = 'edit'; |
|
| 95 | 95 | } else if ( isset( $_GET['post'] ) ) { |
| 96 | - $args['form'] = 0; |
|
| 96 | + $args['form'] = 0; |
|
| 97 | 97 | $base = admin_url( 'edit.php?post_type=frm_display' ); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - ?> |
|
| 100 | + ?> |
|
| 101 | 101 | <li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>"> |
| 102 | 102 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
| 103 | 103 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
| 104 | 104 | <?php |
| 105 | 105 | foreach ( $forms as $form ) { |
| 106 | 106 | if ( isset( $args['id'] ) ) { |
| 107 | - $args['id'] = $form->id; |
|
| 107 | + $args['id'] = $form->id; |
|
| 108 | 108 | } |
| 109 | - if ( isset( $args['form'] ) ) { |
|
| 110 | - $args['form'] = $form->id; |
|
| 109 | + if ( isset( $args['form'] ) ) { |
|
| 110 | + $args['form'] = $form->id; |
|
| 111 | 111 | } |
| 112 | - ?> |
|
| 112 | + ?> |
|
| 113 | 113 | <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
| 114 | 114 | <?php |
| 115 | 115 | unset( $form ); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | </ul> |
| 119 | 119 | </li> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @since 3.05 |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | return $message; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Used when a form is created |
|
| 193 | - */ |
|
| 194 | - public static function setup_new_vars( $values = array() ) { |
|
| 195 | - global $wpdb; |
|
| 191 | + /** |
|
| 192 | + * Used when a form is created |
|
| 193 | + */ |
|
| 194 | + public static function setup_new_vars( $values = array() ) { |
|
| 195 | + global $wpdb; |
|
| 196 | 196 | |
| 197 | - if ( ! empty( $values ) ) { |
|
| 198 | - $post_values = $values; |
|
| 199 | - } else { |
|
| 200 | - $values = array(); |
|
| 197 | + if ( ! empty( $values ) ) { |
|
| 198 | + $post_values = $values; |
|
| 199 | + } else { |
|
| 200 | + $values = array(); |
|
| 201 | 201 | $post_values = isset( $_POST ) ? $_POST : array(); |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | $defaults = array( |
| 205 | 205 | 'name' => '', |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | foreach ( $defaults as $var => $default ) { |
| 209 | 209 | if ( ! isset( $values[ $var ] ) ) { |
| 210 | 210 | $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
| 211 | - } |
|
| 212 | - } |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | $values['description'] = FrmAppHelper::use_wpautop( $values['description'] ); |
| 215 | 215 | |
@@ -228,63 +228,63 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | unset( $defaults ); |
| 230 | 230 | |
| 231 | - if ( ! isset( $values['form_key'] ) ) { |
|
| 231 | + if ( ! isset( $values['form_key'] ) ) { |
|
| 232 | 232 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | $values = self::fill_default_opts( $values, false, $post_values ); |
| 236 | 236 | $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values ); |
| 237 | 237 | |
| 238 | 238 | return apply_filters( 'frm_setup_new_form_vars', $values ); |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Used when editing a form |
|
| 243 | - */ |
|
| 244 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 241 | + /** |
|
| 242 | + * Used when editing a form |
|
| 243 | + */ |
|
| 244 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
| 245 | 245 | if ( empty( $post_values ) ) { |
| 246 | 246 | $post_values = stripslashes_deep( $_POST ); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key; |
| 250 | 250 | $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template; |
| 251 | - $values['status'] = $record->status; |
|
| 251 | + $values['status'] = $record->status; |
|
| 252 | 252 | |
| 253 | 253 | $values = self::fill_default_opts( $values, $record, $post_values ); |
| 254 | 254 | |
| 255 | 255 | return apply_filters( 'frm_setup_edit_form_vars', $values ); |
| 256 | - } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | public static function fill_default_opts( $values, $record, $post_values ) { |
| 259 | 259 | |
| 260 | - $defaults = self::get_default_opts(); |
|
| 260 | + $defaults = self::get_default_opts(); |
|
| 261 | 261 | foreach ( $defaults as $var => $default ) { |
| 262 | 262 | if ( is_array( $default ) ) { |
| 263 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 263 | + if ( ! isset( $values[ $var ] ) ) { |
|
| 264 | 264 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
| 265 | - } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - foreach ( $default as $k => $v ) { |
|
| 267 | + foreach ( $default as $k => $v ) { |
|
| 268 | 268 | $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v ); |
| 269 | 269 | |
| 270 | - if ( is_array( $v ) ) { |
|
| 271 | - foreach ( $v as $k1 => $v1 ) { |
|
| 270 | + if ( is_array( $v ) ) { |
|
| 271 | + foreach ( $v as $k1 => $v1 ) { |
|
| 272 | 272 | $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
| 273 | - unset( $k1, $v1 ); |
|
| 274 | - } |
|
| 275 | - } |
|
| 273 | + unset( $k1, $v1 ); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | 277 | unset( $k, $v ); |
| 278 | - } |
|
| 279 | - } else { |
|
| 278 | + } |
|
| 279 | + } else { |
|
| 280 | 280 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
| 281 | - } |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | unset( $var, $default ); |
| 284 | - } |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - return $values; |
|
| 287 | - } |
|
| 286 | + return $values; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | 289 | public static function get_default_opts() { |
| 290 | 290 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -319,13 +319,13 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * @param string $loc |
|
| 324 | - */ |
|
| 322 | + /** |
|
| 323 | + * @param string $loc |
|
| 324 | + */ |
|
| 325 | 325 | public static function get_default_html( $loc ) { |
| 326 | 326 | if ( $loc == 'submit' ) { |
| 327 | - $draft_link = self::get_draft_link(); |
|
| 328 | - $default_html = <<<SUBMIT_HTML |
|
| 327 | + $draft_link = self::get_draft_link(); |
|
| 328 | + $default_html = <<<SUBMIT_HTML |
|
| 329 | 329 | <div class="frm_submit"> |
| 330 | 330 | [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button] |
| 331 | 331 | <button class="frm_button_submit" type="submit" [button_action]>[button_label]</button> |
@@ -333,22 +333,22 @@ discard block |
||
| 333 | 333 | </div> |
| 334 | 334 | SUBMIT_HTML; |
| 335 | 335 | } else if ( $loc == 'before' ) { |
| 336 | - $default_html = <<<BEFORE_HTML |
|
| 336 | + $default_html = <<<BEFORE_HTML |
|
| 337 | 337 | <legend class="frm_screen_reader">[form_name]</legend> |
| 338 | 338 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
| 339 | 339 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
| 340 | 340 | BEFORE_HTML; |
| 341 | 341 | } else { |
| 342 | - $default_html = ''; |
|
| 343 | - } |
|
| 342 | + $default_html = ''; |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - return $default_html; |
|
| 346 | - } |
|
| 345 | + return $default_html; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - public static function get_draft_link() { |
|
| 349 | - $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 350 | - return $link; |
|
| 351 | - } |
|
| 348 | + public static function get_draft_link() { |
|
| 349 | + $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
| 350 | + return $link; |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
| 354 | 354 | $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | echo $button_parts[1]; // WPCS: XSS ok. |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - /** |
|
| 379 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 378 | + /** |
|
| 379 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
| 380 | + * |
|
| 381 | + * @since 2.0 |
|
| 380 | 382 | * |
| 381 | - * @since 2.0 |
|
| 382 | - * |
|
| 383 | - * @param boolean $reset_fields |
|
| 384 | - */ |
|
| 385 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 383 | + * @param boolean $reset_fields |
|
| 384 | + */ |
|
| 385 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
| 386 | 386 | if ( empty( $fields ) ) { |
| 387 | 387 | return; |
| 388 | 388 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $prev_order = false; |
| 393 | 393 | $add_order = 0; |
| 394 | 394 | $last_field = false; |
| 395 | - foreach ( $fields as $field ) { |
|
| 395 | + foreach ( $fields as $field ) { |
|
| 396 | 396 | if ( $prev_order === $field->field_order ) { |
| 397 | 397 | $add_order++; |
| 398 | 398 | } |
@@ -403,48 +403,48 @@ discard block |
||
| 403 | 403 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - switch ( $field->type ) { |
|
| 407 | - case 'divider': |
|
| 408 | - // create an end section if open |
|
| 406 | + switch ( $field->type ) { |
|
| 407 | + case 'divider': |
|
| 408 | + // create an end section if open |
|
| 409 | 409 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 410 | 410 | |
| 411 | - // mark it open for the next end section |
|
| 412 | - $open = true; |
|
| 411 | + // mark it open for the next end section |
|
| 412 | + $open = true; |
|
| 413 | 413 | break; |
| 414 | - case 'break': |
|
| 414 | + case 'break': |
|
| 415 | 415 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
| 416 | 416 | break; |
| 417 | - case 'end_divider': |
|
| 418 | - if ( ! $open ) { |
|
| 419 | - // the section isn't open, so this is an extra field that needs to be removed |
|
| 420 | - FrmField::destroy( $field->id ); |
|
| 421 | - $reset_fields = true; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - // There is already an end section here, so there is no need to create one |
|
| 425 | - $open = false; |
|
| 426 | - } |
|
| 417 | + case 'end_divider': |
|
| 418 | + if ( ! $open ) { |
|
| 419 | + // the section isn't open, so this is an extra field that needs to be removed |
|
| 420 | + FrmField::destroy( $field->id ); |
|
| 421 | + $reset_fields = true; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + // There is already an end section here, so there is no need to create one |
|
| 425 | + $open = false; |
|
| 426 | + } |
|
| 427 | 427 | $prev_order = $field->field_order; |
| 428 | 428 | |
| 429 | 429 | $last_field = $field; |
| 430 | 430 | unset( $field ); |
| 431 | - } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | 433 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
| 434 | - } |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
| 438 | 438 | * Fix any ordering that may be messed up |
| 439 | 439 | */ |
| 440 | 440 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
| 441 | - if ( ! $open ) { |
|
| 442 | - return; |
|
| 443 | - } |
|
| 441 | + if ( ! $open ) { |
|
| 442 | + return; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | $end_section_values['field_order'] = $field->field_order + 1; |
| 446 | 446 | |
| 447 | - FrmField::create( $end_section_values ); |
|
| 447 | + FrmField::create( $end_section_values ); |
|
| 448 | 448 | |
| 449 | 449 | if ( $move == 'move' ) { |
| 450 | 450 | // bump the order of current field unless we're at the end of the form |
@@ -452,9 +452,9 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $add_order += 2; |
| 455 | - $open = false; |
|
| 456 | - $reset_fields = true; |
|
| 457 | - } |
|
| 455 | + $open = false; |
|
| 456 | + $reset_fields = true; |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | 459 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
| 460 | 460 | $codes = array( |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
| 477 | - } |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | 479 | //replace [form_key] |
| 480 | 480 | $html = str_replace( '[form_key]', $form->form_key, $html ); |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $submit_label = apply_filters( 'frm_submit_button', $title, $form ); |
| 488 | 488 | $submit_label = esc_attr( do_shortcode( $submit_label ) ); |
| 489 | 489 | $html = str_replace( '[button_label]', $submit_label, $html ); |
| 490 | - } |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | 492 | $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values ); |
| 493 | 493 | |
@@ -503,17 +503,17 @@ discard block |
||
| 503 | 503 | $html = do_shortcode( $html ); |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - return $html; |
|
| 507 | - } |
|
| 506 | + return $html; |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | 509 | public static function submit_button_label( $submit ) { |
| 510 | 510 | if ( ! $submit || empty( $submit ) ) { |
| 511 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 512 | - $submit = $frm_settings->submit_value; |
|
| 513 | - } |
|
| 511 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 512 | + $submit = $frm_settings->submit_value; |
|
| 513 | + } |
|
| 514 | 514 | |
| 515 | - return $submit; |
|
| 516 | - } |
|
| 515 | + return $submit; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | 519 | * If the Formidable styling isn't being loaded, |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | } |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - //If submit button needs to be inline or centered |
|
| 545 | + //If submit button needs to be inline or centered |
|
| 546 | 546 | if ( is_object( $form ) ) { |
| 547 | 547 | $form = $form->options; |
| 548 | 548 | } |
@@ -558,8 +558,8 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | $class = apply_filters( 'frm_add_form_style_class', $class, $style ); |
| 560 | 560 | |
| 561 | - return $class; |
|
| 562 | - } |
|
| 561 | + return $class; |
|
| 562 | + } |
|
| 563 | 563 | |
| 564 | 564 | /** |
| 565 | 565 | * Returns appropriate class if form has top labels |
@@ -614,12 +614,12 @@ discard block |
||
| 614 | 614 | return in_array( $label_position, array( 'top', 'inside', 'hidden' ) ); |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - /** |
|
| 618 | - * @param string|boolean $form |
|
| 619 | - * |
|
| 620 | - * @return string |
|
| 621 | - */ |
|
| 622 | - public static function get_form_style( $form ) { |
|
| 617 | + /** |
|
| 618 | + * @param string|boolean $form |
|
| 619 | + * |
|
| 620 | + * @return string |
|
| 621 | + */ |
|
| 622 | + public static function get_form_style( $form ) { |
|
| 623 | 623 | $style = 1; |
| 624 | 624 | if ( empty( $form ) || 'default' == 'form' ) { |
| 625 | 625 | return $style; |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
| 640 | 640 | |
| 641 | 641 | return $style; |
| 642 | - } |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | 644 | /** |
| 645 | 645 | * Display the validation error messages when an entry is submitted |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | public static function get_scroll_js( $form_id ) { |
| 713 | - echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 714 | - } |
|
| 713 | + echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>'; |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | 717 | * @since 3.0 |
@@ -766,20 +766,20 @@ discard block |
||
| 766 | 766 | |
| 767 | 767 | public static function edit_form_link( $form_id ) { |
| 768 | 768 | if ( is_object( $form_id ) ) { |
| 769 | - $form = $form_id; |
|
| 770 | - $name = $form->name; |
|
| 771 | - $form_id = $form->id; |
|
| 772 | - } else { |
|
| 769 | + $form = $form_id; |
|
| 770 | + $name = $form->name; |
|
| 771 | + $form_id = $form->id; |
|
| 772 | + } else { |
|
| 773 | 773 | $name = FrmForm::getName( $form_id ); |
| 774 | - } |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | - if ( $form_id ) { |
|
| 776 | + if ( $form_id ) { |
|
| 777 | 777 | $val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>'; |
| 778 | - } else { |
|
| 779 | - $val = ''; |
|
| 780 | - } |
|
| 778 | + } else { |
|
| 779 | + $val = ''; |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | - return $val; |
|
| 782 | + return $val; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | public static function delete_trash_link( $id, $status, $length = 'label' ) { |
@@ -960,18 +960,18 @@ discard block |
||
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | public static function status_nice_name( $status ) { |
| 963 | - $nice_names = array( |
|
| 964 | - 'draft' => __( 'Draft', 'formidable' ), |
|
| 965 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 966 | - 'publish' => __( 'Published', 'formidable' ), |
|
| 967 | - ); |
|
| 963 | + $nice_names = array( |
|
| 964 | + 'draft' => __( 'Draft', 'formidable' ), |
|
| 965 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 966 | + 'publish' => __( 'Published', 'formidable' ), |
|
| 967 | + ); |
|
| 968 | 968 | |
| 969 | 969 | if ( ! in_array( $status, array_keys( $nice_names ) ) ) { |
| 970 | - $status = 'publish'; |
|
| 971 | - } |
|
| 970 | + $status = 'publish'; |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | 973 | $name = $nice_names[ $status ]; |
| 974 | 974 | |
| 975 | - return $name; |
|
| 976 | - } |
|
| 975 | + return $name; |
|
| 976 | + } |
|
| 977 | 977 | } |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | return $wpdb->get_charset_collate(); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - private function create_tables() { |
|
| 78 | - $charset_collate = $this->collation(); |
|
| 79 | - $sql = array(); |
|
| 77 | + private function create_tables() { |
|
| 78 | + $charset_collate = $this->collation(); |
|
| 79 | + $sql = array(); |
|
| 80 | 80 | |
| 81 | - /* Create/Upgrade Fields Table */ |
|
| 81 | + /* Create/Upgrade Fields Table */ |
|
| 82 | 82 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 83 | 83 | id BIGINT(20) NOT NULL auto_increment, |
| 84 | 84 | field_key varchar(100) default NULL, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | UNIQUE KEY field_key (field_key) |
| 98 | 98 | )'; |
| 99 | 99 | |
| 100 | - /* Create/Upgrade Forms Table */ |
|
| 100 | + /* Create/Upgrade Forms Table */ |
|
| 101 | 101 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 102 | 102 | id int(11) NOT NULL auto_increment, |
| 103 | 103 | form_key varchar(100) default NULL, |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | UNIQUE KEY form_key (form_key) |
| 116 | 116 | )'; |
| 117 | 117 | |
| 118 | - /* Create/Upgrade Items Table */ |
|
| 118 | + /* Create/Upgrade Items Table */ |
|
| 119 | 119 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 120 | 120 | id BIGINT(20) NOT NULL auto_increment, |
| 121 | 121 | item_key varchar(100) default NULL, |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | UNIQUE KEY item_key (item_key) |
| 139 | 139 | )'; |
| 140 | 140 | |
| 141 | - /* Create/Upgrade Meta Table */ |
|
| 141 | + /* Create/Upgrade Meta Table */ |
|
| 142 | 142 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 143 | 143 | id BIGINT(20) NOT NULL auto_increment, |
| 144 | 144 | meta_value longtext default NULL, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | KEY item_id (item_id) |
| 151 | 151 | )'; |
| 152 | 152 | |
| 153 | - foreach ( $sql as $q ) { |
|
| 153 | + foreach ( $sql as $q ) { |
|
| 154 | 154 | if ( function_exists( 'dbDelta' ) ) { |
| 155 | 155 | dbDelta( $q . $charset_collate . ';' ); |
| 156 | 156 | } else { |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | $wpdb->query( $q . $charset_collate ); // WPCS: unprepared SQL ok. |
| 159 | 159 | } |
| 160 | 160 | unset( $q ); |
| 161 | - } |
|
| 162 | - } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | private function maybe_create_contact_form() { |
| 165 | 165 | $form_exists = FrmForm::get_id_by_key( 'contact-form' ); |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - public function uninstall() { |
|
| 218 | + public function uninstall() { |
|
| 219 | 219 | if ( ! current_user_can( 'administrator' ) ) { |
| 220 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 220 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 221 | 221 | wp_die( esc_html( $frm_settings->admin_permission ) ); |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - global $wpdb, $wp_roles; |
|
| 224 | + global $wpdb, $wp_roles; |
|
| 225 | 225 | |
| 226 | 226 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // WPCS: unprepared SQL ok. |
| 227 | 227 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // WPCS: unprepared SQL ok. |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | delete_option( 'frm_install_running' ); |
| 234 | 234 | delete_option( 'frm_lite_settings_upgrade' ); |
| 235 | 235 | |
| 236 | - //delete roles |
|
| 237 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 238 | - $roles = get_editable_roles(); |
|
| 239 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 240 | - foreach ( $roles as $role => $details ) { |
|
| 241 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 236 | + //delete roles |
|
| 237 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 238 | + $roles = get_editable_roles(); |
|
| 239 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 240 | + foreach ( $roles as $role => $details ) { |
|
| 241 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 242 | 242 | unset( $role, $details ); |
| 243 | 243 | } |
| 244 | 244 | unset( $frm_role, $frm_role_description ); |
@@ -266,8 +266,8 @@ discard block |
||
| 266 | 266 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 267 | 267 | |
| 268 | 268 | do_action( 'frm_after_uninstall' ); |
| 269 | - return true; |
|
| 270 | - } |
|
| 269 | + return true; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | 273 | * Delete uneeded default templates |
@@ -449,42 +449,42 @@ discard block |
||
| 449 | 449 | $size .= 'px'; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * Migrate post and email notification settings into actions |
|
| 454 | - */ |
|
| 455 | - private function migrate_to_16() { |
|
| 456 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Old email settings format: |
|
| 460 | - * email_to: Email or field id |
|
| 461 | - * also_email_to: array of fields ids |
|
| 462 | - * reply_to: Email, field id, 'custom' |
|
| 463 | - * cust_reply_to: string |
|
| 464 | - * reply_to_name: field id, 'custom' |
|
| 465 | - * cust_reply_to_name: string |
|
| 466 | - * plain_text: 0|1 |
|
| 467 | - * email_message: string or '' |
|
| 468 | - * email_subject: string or '' |
|
| 469 | - * inc_user_info: 0|1 |
|
| 470 | - * update_email: 0, 1, 2 |
|
| 471 | - * |
|
| 472 | - * Old autoresponder settings format: |
|
| 473 | - * auto_responder: 0|1 |
|
| 474 | - * ar_email_message: string or '' |
|
| 475 | - * ar_email_to: field id |
|
| 476 | - * ar_plain_text: 0|1 |
|
| 477 | - * ar_reply_to_name: string |
|
| 478 | - * ar_reply_to: string |
|
| 479 | - * ar_email_subject: string |
|
| 480 | - * ar_update_email: 0, 1, 2 |
|
| 481 | - * |
|
| 482 | - * New email settings: |
|
| 483 | - * post_content: json settings |
|
| 484 | - * post_title: form id |
|
| 485 | - * post_excerpt: message |
|
| 486 | - */ |
|
| 487 | - foreach ( $forms as $form ) { |
|
| 452 | + /** |
|
| 453 | + * Migrate post and email notification settings into actions |
|
| 454 | + */ |
|
| 455 | + private function migrate_to_16() { |
|
| 456 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * Old email settings format: |
|
| 460 | + * email_to: Email or field id |
|
| 461 | + * also_email_to: array of fields ids |
|
| 462 | + * reply_to: Email, field id, 'custom' |
|
| 463 | + * cust_reply_to: string |
|
| 464 | + * reply_to_name: field id, 'custom' |
|
| 465 | + * cust_reply_to_name: string |
|
| 466 | + * plain_text: 0|1 |
|
| 467 | + * email_message: string or '' |
|
| 468 | + * email_subject: string or '' |
|
| 469 | + * inc_user_info: 0|1 |
|
| 470 | + * update_email: 0, 1, 2 |
|
| 471 | + * |
|
| 472 | + * Old autoresponder settings format: |
|
| 473 | + * auto_responder: 0|1 |
|
| 474 | + * ar_email_message: string or '' |
|
| 475 | + * ar_email_to: field id |
|
| 476 | + * ar_plain_text: 0|1 |
|
| 477 | + * ar_reply_to_name: string |
|
| 478 | + * ar_reply_to: string |
|
| 479 | + * ar_email_subject: string |
|
| 480 | + * ar_update_email: 0, 1, 2 |
|
| 481 | + * |
|
| 482 | + * New email settings: |
|
| 483 | + * post_content: json settings |
|
| 484 | + * post_title: form id |
|
| 485 | + * post_excerpt: message |
|
| 486 | + */ |
|
| 487 | + foreach ( $forms as $form ) { |
|
| 488 | 488 | if ( $form->is_template && $form->default_template ) { |
| 489 | 489 | // don't migrate the default templates since the email will be added anyway |
| 490 | 490 | continue; |
@@ -493,19 +493,19 @@ discard block |
||
| 493 | 493 | // Format form options |
| 494 | 494 | $form_options = maybe_unserialize( $form->options ); |
| 495 | 495 | |
| 496 | - // Migrate settings to actions |
|
| 497 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 498 | - } |
|
| 499 | - } |
|
| 496 | + // Migrate settings to actions |
|
| 497 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 498 | + } |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | - private function migrate_to_11() { |
|
| 502 | - global $wpdb; |
|
| 501 | + private function migrate_to_11() { |
|
| 502 | + global $wpdb; |
|
| 503 | 503 | |
| 504 | 504 | $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
| 505 | 505 | |
| 506 | - $sending = __( 'Sending', 'formidable' ); |
|
| 506 | + $sending = __( 'Sending', 'formidable' ); |
|
| 507 | 507 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 508 | - $old_default_html = <<<DEFAULT_HTML |
|
| 508 | + $old_default_html = <<<DEFAULT_HTML |
|
| 509 | 509 | <div class="frm_submit"> |
| 510 | 510 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 511 | 511 | <input type="submit" value="[button_label]" [button_action] /> |
@@ -515,21 +515,21 @@ discard block |
||
| 515 | 515 | unset( $sending, $img ); |
| 516 | 516 | |
| 517 | 517 | $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
| 518 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 518 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 519 | 519 | foreach ( $forms as $form ) { |
| 520 | 520 | $form->options = maybe_unserialize( $form->options ); |
| 521 | 521 | if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
| 522 | - continue; |
|
| 523 | - } |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 526 | - $form->options['submit_html'] = $new_default_html; |
|
| 525 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 526 | + $form->options['submit_html'] = $new_default_html; |
|
| 527 | 527 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 528 | 528 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 529 | 529 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 530 | 530 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 531 | - } |
|
| 531 | + } |
|
| 532 | 532 | unset( $form ); |
| 533 | - } |
|
| 534 | - } |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | 535 | } |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | $path = untrailingslashit( trim( $path ) ); |
| 400 | 400 | $templates = glob( $path . '/*.php' ); |
| 401 | 401 | |
| 402 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
| 403 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
| 402 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
| 403 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
| 404 | 404 | $template_query = array( 'form_key' => $filename ); |
| 405 | 405 | if ( $template ) { |
| 406 | 406 | $template_query['is_template'] = 1; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $values['is_template'] = $template; |
| 416 | 416 | $values['status'] = 'published'; |
| 417 | 417 | |
| 418 | - include( $templates[ $i ] ); |
|
| 418 | + include( $templates[$i] ); |
|
| 419 | 419 | |
| 420 | 420 | //get updated form |
| 421 | 421 | if ( isset( $form ) && ! empty( $form ) ) { |