| @@ -14,13 +14,13 @@ | ||
| 14 | 14 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong |
| 15 | 15 | |
| 16 | 16 | $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); |
| 17 | 17 | |
| 18 | - if ( ! $views_installed ) { | |
| 18 | + if ( $views_installed ) { | |
| 19 | + self::maybe_redirect_to_views_index(); | |
| 20 | + } else { | |
| 19 | 21 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong |
| 20 | 22 | self::maybe_redirect_to_views_upsell(); |
| 21 | - } else { | |
| 22 | - self::maybe_redirect_to_views_index(); | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
| 26 | 26 | self::load_manage_entries_hooks(); |
| @@ -99,18 +99,19 @@ | ||
| 99 | 99 | * |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | 102 | private static function load_manage_entries_hooks() { |
| 103 | - if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) { | |
| 104 | - $menu_name = FrmAppHelper::get_menu_name(); | |
| 105 | - $base = self::base_column_key( $menu_name ); | |
| 106 | - | |
| 107 | - add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); | |
| 108 | - add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' ); | |
| 109 | - add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' ); | |
| 110 | - } else { | |
| 103 | + if ( in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) { | |
| 111 | 104 | add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 ); |
| 105 | + return; | |
| 112 | 106 | } |
| 107 | + | |
| 108 | + $menu_name = FrmAppHelper::get_menu_name(); | |
| 109 | + $base = self::base_column_key( $menu_name ); | |
| 110 | + | |
| 111 | + add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); | |
| 112 | + add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' ); | |
| 113 | + add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' ); | |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | /** |
| 116 | 117 | * Display in Back End. |
| @@ -153,9 +154,9 @@ | ||
| 153 | 154 | $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); |
| 154 | 155 | $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); |
| 155 | 156 | |
| 156 | 157 | if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) { |
| 157 | - $show_screen = false; | |
| 158 | + return false; | |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | 161 | return $show_screen; |
| 161 | 162 | } |
| @@ -180,10 +181,10 @@ | ||
| 180 | 181 | $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' ); |
| 181 | 182 | } |
| 182 | 183 | |
| 183 | 184 | $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' ); |
| 184 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); | |
| 185 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); | |
| 185 | + $columns[ $form_id . '_created_at' ] = esc_html__( 'Entry creation date', 'formidable' ); | |
| 186 | + $columns[ $form_id . '_updated_at' ] = esc_html__( 'Entry update date', 'formidable' ); | |
| 186 | 187 | self::maybe_add_ip_col( $form_id, $columns ); |
| 187 | 188 | |
| 188 | 189 | $frm_vars['cols'] = $columns; |
| 189 | 190 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| @@ -303,9 +304,9 @@ | ||
| 303 | 304 | */ |
| 304 | 305 | private static function maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, $is_value = true ) { |
| 305 | 306 | $field_name = FrmAppHelper::truncate( $field->name, 35 ); |
| 306 | 307 | |
| 307 | - if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) { | |
| 308 | + if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox', 'product', 'ranking' ), true ) ) { | |
| 308 | 309 | return $field_name; |
| 309 | 310 | } |
| 310 | 311 | |
| 311 | 312 | $append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' ); |
| @@ -379,9 +380,9 @@ | ||
| 379 | 380 | } |
| 380 | 381 | |
| 381 | 382 | foreach ( $meta_value as $mk => $mv ) { |
| 382 | 383 | // Remove blank values. |
| 383 | - if ( empty( $mv ) ) { | |
| 384 | + if ( ! $mv ) { | |
| 384 | 385 | unset( $meta_value[ $mk ] ); |
| 385 | 386 | } |
| 386 | 387 | } |
| 387 | 388 | |
| @@ -391,9 +392,9 @@ | ||
| 391 | 392 | $save = false; |
| 392 | 393 | |
| 393 | 394 | foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
| 394 | 395 | // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
| 395 | - if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { | |
| 396 | + if ( ! $prev_hidden || in_array( $prev_hidden, $meta_value ) ) { | |
| 396 | 397 | // Don't add blank cols or process included cols. |
| 397 | 398 | continue; |
| 398 | 399 | } |
| 399 | 400 | |
| @@ -409,12 +410,13 @@ | ||
| 409 | 410 | $save = true; |
| 410 | 411 | unset( $form_prefix ); |
| 411 | 412 | } |
| 412 | 413 | |
| 413 | - if ( $save ) { | |
| 414 | - $user_id = get_current_user_id(); | |
| 415 | - update_user_option( $user_id, $this_page_name, $meta_value, true ); | |
| 414 | + if ( ! $save ) { | |
| 415 | + return; | |
| 416 | 416 | } |
| 417 | + | |
| 418 | + update_user_option( get_current_user_id(), $this_page_name, $meta_value, true ); | |
| 417 | 419 | } |
| 418 | 420 | |
| 419 | 421 | /** |
| 420 | 422 | * @since 2.05.07 |
| @@ -453,9 +455,9 @@ | ||
| 453 | 455 | * @return int |
| 454 | 456 | */ |
| 455 | 457 | public static function save_per_page( $save, $option, $value ) { |
| 456 | 458 | if ( $option === 'formidable_page_formidable_entries_per_page' ) { |
| 457 | - $save = (int) $value; | |
| 459 | + return (int) $value; | |
| 458 | 460 | } |
| 459 | 461 | |
| 460 | 462 | return $save; |
| 461 | 463 | } |
| @@ -549,17 +551,19 @@ | ||
| 549 | 551 | private static function user_hidden_columns_for_form( $form_id, $result ) { |
| 550 | 552 | $hidden = array(); |
| 551 | 553 | |
| 552 | 554 | foreach ( (array) $result as $r ) { |
| 553 | - if ( ! empty( $r ) ) { | |
| 554 | - list( $form_prefix, $field_key ) = explode( '_', $r ); | |
| 555 | + if ( ! $r ) { | |
| 556 | + continue; | |
| 557 | + } | |
| 555 | 558 | |
| 556 | - if ( (int) $form_prefix === (int) $form_id ) { | |
| 557 | - $hidden[] = $r; | |
| 558 | - } | |
| 559 | + list( $form_prefix, $field_key ) = explode( '_', $r ); | |
| 559 | 560 | |
| 560 | - unset( $form_prefix ); | |
| 561 | + if ( (int) $form_prefix === (int) $form_id ) { | |
| 562 | + $hidden[] = $r; | |
| 561 | 563 | } |
| 564 | + | |
| 565 | + unset( $form_prefix ); | |
| 562 | 566 | } |
| 563 | 567 | |
| 564 | 568 | return $hidden; |
| 565 | 569 | } |
| @@ -630,10 +634,11 @@ | ||
| 630 | 634 | |
| 631 | 635 | if ( headers_sent() ) { |
| 632 | 636 | FrmAppHelper::js_redirect( $url, true ); |
| 633 | 637 | } else { |
| 634 | - wp_redirect( esc_url_raw( $url ) ); | |
| 638 | + wp_safe_redirect( esc_url_raw( $url ) ); | |
| 635 | 639 | } |
| 640 | + | |
| 636 | 641 | die(); |
| 637 | 642 | } |
| 638 | 643 | |
| 639 | 644 | if ( ! $message && isset( $_GET['import-message'] ) ) { |
| @@ -649,15 +654,17 @@ | ||
| 649 | 654 | * |
| 650 | 655 | * @return void |
| 651 | 656 | */ |
| 652 | 657 | private static function get_delete_form_time( $form, &$errors ) { |
| 653 | - if ( 'trash' === $form->status ) { | |
| 654 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); | |
| 655 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) ); | |
| 658 | + if ( 'trash' !== $form->status ) { | |
| 659 | + return; | |
| 660 | + } | |
| 656 | 661 | |
| 657 | - /* translators: %1$s: Time string */ | |
| 658 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); | |
| 659 | - } | |
| 662 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); | |
| 663 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, $form->options['trash_time'] ?? time() ); | |
| 664 | + | |
| 665 | + /* translators: %1$s: Time string */ | |
| 666 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); | |
| 660 | 667 | } |
| 661 | 668 | |
| 662 | 669 | /** |
| 663 | 670 | * Back End CRUD. |
| @@ -788,28 +795,28 @@ | ||
| 788 | 795 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 789 | 796 | |
| 790 | 797 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 791 | 798 | |
| 792 | - if ( ! $errors ) { | |
| 793 | - $_POST['frm_skip_cookie'] = 1; | |
| 794 | - $do_success = false; | |
| 799 | + if ( $errors ) { | |
| 800 | + return; | |
| 801 | + } | |
| 795 | 802 | |
| 796 | - if ( $params['action'] === 'create' ) { | |
| 797 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { | |
| 798 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 803 | + $_POST['frm_skip_cookie'] = 1; | |
| 804 | + $do_success = false; | |
| 799 | 805 | |
| 800 | - $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; | |
| 801 | - $do_success = true; | |
| 802 | - } | |
| 803 | - } | |
| 806 | + if ( $params['action'] === 'create' && apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { | |
| 807 | + $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 804 | 808 | |
| 805 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); | |
| 809 | + $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; | |
| 810 | + $do_success = true; | |
| 811 | + } | |
| 806 | 812 | |
| 807 | - if ( $do_success ) { | |
| 808 | - FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); | |
| 809 | - } | |
| 810 | - unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 813 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); | |
| 814 | + | |
| 815 | + if ( $do_success ) { | |
| 816 | + FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); | |
| 811 | 817 | } |
| 818 | + unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 812 | 819 | } |
| 813 | 820 | |
| 814 | 821 | /** |
| 815 | 822 | * Escape url entities before redirect |
| @@ -863,12 +870,14 @@ | ||
| 863 | 870 | } |
| 864 | 871 | |
| 865 | 872 | FrmAppHelper::unserialize_or_decode( $form->options ); |
| 866 | 873 | |
| 867 | - if ( ! empty( $form->options['no_save'] ) ) { | |
| 868 | - self::unlink_post( $entry_id ); | |
| 869 | - FrmEntry::destroy( $entry_id ); | |
| 874 | + if ( empty( $form->options['no_save'] ) ) { | |
| 875 | + return; | |
| 870 | 876 | } |
| 877 | + | |
| 878 | + self::unlink_post( $entry_id ); | |
| 879 | + FrmEntry::destroy( $entry_id ); | |
| 871 | 880 | } |
| 872 | 881 | |
| 873 | 882 | /** |
| 874 | 883 | * Unlink entry from post |