WC_Tax_Rate_Importer::handle_upload() public WC 1.0
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 5.0.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->import_error( $file['error'] );
}
if ( ! wc_is_file_valid_csv( $file['file'], false ) ) {
// Remove file if not valid.
wp_delete_attachment( $file['id'], true );
$this->import_error( __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
$this->id = absint( $file['id'] );
} elseif ( file_exists( ABSPATH . $file_url ) ) {
if ( ! wc_is_file_valid_csv( ABSPATH . $file_url ) ) {
$this->import_error( __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
$this->file_url = esc_attr( $file_url );
} else {
$this->import_error();
}
return true;
}