PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.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
← All changes | src/helpers/robots-helper.php +48 -0 18.7 → 28.5 View file →
@@ -1,12 +1,60 @@
1 1 <?php
2 2
3 3 namespace Yoast\WP\SEO\Helpers;
4 4
5 +use Yoast\WP\SEO\Models\Indexable;
6 +
5 7 /**
6 8 * A helper object for the robots meta tag.
7 9 */
8 10 class Robots_Helper {
11 +
12 + /**
13 + * Holds the Post_Type_Helper.
14 + *
15 + * @var Post_Type_Helper
16 + */
17 + protected $post_type_helper;
18 +
19 + /**
20 + * Holds the Taxonomy_Helper.
21 + *
22 + * @var Taxonomy_Helper
23 + */
24 + protected $taxonomy_helper;
25 +
26 + /**
27 + * Constructs a Score_Helper.
28 + *
29 + * @param Post_Type_Helper $post_type_helper The Post_Type_Helper.
30 + * @param Taxonomy_Helper $taxonomy_helper The Taxonomy_Helper.
31 + */
32 + public function __construct( Post_Type_Helper $post_type_helper, Taxonomy_Helper $taxonomy_helper ) {
33 + $this->post_type_helper = $post_type_helper;
34 + $this->taxonomy_helper = $taxonomy_helper;
35 + }
36 +
37 + /**
38 + * Retrieves whether the Indexable is indexable.
39 + *
40 + * @param Indexable $indexable The Indexable.
41 + *
42 + * @return bool Whether the Indexable is indexable.
43 + */
44 + public function is_indexable( Indexable $indexable ) {
45 + if ( $indexable->is_robots_noindex === null ) {
46 + // No individual value set, check the global setting.
47 + switch ( $indexable->object_type ) {
48 + case 'post':
49 + return $this->post_type_helper->is_indexable( $indexable->object_sub_type );
50 + case 'term':
51 + return $this->taxonomy_helper->is_indexable( $indexable->object_sub_type );
52 + }
53 + }
54 +
55 + return $indexable->is_robots_noindex === false;
56 + }
9 57
10 58 /**
11 59 * Sets the robots index to noindex.
12 60 *