| @@ -9,14 +9,11 @@ | ||
| 9 | 9 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 10 | 10 | |
| 11 | 11 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
| 12 | 12 | |
| 13 | - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); | |
| 13 | + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_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,15 +31,13 @@ | ||
| 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 | - /** | |
| 108 | - * Display in Back End. | |
| 109 | - */ | |
| 39 | + /* Display in Back End */ | |
| 110 | 40 | public static function route() { |
| 111 | 41 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 112 | 42 | FrmAppHelper::include_svg(); |
| 113 | 43 | |
| @@ -132,12 +62,10 @@ | ||
| 132 | 62 | * |
| 133 | 63 | * @since 3.0 |
| 134 | 64 | */ |
| 135 | 65 | 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' ) { | |
| 66 | + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() ); | |
| 67 | + if ( $screen->id == $menu_name . '_page_formidable-entries' ) { | |
| 140 | 68 | $show_screen = false; |
| 141 | 69 | } |
| 142 | 70 | |
| 143 | 71 | return $show_screen; |
| @@ -197,9 +125,9 @@ | ||
| 197 | 125 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 198 | 126 | continue; |
| 199 | 127 | } |
| 200 | 128 | |
| 201 | - $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] ); | |
| 129 | + $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ); | |
| 202 | 130 | if ( $has_child_fields ) { |
| 203 | 131 | self::add_subform_cols( $form_col, $form_id, $columns ); |
| 204 | 132 | } else { |
| 205 | 133 | self::add_field_cols( $form_col, $form_id, $columns ); |
| @@ -235,9 +163,9 @@ | ||
| 235 | 163 | $col_id .= '-_-form' . $field->form_id; |
| 236 | 164 | } |
| 237 | 165 | |
| 238 | 166 | $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' ); |
| 239 | - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status'; | |
| 167 | + $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status'; | |
| 240 | 168 | if ( $has_separate_value && ! $is_post_status ) { |
| 241 | 169 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 ); |
| 242 | 170 | } |
| 243 | 171 | |
| @@ -260,10 +188,10 @@ | ||
| 260 | 188 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 261 | 189 | } |
| 262 | 190 | |
| 263 | 191 | global $frm_vars; |
| 264 | - // Add a check so we don't create a loop. | |
| 265 | - $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; | |
| 192 | + //add a check so we don't create a loop | |
| 193 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; | |
| 266 | 194 | |
| 267 | 195 | return $check; |
| 268 | 196 | } |
| 269 | 197 | |
| @@ -277,10 +205,9 @@ | ||
| 277 | 205 | } |
| 278 | 206 | |
| 279 | 207 | global $frm_vars; |
| 280 | 208 | if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
| 281 | - // Don't continue if there's no previous value. | |
| 282 | - return; | |
| 209 | + return; // Don't continue if there's no previous value. | |
| 283 | 210 | } |
| 284 | 211 | |
| 285 | 212 | foreach ( $meta_value as $mk => $mv ) { |
| 286 | 213 | // Remove blank values. |
| @@ -334,15 +261,13 @@ | ||
| 334 | 261 | if ( empty( $menu_name ) ) { |
| 335 | 262 | $menu_name = FrmAppHelper::get_menu_name(); |
| 336 | 263 | } |
| 337 | 264 | |
| 338 | - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count(); | |
| 339 | - | |
| 340 | - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries'; | |
| 265 | + return sanitize_title( $menu_name ) . '_page_formidable-entries'; | |
| 341 | 266 | } |
| 342 | 267 | |
| 343 | 268 | public static function save_per_page( $save, $option, $value ) { |
| 344 | - if ( $option === 'formidable_page_formidable_entries_per_page' ) { | |
| 269 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { | |
| 345 | 270 | $save = (int) $value; |
| 346 | 271 | } |
| 347 | 272 | |
| 348 | 273 | return $save; |
| @@ -360,14 +285,8 @@ | ||
| 360 | 285 | $form_id . '_item_key' => 'item_key', |
| 361 | 286 | $form_id . '_is_draft' => 'is_draft', |
| 362 | 287 | ); |
| 363 | 288 | |
| 364 | - if ( ! $form_id ) { | |
| 365 | - $columns[ $form_id . '_user_id' ] = 'user_id'; | |
| 366 | - $columns[ $form_id . '_name' ] = 'name'; | |
| 367 | - $columns[ $form_id . '_form_id' ] = 'form_id'; | |
| 368 | - } | |
| 369 | - | |
| 370 | 289 | foreach ( $fields as $field ) { |
| 371 | 290 | if ( self::field_supports_sorting( $field ) ) { |
| 372 | 291 | $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
| 373 | 292 | } |
| @@ -392,10 +311,8 @@ | ||
| 392 | 311 | * @param mixed $result Option value from database for hidden columns in entries table. |
| 393 | 312 | * @return array |
| 394 | 313 | */ |
| 395 | 314 | public static function hidden_columns( $result ) { |
| 396 | - global $frm_vars; | |
| 397 | - | |
| 398 | 315 | if ( ! is_array( $result ) ) { |
| 399 | 316 | // Force an unexpected value to be an array. |
| 400 | 317 | // Since $result is a filtered option and gets saved to the database, it's possible it could be a string. |
| 401 | 318 | // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. |
| @@ -401,16 +318,21 @@ | ||
| 401 | 318 | // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. |
| 402 | 319 | $result = array(); |
| 403 | 320 | } |
| 404 | 321 | |
| 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; | |
| 322 | + $form_id = FrmForm::get_current_form_id(); | |
| 409 | 323 | |
| 324 | + $hidden = self::user_hidden_columns_for_form( $form_id, $result ); | |
| 325 | + | |
| 326 | + global $frm_vars; | |
| 327 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; | |
| 328 | + | |
| 410 | 329 | if ( ! empty( $hidden ) ) { |
| 411 | - $result = $hidden; | |
| 412 | - $i = $i - count( $result ); | |
| 330 | + $result = $hidden; | |
| 331 | + $i = $i - count( $result ); | |
| 332 | + $max_columns = 11; | |
| 333 | + } else { | |
| 334 | + $max_columns = 8; | |
| 413 | 335 | } |
| 414 | 336 | |
| 415 | 337 | if ( $i <= $max_columns ) { |
| 416 | 338 | return $result; |
| @@ -429,9 +351,9 @@ | ||
| 429 | 351 | foreach ( (array) $result as $r ) { |
| 430 | 352 | if ( ! empty( $r ) ) { |
| 431 | 353 | list( $form_prefix, $field_key ) = explode( '_', $r ); |
| 432 | 354 | |
| 433 | - if ( (int) $form_prefix === (int) $form_id ) { | |
| 355 | + if ( (int) $form_prefix == (int) $form_id ) { | |
| 434 | 356 | $hidden[] = $r; |
| 435 | 357 | } |
| 436 | 358 | |
| 437 | 359 | unset( $form_prefix ); |
| @@ -444,12 +366,8 @@ | ||
| 444 | 366 | /** |
| 445 | 367 | * Remove some columns by default when there are too many |
| 446 | 368 | * |
| 447 | 369 | * @since 2.05.07 |
| 448 | - * | |
| 449 | - * @param array $atts | |
| 450 | - * @param array $result | |
| 451 | - * @return void | |
| 452 | 370 | */ |
| 453 | 371 | private static function remove_excess_cols( $atts, &$result ) { |
| 454 | 372 | global $frm_vars; |
| 455 | 373 | |
| @@ -467,9 +385,9 @@ | ||
| 467 | 385 | } |
| 468 | 386 | |
| 469 | 387 | if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) { |
| 470 | 388 | $result[] = $col_key; |
| 471 | - --$i; | |
| 389 | + $i--; | |
| 472 | 390 | } |
| 473 | 391 | |
| 474 | 392 | unset( $col_key, $col ); |
| 475 | 393 | } |
| @@ -514,20 +432,18 @@ | ||
| 514 | 432 | require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php'; |
| 515 | 433 | } |
| 516 | 434 | |
| 517 | 435 | private static function get_delete_form_time( $form, &$errors ) { |
| 518 | - if ( 'trash' === $form->status ) { | |
| 436 | + if ( 'trash' == $form->status ) { | |
| 519 | 437 | $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
| 520 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) ); | |
| 438 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); | |
| 521 | 439 | |
| 522 | 440 | /* translators: %1$s: Time string */ |
| 523 | - $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 ); | |
| 441 | + $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 | 442 | } |
| 525 | 443 | } |
| 526 | 444 | |
| 527 | - /** | |
| 528 | - * Back End CRUD. | |
| 529 | - */ | |
| 445 | + /* Back End CRUD */ | |
| 530 | 446 | public static function show( $id = 0 ) { |
| 531 | 447 | FrmAppHelper::permission_check( 'frm_view_entries' ); |
| 532 | 448 | |
| 533 | 449 | if ( ! $id ) { |
| @@ -539,15 +455,12 @@ | ||
| 539 | 455 | } |
| 540 | 456 | |
| 541 | 457 | $entry = FrmEntry::getOne( $id, true ); |
| 542 | 458 | if ( ! $entry ) { |
| 543 | - FrmAppController::show_error_modal( | |
| 544 | - array( | |
| 545 | - 'title' => __( 'You can\'t view the entry', 'formidable' ), | |
| 546 | - 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ), | |
| 547 | - 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 548 | - ) | |
| 549 | - ); | |
| 459 | + echo '<div id="form_show_entry_page" class="wrap">' . | |
| 460 | + esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) . | |
| 461 | + '</div>'; | |
| 462 | + | |
| 550 | 463 | return; |
| 551 | 464 | } |
| 552 | 465 | |
| 553 | 466 | $data = $entry->description; |
| @@ -557,9 +470,9 @@ | ||
| 557 | 470 | |
| 558 | 471 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 559 | 472 | $form = FrmForm::getOne( $entry->form_id ); |
| 560 | 473 | |
| 561 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php'; | |
| 474 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); | |
| 562 | 475 | } |
| 563 | 476 | |
| 564 | 477 | /** |
| 565 | 478 | * Destroy an entry from the admin page. |
| @@ -570,11 +483,11 @@ | ||
| 570 | 483 | public static function destroy() { |
| 571 | 484 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 ); |
| 572 | 485 | if ( false !== $permission_error ) { |
| 573 | 486 | $error_args = array( |
| 574 | - 'title' => __( 'Verification failed', 'formidable' ), | |
| 575 | - 'body' => $permission_error, | |
| 576 | - 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ), | |
| 487 | + 'title' => __( 'Verification failed', 'formidable' ), | |
| 488 | + 'body' => $permission_error, | |
| 489 | + 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ), | |
| 577 | 490 | ); |
| 578 | 491 | FrmAppController::show_error_modal( $error_args ); |
| 579 | 492 | return; |
| 580 | 493 | } |
| @@ -592,8 +505,18 @@ | ||
| 592 | 505 | |
| 593 | 506 | self::display_list( $message ); |
| 594 | 507 | } |
| 595 | 508 | |
| 509 | + /** | |
| 510 | + * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite. | |
| 511 | + */ | |
| 512 | + public static function destroy_all() { | |
| 513 | + _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' ); | |
| 514 | + if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) { | |
| 515 | + FrmProEntriesController::destroy_all(); | |
| 516 | + } | |
| 517 | + } | |
| 518 | + | |
| 596 | 519 | public static function process_entry( $errors = '', $ajax = false ) { |
| 597 | 520 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 598 | 521 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 599 | 522 | return; |
| @@ -605,13 +528,8 @@ | ||
| 605 | 528 | if ( ! $form ) { |
| 606 | 529 | return; |
| 607 | 530 | } |
| 608 | 531 | |
| 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 | 532 | $params = FrmForm::get_params( $form ); |
| 615 | 533 | |
| 616 | 534 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 617 | 535 | $frm_vars['form_params'] = array(); |
| @@ -705,9 +623,9 @@ | ||
| 705 | 623 | FrmEntry::clear_cache(); |
| 706 | 624 | } |
| 707 | 625 | |
| 708 | 626 | /** |
| 709 | - * @param array $atts | |
| 627 | + * @param $atts | |
| 710 | 628 | * |
| 711 | 629 | * @return array|string |
| 712 | 630 | */ |
| 713 | 631 | public static function show_entry_shortcode( $atts ) { |
| @@ -734,11 +652,9 @@ | ||
| 734 | 652 | 'exclude_fields' => '', |
| 735 | 653 | 'include_fields' => '', |
| 736 | 654 | 'include_extras' => '', |
| 737 | 655 | 'inline_style' => 1, |
| 738 | - 'table_style' => '', | |
| 739 | - // Return embedded fields as nested array. | |
| 740 | - 'child_array' => false, | |
| 656 | + 'child_array' => false, // return embedded fields as nested array | |
| 741 | 657 | 'line_breaks' => true, |
| 742 | 658 | 'array_separator' => ', ', |
| 743 | 659 | ); |
| 744 | 660 | $defaults = apply_filters( 'frm_show_entry_defaults', $defaults ); |
| @@ -780,14 +696,20 @@ | ||
| 780 | 696 | /** |
| 781 | 697 | * Add or remove information in the entry sidebar. |
| 782 | 698 | * |
| 783 | 699 | * @since 5.5.2 |
| 784 | - * | |
| 785 | 700 | * @param array $data |
| 786 | - * @param array{entry:\stdClass} $entry | |
| 787 | 701 | */ |
| 788 | 702 | $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) ); |
| 789 | 703 | } |
| 790 | 704 | |
| 791 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php'; | |
| 705 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); | |
| 706 | + } | |
| 707 | + | |
| 708 | + /** | |
| 709 | + * @deprecated 4.0 | |
| 710 | + */ | |
| 711 | + public static function contextual_help( $help, $screen_id, $screen ) { | |
| 712 | + _deprecated_function( __METHOD__, '4.0' ); | |
| 713 | + return $help; | |
| 792 | 714 | } |
| 793 | 715 | } |