| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Values\Indexables; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Indexable_Builder_Versions |
| 7 |
*/ |
| 8 |
class Indexable_Builder_Versions { |
| 9 |
|
| 10 |
const DEFAULT_INDEXABLE_BUILDER_VERSION = 1; |
| 11 |
|
| 12 |
/** |
| 13 |
* The list of indexable builder versions defined by Yoast SEO Free. |
| 14 |
* If the key is not in this list, the indexable type will not be managed. |
| 15 |
* These numbers should be increased if one of the builders implements a new feature. |
| 16 |
* |
| 17 |
* @var array |
| 18 |
*/ |
| 19 |
protected $indexable_builder_versions_by_type = [ |
| 20 |
'date-archive' => self::DEFAULT_INDEXABLE_BUILDER_VERSION, |
| 21 |
'general' => self::DEFAULT_INDEXABLE_BUILDER_VERSION, |
| 22 |
'home-page' => 2, |
| 23 |
'post' => 2, |
| 24 |
'post-type-archive' => 2, |
| 25 |
'term' => 2, |
| 26 |
'user' => 2, |
| 27 |
'system-page' => self::DEFAULT_INDEXABLE_BUILDER_VERSION, |
| 28 |
]; |
| 29 |
|
| 30 |
/** |
| 31 |
* Provides the most recent version number for an Indexable's object type. |
| 32 |
* |
| 33 |
* @param string $object_type The Indexable type for which you want to know the most recent version. |
| 34 |
* |
| 35 |
* @return int The most recent version number for the type, or 1 if the version doesn't exist. |
| 36 |
*/ |
| 37 |
public function get_latest_version_for_type( $object_type ) { |
| 38 |
if ( ! \array_key_exists( $object_type, $this->indexable_builder_versions_by_type ) ) { |
| 39 |
return self::DEFAULT_INDEXABLE_BUILDER_VERSION; |
| 40 |
} |
| 41 |
|
| 42 |
return $this->indexable_builder_versions_by_type[ $object_type ]; |
| 43 |
} |
| 44 |
} |
| 45 |
|