PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / dashboard / infrastructure / taxonomies / taxonomy-validator.php

taxonomy-validator.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.5, at src/dashboard/infrastructure/taxonomies/taxonomy-validator.php

28 lines 816 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Dashboard\Infrastructure\Taxonomies;
5
6 use WP_Taxonomy;
7
8 /**
9 * Class that validates taxonomies.
10 */
11 class Taxonomy_Validator {
12
13 /**
14 * Returns whether the taxonomy in question is valid and associated with a given content type.
15 *
16 * @param WP_Taxonomy|false|null $taxonomy The taxonomy to check.
17 * @param string $content_type The name of the content type to check.
18 *
19 * @return bool Whether the taxonomy in question is valid.
20 */
21 public function is_valid_taxonomy( $taxonomy, string $content_type ): bool {
22 return \is_a( $taxonomy, 'WP_Taxonomy' )
23 && $taxonomy->public
24 && $taxonomy->show_in_rest
25 && \in_array( $taxonomy->name, \get_object_taxonomies( $content_type ), true );
26 }
27 }
28