| @@ -9,10 +9,9 @@ | ||
| 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() : FrmAppHelper::pro_is_installed(); | |
| 14 | - if ( ! $views_installed ) { | |
| 13 | + if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 15 | 14 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' ); |
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
| @@ -23,9 +22,9 @@ | ||
| 23 | 22 | /** |
| 24 | 23 | * @since 2.05.07 |
| 25 | 24 | */ |
| 26 | 25 | private static function load_manage_entries_hooks() { |
| 27 | - if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) { | |
| 26 | + if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new' ) ) ) { | |
| 28 | 27 | $menu_name = FrmAppHelper::get_menu_name(); |
| 29 | 28 | $base = self::base_column_key( $menu_name ); |
| 30 | 29 | |
| 31 | 30 | add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' ); |
| @@ -109,18 +108,8 @@ | ||
| 109 | 108 | |
| 110 | 109 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 111 | 110 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 112 | 111 | |
| 113 | - /** | |
| 114 | - * Allows changing fields in the Entries list table heading. | |
| 115 | - * | |
| 116 | - * @since 5.0.04 | |
| 117 | - * | |
| 118 | - * @param array $fields Array of fields. | |
| 119 | - * @param array $args The arguments. Contains `form_id`. | |
| 120 | - */ | |
| 121 | - $form_cols = apply_filters( 'frm_fields_in_entries_list_table', $form_cols, compact( 'form_id' ) ); | |
| 122 | - | |
| 123 | 112 | foreach ( $form_cols as $form_col ) { |
| 124 | 113 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 125 | 114 | continue; |
| 126 | 115 | } |
| @@ -285,9 +274,10 @@ | ||
| 285 | 274 | $form_id . '_is_draft' => 'is_draft', |
| 286 | 275 | ); |
| 287 | 276 | |
| 288 | 277 | foreach ( $fields as $field ) { |
| 289 | - if ( self::field_supports_sorting( $field ) ) { | |
| 278 | + if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { | |
| 279 | + // Can't sort on checkboxes because they are stored serialized, or post fields | |
| 290 | 280 | $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
| 291 | 281 | } |
| 292 | 282 | } |
| 293 | 283 | |
| @@ -293,32 +283,9 @@ | ||
| 293 | 283 | |
| 294 | 284 | return $columns; |
| 295 | 285 | } |
| 296 | 286 | |
| 297 | - /** | |
| 298 | - * Can't sort on checkboxes because they are sorted serialized. | |
| 299 | - * Some post content can be sorted but not everything. | |
| 300 | - * | |
| 301 | - * @param stdClass $field | |
| 302 | - * @return bool | |
| 303 | - */ | |
| 304 | - private static function field_supports_sorting( $field ) { | |
| 305 | - $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] ); | |
| 306 | - return apply_filters( 'frm_field_column_is_sortable', $is_sortable, $field ); | |
| 307 | - } | |
| 308 | - | |
| 309 | - /** | |
| 310 | - * @param mixed $result Option value from database for hidden columns in entries table. | |
| 311 | - * @return array | |
| 312 | - */ | |
| 313 | 287 | public static function hidden_columns( $result ) { |
| 314 | - if ( ! is_array( $result ) ) { | |
| 315 | - // Force an unexpected value to be an array. | |
| 316 | - // Since $result is a filtered option and gets saved to the database, it's possible it could be a string. | |
| 317 | - // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error. | |
| 318 | - $result = array(); | |
| 319 | - } | |
| 320 | - | |
| 321 | 288 | $form_id = FrmForm::get_current_form_id(); |
| 322 | 289 | |
| 323 | 290 | $hidden = self::user_hidden_columns_for_form( $form_id, $result ); |
| 324 | 291 | |
| @@ -416,9 +383,9 @@ | ||
| 416 | 383 | $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
| 417 | 384 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 418 | 385 | $url = add_query_arg( 'paged', $total_pages ); |
| 419 | 386 | if ( headers_sent() ) { |
| 420 | - FrmAppHelper::js_redirect( $url, true ); | |
| 387 | + echo FrmAppHelper::js_redirect( $url ); // WPCS: XSS ok. | |
| 421 | 388 | } else { |
| 422 | 389 | wp_redirect( esc_url_raw( $url ) ); |
| 423 | 390 | } |
| 424 | 391 | die(); |
| @@ -427,9 +394,9 @@ | ||
| 427 | 394 | if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
| 428 | 395 | $message = __( 'Your import is complete', 'formidable' ); |
| 429 | 396 | } |
| 430 | 397 | |
| 431 | - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php'; | |
| 398 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); | |
| 432 | 399 | } |
| 433 | 400 | |
| 434 | 401 | private static function get_delete_form_time( $form, &$errors ) { |
| 435 | 402 | if ( 'trash' == $form->status ) { |
| @@ -472,19 +439,10 @@ | ||
| 472 | 439 | |
| 473 | 440 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 474 | 441 | } |
| 475 | 442 | |
| 476 | - /** | |
| 477 | - * Destroy an entry from the admin page. | |
| 478 | - * This is triggered from the entries list from the "Delete" row action, and also from the "Delete Entry" trigger in the view/edit entry sidebar. | |
| 479 | - * | |
| 480 | - * @return void | |
| 481 | - */ | |
| 482 | 443 | public static function destroy() { |
| 483 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 ); | |
| 484 | - if ( false !== $permission_error ) { | |
| 485 | - wp_die( esc_html( $permission_error ) ); | |
| 486 | - } | |
| 444 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); | |
| 487 | 445 | |
| 488 | 446 | $params = FrmForm::get_admin_params(); |
| 489 | 447 | |
| 490 | 448 | if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
| @@ -492,9 +450,9 @@ | ||
| 492 | 450 | } |
| 493 | 451 | |
| 494 | 452 | $message = ''; |
| 495 | 453 | if ( FrmEntry::destroy( $params['id'] ) ) { |
| 496 | - $message = __( 'Entry was successfully deleted', 'formidable' ); | |
| 454 | + $message = __( 'Entry was Successfully Deleted', 'formidable' ); | |
| 497 | 455 | } |
| 498 | 456 | |
| 499 | 457 | self::display_list( $message ); |
| 500 | 458 | } |
| @@ -510,9 +468,9 @@ | ||
| 510 | 468 | } |
| 511 | 469 | |
| 512 | 470 | public static function process_entry( $errors = '', $ajax = false ) { |
| 513 | 471 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 514 | - if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 472 | + if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { | |
| 515 | 473 | return; |
| 516 | 474 | } |
| 517 | 475 | |
| 518 | 476 | global $frm_vars; |
| @@ -533,9 +491,9 @@ | ||
| 533 | 491 | return; |
| 534 | 492 | } |
| 535 | 493 | |
| 536 | 494 | if ( $errors == '' && ! $ajax ) { |
| 537 | - $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 495 | + $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); | |
| 538 | 496 | } |
| 539 | 497 | |
| 540 | 498 | /** |
| 541 | 499 | * Use this filter to add trigger actions and add errors after |
| @@ -549,11 +507,11 @@ | ||
| 549 | 507 | |
| 550 | 508 | if ( empty( $errors ) ) { |
| 551 | 509 | $_POST['frm_skip_cookie'] = 1; |
| 552 | 510 | $do_success = false; |
| 553 | - if ( $params['action'] === 'create' ) { | |
| 511 | + if ( $params['action'] == 'create' ) { | |
| 554 | 512 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 555 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 513 | + $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); | |
| 556 | 514 | |
| 557 | 515 | $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; |
| 558 | 516 | $do_success = true; |
| 559 | 517 | } |
| @@ -562,9 +520,9 @@ | ||
| 562 | 520 | do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
| 563 | 521 | if ( $do_success ) { |
| 564 | 522 | FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); |
| 565 | 523 | } |
| 566 | - unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 524 | + unset( $_POST['frm_skip_cookie'] ); | |
| 567 | 525 | } |
| 568 | 526 | } |
| 569 | 527 | |
| 570 | 528 | /** |
| @@ -622,34 +580,33 @@ | ||
| 622 | 580 | * @return array|string |
| 623 | 581 | */ |
| 624 | 582 | public static function show_entry_shortcode( $atts ) { |
| 625 | 583 | $defaults = array( |
| 626 | - 'id' => false, | |
| 627 | - 'entry' => false, | |
| 628 | - 'fields' => false, | |
| 629 | - 'plain_text' => false, | |
| 630 | - 'user_info' => false, | |
| 631 | - 'include_blank' => false, | |
| 632 | - 'default_email' => false, | |
| 633 | - 'form_id' => false, | |
| 634 | - 'format' => 'text', | |
| 635 | - 'array_key' => 'key', | |
| 636 | - 'direction' => 'ltr', | |
| 637 | - 'font_size' => '', | |
| 638 | - 'text_color' => '', | |
| 639 | - 'border_width' => '', | |
| 640 | - 'border_color' => '', | |
| 641 | - 'bg_color' => '', | |
| 642 | - 'alt_bg_color' => '', | |
| 643 | - 'class' => '', | |
| 644 | - 'clickable' => false, | |
| 645 | - 'exclude_fields' => '', | |
| 646 | - 'include_fields' => '', | |
| 647 | - 'include_extras' => '', | |
| 648 | - 'inline_style' => 1, | |
| 649 | - 'child_array' => false, // return embedded fields as nested array | |
| 650 | - 'line_breaks' => true, | |
| 651 | - 'array_separator' => ', ', | |
| 584 | + 'id' => false, | |
| 585 | + 'entry' => false, | |
| 586 | + 'fields' => false, | |
| 587 | + 'plain_text' => false, | |
| 588 | + 'user_info' => false, | |
| 589 | + 'include_blank' => false, | |
| 590 | + 'default_email' => false, | |
| 591 | + 'form_id' => false, | |
| 592 | + 'format' => 'text', | |
| 593 | + 'array_key' => 'key', | |
| 594 | + 'direction' => 'ltr', | |
| 595 | + 'font_size' => '', | |
| 596 | + 'text_color' => '', | |
| 597 | + 'border_width' => '', | |
| 598 | + 'border_color' => '', | |
| 599 | + 'bg_color' => '', | |
| 600 | + 'alt_bg_color' => '', | |
| 601 | + 'class' => '', | |
| 602 | + 'clickable' => false, | |
| 603 | + 'exclude_fields' => '', | |
| 604 | + 'include_fields' => '', | |
| 605 | + 'include_extras' => '', | |
| 606 | + 'inline_style' => 1, | |
| 607 | + 'child_array' => false, // return embedded fields as nested array | |
| 608 | + 'line_breaks' => true, | |
| 652 | 609 | ); |
| 653 | 610 | $defaults = apply_filters( 'frm_show_entry_defaults', $defaults ); |
| 654 | 611 | |
| 655 | 612 | $atts = shortcode_atts( $defaults, $atts ); |
| @@ -685,15 +642,8 @@ | ||
| 685 | 642 | $data = $entry->description; |
| 686 | 643 | if ( isset( $data['browser'] ) ) { |
| 687 | 644 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 688 | 645 | } |
| 689 | - /** | |
| 690 | - * Add or remove information in the entry sidebar. | |
| 691 | - * | |
| 692 | - * @since 5.5.2 | |
| 693 | - * @param array $data | |
| 694 | - */ | |
| 695 | - $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) ); | |
| 696 | 646 | } |
| 697 | 647 | |
| 698 | 648 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 699 | 649 | } |
| @@ -703,6 +653,22 @@ | ||
| 703 | 653 | */ |
| 704 | 654 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 705 | 655 | _deprecated_function( __METHOD__, '4.0' ); |
| 706 | 656 | return $help; |
| 657 | + } | |
| 658 | + | |
| 659 | + /** | |
| 660 | + * @deprecated 1.07.05 | |
| 661 | + * @codeCoverageIgnore | |
| 662 | + */ | |
| 663 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { | |
| 664 | + return FrmDeprecated::show_form( $id, $key, $title, $description ); | |
| 665 | + } | |
| 666 | + | |
| 667 | + /** | |
| 668 | + * @deprecated 1.07.05 | |
| 669 | + * @codeCoverageIgnore | |
| 670 | + */ | |
| 671 | + public static function get_form( $filename, $form, $title, $description ) { | |
| 672 | + return FrmDeprecated::get_form( $filename, $form, $title, $description ); | |
| 707 | 673 | } |
| 708 | 674 | } |