| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | // Return the link to the last page created. |
| 97 | 97 | $pages = $imported['posts']; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( ! empty( $form ) ) { | |
| 100 | + if ( $form ) { | |
| 101 | 101 | // Create selected pages with the correct shortcodes. |
| 102 | 102 | $pages = self::create_pages_for_import( $form ); |
| 103 | 103 | } |
| 104 | 104 | |
| @@ -177,9 +177,9 @@ | ||
| 177 | 177 | * |
| 178 | 178 | * @param array $form |
| 179 | 179 | * @param string $value |
| 180 | 180 | * |
| 181 | - * @return string | |
| 181 | + * @return array|string | |
| 182 | 182 | */ |
| 183 | 183 | private static function get_selected_in_form( $form, $value = 'form' ) { |
| 184 | 184 | if ( $form && ! empty( $form[ $value ] ) ) { |
| 185 | 185 | return $form[ $value ]; |
| @@ -204,9 +204,9 @@ | ||
| 204 | 204 | $view_keys = self::get_selected_in_form( $form, 'view' ); |
| 205 | 205 | $page_ids = array(); |
| 206 | 206 | |
| 207 | 207 | foreach ( (array) $form['pages'] as $for => $name ) { |
| 208 | - if ( empty( $name ) ) { | |
| 208 | + if ( ! $name ) { | |
| 209 | 209 | // Don't create a page if no title is given. |
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |
| @@ -384,9 +384,9 @@ | ||
| 384 | 384 | $file_type = sanitize_option( 'upload_path', $_FILES['frm_import_file']['name'] ); |
| 385 | 385 | $file_type = strtolower( pathinfo( $file_type, PATHINFO_EXTENSION ) ); |
| 386 | 386 | |
| 387 | 387 | if ( 'xml' !== $file_type && isset( $export_format[ $file_type ] ) ) { |
| 388 | - // allow other file types to be imported | |
| 388 | + // Allow other file types to be imported | |
| 389 | 389 | do_action( 'frm_before_import_' . $file_type ); |
| 390 | 390 | |
| 391 | 391 | return; |
| 392 | 392 | } |
| @@ -426,9 +426,9 @@ | ||
| 426 | 426 | $type = FrmAppHelper::get_post_param( 'type', array(), 'sanitize_text_field' ); |
| 427 | 427 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
| 428 | 428 | |
| 429 | 429 | if ( ! headers_sent() && ! $type ) { |
| 430 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); | |
| 430 | + wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); | |
| 431 | 431 | die(); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | if ( 'xml' === $format ) { |
| @@ -475,9 +475,9 @@ | ||
| 475 | 475 | ); |
| 476 | 476 | $args = wp_parse_args( $args, $defaults ); |
| 477 | 477 | |
| 478 | 478 | // Make sure ids are numeric. |
| 479 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { | |
| 479 | + if ( is_array( $args['ids'] ) && $args['ids'] ) { | |
| 480 | 480 | $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | $records = array(); |
| @@ -603,14 +603,14 @@ | ||
| 603 | 603 | private static function prepare_types_array( &$type ) { |
| 604 | 604 | $type = (array) $type; |
| 605 | 605 | |
| 606 | 606 | if ( ! in_array( 'forms', $type, true ) && ( in_array( 'items', $type, true ) || in_array( 'posts', $type, true ) ) ) { |
| 607 | - // make sure the form is included if there are entries | |
| 607 | + // Make sure the form is included if there are entries | |
| 608 | 608 | $type[] = 'forms'; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | if ( in_array( 'forms', $type, true ) ) { |
| 612 | - // include actions with forms | |
| 612 | + // Include actions with forms | |
| 613 | 613 | $type[] = 'actions'; |
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | |
| @@ -628,9 +628,9 @@ | ||
| 628 | 628 | private static function get_file_name( $args, $records ) { |
| 629 | 629 | $has_one_form = ! empty( $records['forms'] ) && count( $args['ids'] ) === 1; |
| 630 | 630 | |
| 631 | 631 | if ( $has_one_form ) { |
| 632 | - // one form is being exported | |
| 632 | + // One form is being exported | |
| 633 | 633 | $selected_form_id = reset( $args['ids'] ); |
| 634 | 634 | $filename = 'form-' . $selected_form_id . '.xml'; |
| 635 | 635 | |
| 636 | 636 | foreach ( $records['forms'] as $form_id ) { |
| @@ -690,9 +690,9 @@ | ||
| 690 | 690 | FrmAppHelper::permission_check( 'frm_view_entries' ); |
| 691 | 691 | |
| 692 | 692 | if ( ! $form_id ) { |
| 693 | 693 | $form_id = FrmAppHelper::get_param( 'form', '', 'get', 'sanitize_text_field' ); |
| 694 | - $search = FrmAppHelper::get_param( ( isset( $_REQUEST['s'] ) ? 's' : 'search' ), '', 'get', 'sanitize_text_field' ); | |
| 694 | + $search = FrmAppHelper::get_param( isset( $_REQUEST['s'] ) ? 's' : 'search', '', 'get', 'sanitize_text_field' ); | |
| 695 | 695 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | // Remove time limit to execute this function. |
| @@ -741,12 +741,12 @@ | ||
| 741 | 741 | |
| 742 | 742 | $entry_ids = FrmDb::get_col( $wpdb->prefix . 'frm_items it', $query ); |
| 743 | 743 | unset( $query ); |
| 744 | 744 | |
| 745 | - if ( ! $entry_ids ) { | |
| 745 | + if ( $entry_ids ) { | |
| 746 | + FrmCSVExportHelper::generate_csv( compact( 'form', 'entry_ids', 'form_cols' ) ); | |
| 747 | + } else { | |
| 746 | 748 | esc_html_e( 'There are no entries for that form.', 'formidable' ); |
| 747 | - } else { | |
| 748 | - FrmCSVExportHelper::generate_csv( compact( 'form', 'entry_ids', 'form_cols' ) ); | |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | wp_die(); |
| 752 | 752 | } |
| @@ -759,9 +759,9 @@ | ||
| 759 | 759 | * |
| 760 | 760 | * @param int $form_id |
| 761 | 761 | * @param object $form |
| 762 | 762 | * |
| 763 | - * @return array $csv_fields | |
| 763 | + * @return array CSV fields. | |
| 764 | 764 | */ |
| 765 | 765 | public static function get_fields_for_csv_export( $form_id, $form ) { |
| 766 | 766 | $csv_fields = FrmField::get_all_for_form( $form_id, '', 'include', 'include' ); |
| 767 | 767 | $no_export_fields = FrmField::no_save_fields(); |
| @@ -781,14 +781,14 @@ | ||
| 781 | 781 | * @return array |
| 782 | 782 | */ |
| 783 | 783 | public static function allow_mime( $mimes ) { |
| 784 | 784 | if ( ! isset( $mimes['csv'] ) ) { |
| 785 | - // allow csv files | |
| 785 | + // Allow csv files | |
| 786 | 786 | $mimes['csv'] = 'text/csv'; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | if ( ! isset( $mimes['xml'] ) ) { |
| 790 | - // allow xml | |
| 790 | + // Allow xml | |
| 791 | 791 | $mimes['xml'] = 'text/xml'; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | return $mimes; |