WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wc_is_file_valid_csv() WC 3.6.5

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: woocommerce/includes/wc-conditional-functions.php WC 4.3.2

<?php
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.
	 */
	$check_import_file_path = apply_filters( 'woocommerce_csv_importer_check_import_file_path', true );

	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;
}