| 1 |
<?php |
| 2 |
/** |
| 3 |
* TablePress Table Import File Class |
| 4 |
* |
| 5 |
* @package TablePress |
| 6 |
* @subpackage Import |
| 7 |
* @author Tobias Bäthge |
| 8 |
* @since 2.3.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace TablePress\Import; |
| 12 |
|
| 13 |
// Prohibit direct script loading. |
| 14 |
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 15 |
|
| 16 |
/** |
| 17 |
* TablePress Table Import File Class |
| 18 |
* |
| 19 |
* @package TablePress |
| 20 |
* @subpackage Import |
| 21 |
* @author Tobias Bäthge |
| 22 |
* @since 2.3.0 |
| 23 |
*/ |
| 24 |
class File { |
| 25 |
|
| 26 |
/** |
| 27 |
* Local file path location of the file to import. |
| 28 |
* |
| 29 |
* @since 2.3.0 |
| 30 |
*/ |
| 31 |
public string $location = ''; |
| 32 |
|
| 33 |
/** |
| 34 |
* File extension of the file to import. |
| 35 |
* |
| 36 |
* @since 2.3.0 |
| 37 |
*/ |
| 38 |
public string $extension = ''; |
| 39 |
|
| 40 |
/** |
| 41 |
* MIME type of the file to import. |
| 42 |
* |
| 43 |
* @since 2.3.0 |
| 44 |
*/ |
| 45 |
public string $mime_type = ''; |
| 46 |
|
| 47 |
/** |
| 48 |
* Name of the file to import, used as the table name. |
| 49 |
* |
| 50 |
* @since 2.3.0 |
| 51 |
*/ |
| 52 |
public string $name = ''; |
| 53 |
|
| 54 |
/** |
| 55 |
* Error code related to the import of the file. |
| 56 |
* |
| 57 |
* @since 2.3.0 |
| 58 |
*/ |
| 59 |
public ?\WP_Error $error = null; |
| 60 |
|
| 61 |
/** |
| 62 |
* Whether the file should be kept or deleted after import. |
| 63 |
* |
| 64 |
* @since 2.3.0 |
| 65 |
*/ |
| 66 |
public bool $keep_file = false; |
| 67 |
|
| 68 |
/** |
| 69 |
* Creates a new File object, from an array of file properties. |
| 70 |
* |
| 71 |
* @since 1.0.0 |
| 72 |
* |
| 73 |
* @param array<string, string|bool|\WP_Error> $properties Array of file properties. |
| 74 |
*/ |
| 75 |
public function __construct( array $properties ) { |
| 76 |
foreach ( $properties as $property => $value ) { |
| 77 |
if ( property_exists( $this, $property ) ) { |
| 78 |
$this->$property = $value; |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
} // class File |
| 84 |
|