Yoast\WP\SEO\Dashboard\Infrastructure\Taxonomies

Taxonomy_Validator{}Yoast 1.0

Class that validates taxonomies.

Хуков нет.

Использование

$Taxonomy_Validator = new Taxonomy_Validator();
// use class methods

Методы

  1. public is_valid_taxonomy( $taxonomy, string $content_type )

Код Taxonomy_Validator{} Yoast 24.4

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 );
	}
}