WC_Product_CSV_Importer::parse_tags_field()
Parse a tag field from a CSV.
Method of the class: WC_Product_CSV_Importer{}
No Hooks.
Return
Array
.
Usage
$WC_Product_CSV_Importer = new WC_Product_CSV_Importer(); $WC_Product_CSV_Importer->parse_tags_field( $value );
- $value(string) (required)
- Field value.
WC_Product_CSV_Importer::parse_tags_field() WC Product CSV Importer::parse tags field code WC 9.5.1
public function parse_tags_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; }