Prepare terms if `--by=<field>` flag is used

@param array $terms
@param string $field
@param string $taxonomy
500655
protected function prepare_terms( $field, $terms, $taxonomy ) {
		if ( 'id' === $field ) {
			$new_terms = [];
			foreach ( $terms as $term_id ) {
				$term = get_term_by( 'term_id', $term_id, $taxonomy );
				if ( $term ) {
					$new_terms[] = $term->slug;
				}
			}
			$terms = $new_terms;
		}
		return $terms;
	}
776969
public function addTerm(Term $term)
    {
        if (false === $this->terms->contains($term)) {
            $this->terms->add($term);
        }

        return $this;
    }
993685
function deleteTerms( termMap, existingTerms, callback ) {
			if ( this.verbose ) {
				this.log( "Deleting old terms..." );
			}

			async.map( Object.keys( existingTerms ), function( taxonomy, callback ) {
				var terms = existingTerms[ taxonomy ];
				this.forEach( Object.keys( terms ), function( term, callback ) {
					this.deleteTerm( terms[ term ], callback );
				}, callback );
			}.bind( this ), function( error ) {
				if ( error ) {
					return callback( error );
				}

				if ( this.verbose ) {
					this.log( "Deleted all old terms." );
				}

				callback( null, termMap );
			}.bind( this ));
		}
1253879
protected function setTerms($terms)
    {
        if (false === is_array($terms)) {
            throw new TransformationFailure('Taxonomy terms must be an array');
        }

        $this->terms = $terms;

        return $this;
    }
253351
public function scopeWithTerm($query, $term_name, $taxonomy)
    {
        $term_ids = Taxonomy::where('taxonomy', $taxonomy)->pluck('term_id');

        $term     = Term::whereIn('id', $term_ids)->where('name', $term_name)->first();
        $taxonomy = Taxonomy::where('term_id', $term->id)->first();

        return $query->whereHas('taxonomies', function($q) use($term, $taxonomy) {
            $q->where('term_id', $term->id);
        });
    }
512825
public function make(TaxonomyInterface $taxonomy, array $options = []): TaxonomyField
    {
        $this->taxonomy = $taxonomy;
        $this->options = $options;

        return $this;
    }
611713
public function commonTerm($field, $term, array $attributes = [])
    {
        $query = new CommonTermsQuery($field, $term, $attributes);

        $this->append($query);

        return $this;
    }
789258
function delete_term( $term, $tt_id, $taxonomy, $deleted_term )
	{
		global $wpdb;
		
		$values = $wpdb->query($wpdb->prepare(
			"DELETE FROM $wpdb->options WHERE option_name LIKE %s",
			'%' . $taxonomy . '_' . $term . '%'
		));
	}
60206
public function prefix($field, $term, array $attributes = [])
    {
        $query = new PrefixQuery($field, $term, $attributes);

        $this->append($query);

        return $this;
    }
106330
public void delete(Term term) {
        Log.debug(String.format("Deleting by term %s", term));
        try {
            indexWriter.deleteDocuments(term);
        } catch (IOException e) {
            Log.error(e, "Error while deleting by term %s", term);
            throw new RuntimeException(e);
        }
    }
1003134
public void addTerm(OntologyTerm term) {
        terms.put(term.getId(), term);
        indexTerm(term);
        isTypeOfIsBuilt = false;
    }
189313
public function hasTerm($term_id)
    {
        $taxonomy_terms = $this->getTerms();
        if (!Arr::iterable($taxonomy_terms)) {
            return false;
        }

        foreach ($taxonomy_terms as $taxonomy_key => $terms) {
            if (!Arr::iterable($terms)) {
                continue;
            }

            foreach ($terms as $term) {
                if ((int) $term->term_id === (int) $term_id) {
                    return true;
                }
            }
        }

        return false;
    }
1161752
public function col_taxonomy( string $taxonomy, array $args ) {

		global $post;

		$terms = get_the_terms( $post, $taxonomy );
		$tax   = get_taxonomy( $taxonomy );

		if ( is_wp_error( $terms ) ) {
			echo esc_html( $terms->get_error_message() );
			return;
		}

		if ( empty( $terms ) ) {
			printf(
				'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
				esc_html( $tax->labels->no_terms )
			);
			return;
		}

		$out = [];

		foreach ( $terms as $term ) {

			if ( $args['link'] ) {

				switch ( $args['link'] ) {
					case 'view':
						if ( $tax->public ) {
							// https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1096
							// @codingStandardsIgnoreStart
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_term_link( $term ) ),
								esc_html( $term->name )
							);
							// @codingStandardsIgnoreEnd
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'edit':
						if ( current_user_can( $tax->cap->edit_terms ) ) {
							$out[] = sprintf(
								'<a href="%1$s">%2$s</a>',
								esc_url( get_edit_term_link( $term, $taxonomy, $post->post_type ) ),
								esc_html( $term->name )
							);
						} else {
							$out[] = esc_html( $term->name );
						}
						break;
					case 'list':
						$link = add_query_arg( [
							'post_type' => $post->post_type,
							$taxonomy   => $term->slug,
						], admin_url( 'edit.php' ) );
						$out[] = sprintf(
							'<a href="%1$s">%2$s</a>',
							esc_url( $link ),
							esc_html( $term->name )
						);
						break;
				}
			} else {

				$out[] = esc_html( $term->name );

			}
		}

		echo implode( ', ', $out ); // WPCS: XSS ok.

	}
357564
public function terms($taxonomy = null, array $arguments = [])
    {
        if (isset($taxonomy)) {
            return $this->model->getTerms($this, $taxonomy, $arguments);
        }

        return $this->model->getAllTerms($this);
    }
189251
public function termCreate($term)
    {
        $this->dispatchHooks('BeforeTermCreateScope', $term);
        $this->parseEntityFields('taxonomy_term', $term);
        $saved = $this->getDriver()->createTerm($term);
        $this->dispatchHooks('AfterTermCreateScope', $saved);
        $this->terms[] = $saved;
        return $saved;
    }
279283
public static function get_taxonomy_field( $taxonomy_term, $field = '' ) {
		if ( is_a( $taxonomy_term, 'WP_Term' ) ) {
			return self::get_field( $taxonomy_term, $field );
		} elseif ( is_array( $taxonomy_term ) && count( $taxonomy_term ) >= 2 ) {
			return self::get_field( "{$taxonomy_term[0]}_{$taxonomy_term[1]}", $field );
		}
		throw new \Exception( '$taxonomy_term must be either a term object or an array of [$taxonomy, $term_id]' );
	}
367074
public function addTerm(Term $term)
    {
        if (false === $this->hasTerm($term)) {
            $this->terms->add($term);
        }

        return $this;
    }