Taxonomy_Manager::get_attachment_taxonomy_term_id()

Gets the ID for the attachment taxonomy term that should be used for form uploads.

Description

The ID identifies a term of the attachment taxonomy to use for form uploads.

See also

Return

(int) Taxonomy term ID, or 0 if attachment taxonomies should not be used.

Source

File: src/db-objects/taxonomy-manager.php

	public function get_attachment_taxonomy_term_id() {
		$taxonomy_slug = $this->get_attachment_taxonomy_slug();
		if ( empty( $taxonomy_slug ) ) {
			return 0;
		}

		$options = $this->options()->get( 'general_settings', array() );
		$term_id = ! empty( $options['attachment_taxonomy_term_id'] ) ? $options['attachment_taxonomy_term_id'] : 0;
		if ( empty( $term_id ) ) {
			return 0;
		}

		$term = get_term_by( 'slug', $term_id, $taxonomy_slug );
		if ( ! $term ) {
			return 0;
		}

		return (int) $term->term_id;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.