WC_Product_CSV_Importer::parse_tags_spaces_field()
Parse a tag field from a CSV with space separators.
Метод класса: WC_Product_CSV_Importer{}
Хуков нет.
Возвращает
Массив
.
Использование
$WC_Product_CSV_Importer = new WC_Product_CSV_Importer(); $WC_Product_CSV_Importer->parse_tags_spaces_field( $value );
- $value(строка) (обязательный)
- Field value.
Код WC_Product_CSV_Importer::parse_tags_spaces_field() WC Product CSV Importer::parse tags spaces field WC 9.2.3
public function parse_tags_spaces_field( $value ) { if ( empty( $value ) ) { return array(); } $value = $this->unescape_data( $value ); $names = $this->explode_values( $value, ' ' ); $tags = array(); foreach ( $names as $name ) { $term = get_term_by( 'name', $name, 'product_tag' ); if ( ! $term || is_wp_error( $term ) ) { $term = (object) wp_insert_term( $name, 'product_tag' ); } if ( ! is_wp_error( $term ) ) { $tags[] = $term->term_id; } } return $tags; }