WC_Tax_Rate_Importer::handle_upload()
Handles the CSV upload and initial parsing of the file to prepare for. displaying author import options.
Метод класса: WC_Tax_Rate_Importer{}
Хуков нет.
Возвращает
true|false
. False if error uploading or invalid file, true otherwise
Использование
$WC_Tax_Rate_Importer = new WC_Tax_Rate_Importer(); $WC_Tax_Rate_Importer->handle_upload();
Код WC_Tax_Rate_Importer::handle_upload() WC Tax Rate Importer::handle upload WC 8.7.0
public function handle_upload() { $file_url = isset( $_POST['file_url'] ) ? wc_clean( wp_unslash( $_POST['file_url'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce already verified in WC_Tax_Rate_Importer::dispatch() if ( empty( $file_url ) ) { $file = wp_import_handle_upload(); if ( isset( $file['error'] ) ) { $this->set_import_error_message( $file['error'] ); return false; } if ( ! wc_is_file_valid_csv( $file['file'], false ) ) { // Remove file if not valid. wp_delete_attachment( $file['id'], true ); $this->set_import_error_message( __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) ); return false; } $this->id = absint( $file['id'] ); } elseif ( ( 0 === stripos( realpath( ABSPATH . $file_url ), ABSPATH ) ) && file_exists( ABSPATH . $file_url ) ) { if ( ! wc_is_file_valid_csv( ABSPATH . $file_url ) ) { $this->set_import_error_message( __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) ); return false; } $this->file_url = esc_attr( $file_url ); } else { return false; } return true; }