# wordpress-seo/27.8/src/dashboard/infrastructure/taxonomies/taxonomy-validator.php

Yoast SEO – Advanced SEO with real-time guidance and built-in AI, version 27.8. 28 lines.

- Page: https://pluginprobe.com/plugins/wordpress-seo/27.8/code/src/dashboard/infrastructure/taxonomies/taxonomy-validator.php
- Raw: https://pluginprobe.com/plugins/wordpress-seo/27.8/raw/src/dashboard/infrastructure/taxonomies/taxonomy-validator.php
- Modified: 2025-04-07T09:46:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wordpress-seo/27.8/code/src/dashboard/infrastructure/taxonomies/taxonomy-validator.php#L10-L20`.

```php
<?php

// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Taxonomies;

use WP_Taxonomy;

/**
 * Class that validates taxonomies.
 */
class Taxonomy_Validator {

	/**
	 * Returns whether the taxonomy in question is valid and associated with a given content type.
	 *
	 * @param WP_Taxonomy|false|null $taxonomy     The taxonomy to check.
	 * @param string                 $content_type The name of the content type to check.
	 *
	 * @return bool Whether the taxonomy in question is valid.
	 */
	public function is_valid_taxonomy( $taxonomy, string $content_type ): bool {
		return \is_a( $taxonomy, 'WP_Taxonomy' )
			&& $taxonomy->public
			&& $taxonomy->show_in_rest
			&& \in_array( $taxonomy->name, \get_object_taxonomies( $content_type ), true );
	}
}

```
