| @@ -12,11 +12,8 @@ | ||
| 12 | 12 | |
| 13 | 13 | $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); |
| 14 | 14 | if ( ! $views_installed ) { |
| 15 | 15 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' ); |
| 16 | - self::maybe_redirect_to_views_upsell(); | |
| 17 | - } else { | |
| 18 | - self::maybe_redirect_to_views_index(); | |
| 19 | 16 | } |
| 20 | 17 | |
| 21 | 18 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
| 22 | 19 | self::load_manage_entries_hooks(); |
| @@ -23,73 +20,8 @@ | ||
| 23 | 20 | } |
| 24 | 21 | } |
| 25 | 22 | |
| 26 | 23 | /** |
| 27 | - * This function is called when views is installed. | |
| 28 | - * The Views add-on uses a different URL for the Views tab than the upsell page. | |
| 29 | - * If the user is on the upsell page, instead of showing a permission error on reload, | |
| 30 | - * redirect to the views index page. | |
| 31 | - * | |
| 32 | - * @since 6.14.1 | |
| 33 | - * | |
| 34 | - * @return void | |
| 35 | - */ | |
| 36 | - private static function maybe_redirect_to_views_index() { | |
| 37 | - if ( ! FrmAppHelper::is_admin_page( 'formidable-views' ) ) { | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - | |
| 41 | - $query_args = array( | |
| 42 | - 'post_type' => 'frm_display', | |
| 43 | - ); | |
| 44 | - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args ); | |
| 45 | - | |
| 46 | - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'edit.php' ) ) ); | |
| 47 | - die(); | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * This function is called when views is inactive. | |
| 52 | - * A user may deactivate views but then try to reload the views index. | |
| 53 | - * Instead of showing a permission error, redirect to the views upsell page. | |
| 54 | - * | |
| 55 | - * @since 6.14.1 | |
| 56 | - * | |
| 57 | - * @return void | |
| 58 | - */ | |
| 59 | - private static function maybe_redirect_to_views_upsell() { | |
| 60 | - global $pagenow; | |
| 61 | - if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) { | |
| 62 | - return; | |
| 63 | - } | |
| 64 | - | |
| 65 | - $query_args = array( | |
| 66 | - 'page' => 'formidable-views', | |
| 67 | - ); | |
| 68 | - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args ); | |
| 69 | - | |
| 70 | - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ); | |
| 71 | - die(); | |
| 72 | - } | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * @since 6.14.1 | |
| 76 | - * | |
| 77 | - * @param array $query_args | |
| 78 | - * @return array | |
| 79 | - */ | |
| 80 | - private static function add_url_params_to_views_redirect_query_args( $query_args ) { | |
| 81 | - $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 ); | |
| 82 | - | |
| 83 | - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 ); | |
| 84 | - if ( $form_id ) { | |
| 85 | - $query_args['form'] = $form_id; | |
| 86 | - } | |
| 87 | - | |
| 88 | - return $query_args; | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | 24 | * @since 2.05.07 |
| 93 | 25 | */ |
| 94 | 26 | private static function load_manage_entries_hooks() { |
| 95 | 27 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) { |
| @@ -99,9 +31,9 @@ | ||
| 99 | 31 | add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); |
| 100 | 32 | add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' ); |
| 101 | 33 | add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 102 | 34 | } else { |
| 103 | - add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 ); | |
| 35 | + add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 ); | |
| 104 | 36 | } |
| 105 | 37 | } |
| 106 | 38 | |
| 107 | 39 | /** |
| @@ -132,12 +64,10 @@ | ||
| 132 | 64 | * |
| 133 | 65 | * @since 3.0 |
| 134 | 66 | */ |
| 135 | 67 | public static function remove_screen_options( $show_screen, $screen ) { |
| 136 | - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); | |
| 137 | - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); | |
| 138 | - | |
| 139 | - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) { | |
| 68 | + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); | |
| 69 | + if ( $screen->id == $menu_name . '_page_formidable-entries' ) { | |
| 140 | 70 | $show_screen = false; |
| 141 | 71 | } |
| 142 | 72 | |
| 143 | 73 | return $show_screen; |
| @@ -334,11 +264,9 @@ | ||
| 334 | 264 | if ( empty( $menu_name ) ) { |
| 335 | 265 | $menu_name = FrmAppHelper::get_menu_name(); |
| 336 | 266 | } |
| 337 | 267 | |
| 338 | - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); | |
| 339 | - | |
| 340 | - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries'; | |
| 268 | + return sanitize_title( $menu_name ) . '_page_formidable-entries'; | |
| 341 | 269 | } |
| 342 | 270 | |
| 343 | 271 | public static function save_per_page( $save, $option, $value ) { |
| 344 | 272 | if ( $option === 'formidable_page_formidable_entries_per_page' ) { |
| @@ -392,10 +320,8 @@ | ||
| 392 | 320 | * @param mixed $result Option value from database for hidden columns in entries table. |
| 393 | 321 | * @return array |
| 394 | 322 | */ |
| 395 | 323 | public static function hidden_columns( $result ) { |
| 396 | - global $frm_vars; | |
| 397 | - | |
| 398 | 324 | if ( ! is_array( $result ) ) { |
| 399 | 325 | // Force an unexpected value to be an array. |
| 400 | 326 | // Since $result is a filtered option and gets saved to the database, it's possible it could be a string. |
| 401 | 327 | // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. |
| @@ -401,16 +327,21 @@ | ||
| 401 | 327 | // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. |
| 402 | 328 | $result = array(); |
| 403 | 329 | } |
| 404 | 330 | |
| 405 | - $form_id = FrmForm::get_current_form_id(); | |
| 406 | - $hidden = self::user_hidden_columns_for_form( $form_id, $result ); | |
| 407 | - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; | |
| 408 | - $max_columns = 11; | |
| 331 | + $form_id = FrmForm::get_current_form_id(); | |
| 409 | 332 | |
| 333 | + $hidden = self::user_hidden_columns_for_form( $form_id, $result ); | |
| 334 | + | |
| 335 | + global $frm_vars; | |
| 336 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; | |
| 337 | + | |
| 410 | 338 | if ( ! empty( $hidden ) ) { |
| 411 | - $result = $hidden; | |
| 412 | - $i = $i - count( $result ); | |
| 339 | + $result = $hidden; | |
| 340 | + $i = $i - count( $result ); | |
| 341 | + $max_columns = 11; | |
| 342 | + } else { | |
| 343 | + $max_columns = 8; | |
| 413 | 344 | } |
| 414 | 345 | |
| 415 | 346 | if ( $i <= $max_columns ) { |
| 416 | 347 | return $result; |
| @@ -444,12 +375,8 @@ | ||
| 444 | 375 | /** |
| 445 | 376 | * Remove some columns by default when there are too many |
| 446 | 377 | * |
| 447 | 378 | * @since 2.05.07 |
| 448 | - * | |
| 449 | - * @param array $atts | |
| 450 | - * @param array $result | |
| 451 | - * @return void | |
| 452 | 379 | */ |
| 453 | 380 | private static function remove_excess_cols( $atts, &$result ) { |
| 454 | 381 | global $frm_vars; |
| 455 | 382 | |
| @@ -516,9 +443,9 @@ | ||
| 516 | 443 | |
| 517 | 444 | private static function get_delete_form_time( $form, &$errors ) { |
| 518 | 445 | if ( 'trash' === $form->status ) { |
| 519 | 446 | $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
| 520 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) ); | |
| 447 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? $form->options['trash_time'] : time() ) ); | |
| 521 | 448 | |
| 522 | 449 | /* translators: %1$s: Time string */ |
| 523 | 450 | $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 ); |
| 524 | 451 | } |
| @@ -605,13 +532,8 @@ | ||
| 605 | 532 | if ( ! $form ) { |
| 606 | 533 | return; |
| 607 | 534 | } |
| 608 | 535 | |
| 609 | - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' ); | |
| 610 | - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) { | |
| 611 | - return; | |
| 612 | - } | |
| 613 | - | |
| 614 | 536 | $params = FrmForm::get_params( $form ); |
| 615 | 537 | |
| 616 | 538 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 617 | 539 | $frm_vars['form_params'] = array(); |
| @@ -734,9 +656,8 @@ | ||
| 734 | 656 | 'exclude_fields' => '', |
| 735 | 657 | 'include_fields' => '', |
| 736 | 658 | 'include_extras' => '', |
| 737 | 659 | 'inline_style' => 1, |
| 738 | - 'table_style' => '', | |
| 739 | 660 | // Return embedded fields as nested array. |
| 740 | 661 | 'child_array' => false, |
| 741 | 662 | 'line_breaks' => true, |
| 742 | 663 | 'array_separator' => ', ', |
| @@ -780,11 +701,9 @@ | ||
| 780 | 701 | /** |
| 781 | 702 | * Add or remove information in the entry sidebar. |
| 782 | 703 | * |
| 783 | 704 | * @since 5.5.2 |
| 784 | - * | |
| 785 | 705 | * @param array $data |
| 786 | - * @param array{entry:\stdClass} $entry | |
| 787 | 706 | */ |
| 788 | 707 | $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) ); |
| 789 | 708 | } |
| 790 | 709 | |