WC_Product_CSV_Importer_Controller::is_file_valid_csv( string $file, bool $check_path = true )

Check whether a file is a valid CSV file.


Description Description


Parameters Parameters

$file

(Required) File path.

$check_path

(Optional) Whether to also check the file is located in a valid location (Default: true).

Default value: true


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/admin/importers/class-wc-product-csv-importer-controller.php

94
95
96
97
98
99
100
101
102
103
104
105
106
public static function is_file_valid_csv( $file, $check_path = true ) {
    if ( $check_path && apply_filters( 'woocommerce_product_csv_importer_check_import_file_path', true ) && false !== stripos( $file, '://' ) ) {
        return false;
    }
 
    $valid_filetypes = self::get_valid_csv_filetypes();
    $filetype        = wp_check_filetype( $file, $valid_filetypes );
    if ( in_array( $filetype['type'], $valid_filetypes, true ) ) {
        return true;
    }
 
    return false;
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.