WC_Tax_Rate_Importer::greet()publicWC 1.0

Output information about the uploading process.

Method of the class: WC_Tax_Rate_Importer{}

Hooks from the method

Return

null. Nothing (null).

Usage

$WC_Tax_Rate_Importer = new WC_Tax_Rate_Importer();
$WC_Tax_Rate_Importer->greet();

WC_Tax_Rate_Importer::greet() code WC 8.6.1

<?php
public function greet() {

	echo '<div class="narrow">';
	echo '<p>' . esc_html__( 'Hi there! Upload a CSV file containing tax rates to import the contents into your shop. Choose a .csv file to upload, then click "Upload file and import".', 'woocommerce' ) . '</p>';

	/* translators: 1: Link to tax rates sample file 2: Closing link. */
	echo '<p>' . sprintf( esc_html__( 'Your CSV needs to include columns in a specific order. %1$sClick here to download a sample%2$s.', 'woocommerce' ), '<a href="' . esc_url( WC()->plugin_url() ) . '/sample-data/sample_tax_rates.csv">', '</a>' ) . '</p>';

	$action = 'admin.php?import=woocommerce_tax_rate_csv&step=1';

	$bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
	$size       = size_format( $bytes );
	$upload_dir = wp_upload_dir();
	if ( ! empty( $upload_dir['error'] ) ) :
		?>
		<div class="error">
			<p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p>
			<p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p>
		</div>
	<?php else : ?>
		<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>">
			<table class="form-table">
				<tbody>
					<tr>
						<th>
							<label for="upload"><?php esc_html_e( 'Choose a file from your computer:', 'woocommerce' ); ?></label>
						</th>
						<td>
							<input type="file" id="upload" name="import" size="25" />
							<input type="hidden" name="action" value="save" />
							<input type="hidden" name="max_file_size" value="<?php echo absint( $bytes ); ?>" />
							<small>
								<?php
								printf(
									/* translators: %s: maximum upload size */
									esc_html__( 'Maximum size: %s', 'woocommerce' ),
									esc_attr( $size )
								);
								?>
							</small>
						</td>
					</tr>
					<tr>
						<th>
							<label for="file_url"><?php esc_html_e( 'OR enter path to file:', 'woocommerce' ); ?></label>
						</th>
						<td>
							<?php echo ' ' . esc_html( ABSPATH ) . ' '; ?><input type="text" id="file_url" name="file_url" size="25" />
						</td>
					</tr>
					<tr>
						<th><label><?php esc_html_e( 'Delimiter', 'woocommerce' ); ?></label><br/></th>
						<td><input type="text" name="delimiter" placeholder="," size="2" /></td>
					</tr>
				</tbody>
			</table>
			<p class="submit">
				<button type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import', 'woocommerce' ); ?>"><?php esc_html_e( 'Upload file and import', 'woocommerce' ); ?></button>
			</p>
		</form>
		<?php
	endif;

	echo '</div>';
}