diff --git a/includes/admin/importers/class-wc-product-csv-importer-controller.php b/includes/admin/importers/class-wc-product-csv-importer-controller.php index 52f6d4275a5..99abc461769 100644 --- a/includes/admin/importers/class-wc-product-csv-importer-controller.php +++ b/includes/admin/importers/class-wc-product-csv-importer-controller.php @@ -329,6 +329,13 @@ class WC_Product_CSV_Importer_Controller { } return ABSPATH . $file_url; + } elseif ( file_exists( $file_url ) ) { + $filetype = wp_check_filetype( $file_url, $valid_filetypes ); + if ( ! in_array( $filetype['type'], $valid_filetypes, true ) ) { + return new WP_Error( 'woocommerce_product_csv_importer_upload_file_invalid', __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) ); + } + + return $file_url; } // phpcs:enable