Automattic\WooCommerce\Admin\API
OnboardingTasks::get_header_mappings()
Get header mappings from CSV columns.
Метод класса: OnboardingTasks{}
Хуки из метода
Возвращает
Массив
. Mapped headers.
Использование
$result = OnboardingTasks::get_header_mappings( $file );
- $file(строка) (обязательный)
- File path.
Код OnboardingTasks::get_header_mappings() OnboardingTasks::get header mappings WC 9.3.3
public static function get_header_mappings( $file ) { include_once WC_ABSPATH . 'includes/admin/importers/mappings/mappings.php'; $importer_class = apply_filters( 'woocommerce_product_csv_importer_class', 'WC_Product_CSV_Importer' ); $importer = new $importer_class( $file, array() ); $raw_headers = $importer->get_raw_keys(); $default_columns = wc_importer_default_english_mappings( array() ); $special_columns = wc_importer_default_special_english_mappings( array() ); $headers = array(); foreach ( $raw_headers as $key => $field ) { $index = $field; $headers[ $index ] = $field; if ( isset( $default_columns[ $field ] ) ) { $headers[ $index ] = $default_columns[ $field ]; } else { foreach ( $special_columns as $regex => $special_key ) { if ( preg_match( self::sanitize_special_column_name_regex( $regex ), $field, $matches ) ) { $headers[ $index ] = $special_key . $matches[1]; break; } } } } return $headers; }