classes/Tools/Rekognition/RekognitionTool.php
private function processTags($tags, $tax, $postID) {
		if (empty($tags)) {
			return;
		}

		$tagsToAdd = [];
		foreach($tags as $tag) {
			$term = false;
			if (term_exists($tag['tag'], $tax)) {
				$term = get_term_by('name', $tag['tag'], $tax);
			} else {
				$parent = false;
				if (isset($tag['parent'])) {
					if (!term_exists($tag['parent'])) {
						$parentTermInfo = wp_insert_term($tag['parent'], $tax);
						$parent = get_term_by('id', $parentTermInfo['term_id'], $tax);
					} else {
						$parent = get_term_by('name', $tag['parent'], $tax);
					}
				}

				$tagInfo = [];

				if ($parent) {
					$tagInfo['parent'] = $parent->term_id;
				}

				$tagInfo = wp_insert_term($tag['tag'], $tax, $tagInfo);
				$term = get_term_by('id', $tagInfo['term_id'], $tax);
			}

			if ($term) {
				$tagsToAdd[] = $term->term_id;
			}
		}

		if (!empty($tagsToAdd)) {
			wp_set_object_terms($postID, $tagsToAdd, $tax, true);
		}
	}
private function processTags($tags, $tax, $postID) {
		if (empty($tags)) {
			return;
		}

		$tagsToAdd = [];
		foreach($tags as $tag) {
			$term = false;
			if (term_exists($tag['tag'], $tax)) {
				$term = get_term_by('name', $tag['tag'], $tax);
			} else {
				$parent = false;
				if (isset($tag['parent'])) {
					if (!term_exists($tag['parent'])) {
						$parentTermInfo = wp_insert_term($tag['parent'], $tax);
						$parent = get_term_by('id', $parentTermInfo['term_id'], $tax);
					} else {
						$parent = get_term_by('name', $tag['parent'], $tax);
					}
				}

				$tagInfo = [];

				if ($parent) {
					$tagInfo['parent'] = $parent->term_id;
				}

				$tagInfo = wp_insert_term($tag['tag'], $tax, $tagInfo);
				$term = get_term_by('id', $tagInfo['term_id'], $tax);
			}

			if ($term) {
				$tagsToAdd[] = $term->term_id;
			}
		}

		if (!empty($tagsToAdd)) {
			wp_set_object_terms($postID, $tagsToAdd, $tax, true);
		}
	}
private function processTags ( $ tags , $ tax , $ postID ) { if ( empty ( $ tags ) ) { return ; } $ tagsToAdd = [ ] ; foreach ( $ tags as $ tag ) { $ term = false ; if ( term_exists ( $ tag [ 'tag' ] , $ tax ) ) { $ term = get_term_by ( 'name' , $ tag [ 'tag' ] , $ tax ) ; } else { $ parent = false ; if ( isset ( $ tag [ 'parent' ] ) ) { if ( ! term_exists ( $ tag [ 'parent' ] ) ) { $ parentTermInfo = wp_insert_term ( $ tag [ 'parent' ] , $ tax ) ; $ parent = get_term_by ( 'id' , $ parentTermInfo [ 'term_id' ] , $ tax ) ; } else { $ parent = get_term_by ( 'name' , $ tag [ 'parent' ] , $ tax ) ; } } $ tagInfo = [ ] ; if ( $ parent ) { $ tagInfo [ 'parent' ] = $ parent -> term_id ; } $ tagInfo = wp_insert_term ( $ tag [ 'tag' ] , $ tax , $ tagInfo ) ; $ term = get_term_by ( 'id' , $ tagInfo [ 'term_id' ] , $ tax ) ; } if ( $ term ) { $ tagsToAdd [ ] = $ term -> term_id ; } } if ( ! empty ( $ tagsToAdd ) ) { wp_set_object_terms ( $ postID , $ tagsToAdd , $ tax , true ) ; } }
Process the tags found with Rekognition

@param array $tags
@param string $tax
@param int $postID
Process the tags found with Rekognition