| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Builders; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Helpers\Options_Helper; |
| 6 |
use Yoast\WP\SEO\Models\Indexable; |
| 7 |
use Yoast\WP\SEO\Values\Indexables\Indexable_Builder_Versions; |
| 8 |
|
| 9 |
/** |
| 10 |
* Date Archive Builder for the indexables. |
| 11 |
* |
| 12 |
* Formats the date archive meta to indexable format. |
| 13 |
*/ |
| 14 |
class Indexable_Date_Archive_Builder { |
| 15 |
|
| 16 |
/** |
| 17 |
* The options helper. |
| 18 |
* |
| 19 |
* @var Options_Helper |
| 20 |
*/ |
| 21 |
private $options; |
| 22 |
|
| 23 |
/** |
| 24 |
* The latest version of the Indexable_Date_Archive_Builder. |
| 25 |
* |
| 26 |
* @var int |
| 27 |
*/ |
| 28 |
protected $version; |
| 29 |
|
| 30 |
/** |
| 31 |
* Indexable_Date_Archive_Builder constructor. |
| 32 |
* |
| 33 |
* @param Options_Helper $options The options helper. |
| 34 |
* @param Indexable_Builder_Versions $versions The latest version for all indexable builders. |
| 35 |
*/ |
| 36 |
public function __construct( Options_Helper $options, Indexable_Builder_Versions $versions ) { |
| 37 |
$this->options = $options; |
| 38 |
$this->version = $versions->get_latest_version_for_type( 'date-archive' ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Formats the data. |
| 43 |
* |
| 44 |
* @param Indexable $indexable The indexable to format. |
| 45 |
* |
| 46 |
* @return Indexable The extended indexable. |
| 47 |
*/ |
| 48 |
public function build( $indexable ) { |
| 49 |
$indexable->object_type = 'date-archive'; |
| 50 |
$indexable->title = $this->options->get( 'title-archive-wpseo' ); |
| 51 |
$indexable->description = $this->options->get( 'metadesc-archive-wpseo' ); |
| 52 |
$indexable->is_robots_noindex = $this->options->get( 'noindex-archive-wpseo' ); |
| 53 |
$indexable->is_public = ( (int) $indexable->is_robots_noindex !== 1 ); |
| 54 |
$indexable->blog_id = \get_current_blog_id(); |
| 55 |
$indexable->permalink = null; |
| 56 |
$indexable->version = $this->version; |
| 57 |
|
| 58 |
return $indexable; |
| 59 |
} |
| 60 |
} |
| 61 |
|