Code_Manager.php
4 years ago
Code_Manager_Dashboard.php
4 years ago
Code_Manager_Export.php
4 years ago
Code_Manager_Form.php
4 years ago
Code_Manager_Import.php
4 years ago
Code_Manager_Import_File.php
4 years ago
Code_Manager_List.php
4 years ago
Code_Manager_List_View.php
4 years ago
Code_Manager_Model.php
4 years ago
Code_Manager_Preview.php
4 years ago
Code_Manager_Settings.php
4 years ago
Code_Manager_Tabs.php
4 years ago
Message_Box.php
4 years ago
WP_List_Table.php
4 years ago
Code_Manager_Import.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Code_Manager { |
| 4 | |
| 5 | /** |
| 6 | * Class Code_Manager_Import |
| 7 | * |
| 8 | * Add import feature to plugin (reached from list table). |
| 9 | * |
| 10 | * @author Peter Schulz |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | class Code_Manager_Import { |
| 14 | |
| 15 | public static function import() { |
| 16 | if ( isset( $_FILES['filename'] ) && |
| 17 | UPLOAD_ERR_OK === $_FILES['filename']['error'] |
| 18 | && is_uploaded_file( $_FILES['filename']['tmp_name'] ) |
| 19 | ) { |
| 20 | // Get file content |
| 21 | $import_file = new Code_Manager_Import_File( $_FILES['filename']['tmp_name'] ); |
| 22 | $import_file->import(); |
| 23 | } else { |
| 24 | // File upload failed |
| 25 | $msg = new Message_Box( |
| 26 | [ |
| 27 | 'message_text' => __( 'File upload failed', 'code-manager' ), |
| 28 | 'message_type' => 'error', |
| 29 | 'message_is_dismissible' => false, |
| 30 | ] |
| 31 | ); |
| 32 | $msg->box(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | } |
| 37 | |
| 38 | } |