| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @author Tobias Bäthge |
| 8 | 8 | * @since 1.0.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +declare(strict_types=1); | |
| 12 | + | |
| 11 | 13 | use TablePress\Import\File; |
| 12 | 14 | |
| 13 | 15 | // Prohibit direct script loading. |
| 14 | 16 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| @@ -243,8 +245,12 @@ | ||
| 243 | 245 | continue; |
| 244 | 246 | } |
| 245 | 247 | |
| 246 | 248 | $file->extension = strtolower( pathinfo( $file->name, PATHINFO_EXTENSION ) ); |
| 249 | + if ( '' === $file->extension ) { | |
| 250 | + // If the file name has no extension, try to get it from the location (as WordPress tries adding an extension to that based on the MIME type, e.g. when downloading files). | |
| 251 | + $file->extension = strtolower( pathinfo( $file->location, PATHINFO_EXTENSION ) ); | |
| 252 | + } | |
| 247 | 253 | |
| 248 | 254 | if ( function_exists( 'mime_content_type' ) ) { |
| 249 | 255 | $mime_type = mime_content_type( $file->location ); |
| 250 | 256 | if ( false !== $mime_type ) { |