| 62 | | if ( !isset($_FILES['import']) ) { |
| 63 | | $file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); |
| 64 | | return $file; |
| 65 | | } |
| | 62 | if($_POST['import_url']) { |
| | 63 | $wrx_url = esc_url($_POST['import_url'], null, 'url'); |
| | 64 | if($wrx_url) { |
| | 65 | $wrx_content = wp_remote_fopen($wrx_url); |
| | 66 | $file = wp_upload_bits(basename($wrx_url) . ".txt", null, $wrx_content); |
| | 67 | } else { |
| | 68 | $file['error'] = __( 'The URL you entered is empty or invalid.' ); |
| | 69 | return $file; |
| | 70 | } |
| | 71 | } else { |
| | 72 | if ( !isset($_FILES['import']) ) { |
| | 73 | $file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); |
| | 74 | return $file; |
| | 75 | } else { |
| | 76 | $overrides = array( 'test_form' => false, 'test_type' => false ); |
| | 77 | $_FILES['import']['name'] .= '.txt'; |
| | 78 | $file = wp_handle_upload( $_FILES['import'], $overrides ); |
| | 79 | if ( isset( $file['error'] ) ) |
| | 80 | return $file; |
| | 81 | } |
| | 82 | } |