WC_Product_CSV_Importer_Controller::import() public WC 1.0
Import the file if it exists and is valid.
{} Это метод класса: WC_Product_CSV_Importer_Controller{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WC_Product_CSV_Importer_Controller = new WC_Product_CSV_Importer_Controller(); $WC_Product_CSV_Importer_Controller->import();
Код WC_Product_CSV_Importer_Controller::import() WC Product CSV Importer Controller::import WC 5.0.0
public function import() {
// Displaying this page triggers Ajax action to run the import with a valid nonce,
// therefore this page needs to be nonce protected as well.
check_admin_referer( 'woocommerce-csv-importer' );
if ( ! self::is_file_valid_csv( $this->file ) ) {
$this->add_error( __( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
$this->output_errors();
return;
}
if ( ! is_file( $this->file ) ) {
$this->add_error( __( 'The file does not exist, please try again.', 'woocommerce' ) );
$this->output_errors();
return;
}
if ( ! empty( $_POST['map_from'] ) && ! empty( $_POST['map_to'] ) ) {
$mapping_from = wc_clean( wp_unslash( $_POST['map_from'] ) );
$mapping_to = wc_clean( wp_unslash( $_POST['map_to'] ) );
// Save mapping preferences for future imports.
update_user_option( get_current_user_id(), 'woocommerce_product_import_mapping', $mapping_to );
} else {
wp_redirect( esc_url_raw( $this->get_next_step_link( 'upload' ) ) );
exit;
}
wp_localize_script(
'wc-product-import',
'wc_product_import_params',
array(
'import_nonce' => wp_create_nonce( 'wc-product-import' ),
'mapping' => array(
'from' => $mapping_from,
'to' => $mapping_to,
),
'file' => $this->file,
'update_existing' => $this->update_existing,
'delimiter' => $this->delimiter,
)
);
wp_enqueue_script( 'wc-product-import' );
include_once dirname( __FILE__ ) . '/views/html-csv-import-progress.php';
}