Yoast\WP\SEO\Dashboard\Infrastructure\Taxonomies

Taxonomy_Validator::is_valid_taxonomypublicYoast 1.0

Returns whether the taxonomy in question is valid and associated with a given content type.

Метод класса: Taxonomy_Validator{}

Хуков нет.

Возвращает

true|false. Whether the taxonomy in question is valid.

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

$Taxonomy_Validator = new Taxonomy_Validator();
$Taxonomy_Validator->is_valid_taxonomy( $taxonomy, $content_type ): bool;
$taxonomy(WP_Taxonomy|false|null) (обязательный)
The taxonomy to check.
$content_type(строка) (обязательный)
The name of the content type to check.

Код Taxonomy_Validator::is_valid_taxonomy() Yoast 27.5

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