wc_is_file_valid_csv()
Check if a CSV file is valid.
Хуки из функции
Возвращает
true|false
.
Использование
wc_is_file_valid_csv( $file, $check_path );
- $file(строка) (обязательный)
- File name.
- $check_path(true|false)
- If should check for the path.
По умолчанию: true
Список изменений
С версии 3.6.5 | Введена. |
Код wc_is_file_valid_csv() wc is file valid csv WC 9.3.1
function wc_is_file_valid_csv( $file, $check_path = true ) { /** * Filter check for CSV file path. * * @since 3.6.4 * @param bool $check_import_file_path If requires file path check. Defaults to true. * @param string $file Path of the file to be checked. */ $check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true, $file ); if ( $check_path && $check_import_file_path && false !== stripos( $file, '://' ) ) { return false; } /** * Filter CSV valid file types. * * @since 3.6.5 * @param array $valid_filetypes List of valid file types. */ $valid_filetypes = apply_filters( 'woocommerce_csv_import_valid_filetypes', array( 'csv' => 'text/csv', 'txt' => 'text/plain', ) ); $filetype = wp_check_filetype( $file, $valid_filetypes ); if ( in_array( $filetype['type'], $valid_filetypes, true ) ) { return true; } return false; }