| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Presentations; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Indexable_Post_Type_Archive_Presentation. |
| 7 |
* |
| 8 |
* Presentation object for indexables. |
| 9 |
*/ |
| 10 |
class Indexable_Post_Type_Archive_Presentation extends Indexable_Presentation { |
| 11 |
|
| 12 |
use Archive_Adjacent; |
| 13 |
|
| 14 |
/** |
| 15 |
* Generates the canonical. |
| 16 |
* |
| 17 |
* @return string The canonical. |
| 18 |
*/ |
| 19 |
public function generate_canonical() { |
| 20 |
$permalink = $this->get_permalink(); |
| 21 |
if ( ! $permalink ) { |
| 22 |
return ''; |
| 23 |
} |
| 24 |
|
| 25 |
$current_page = $this->pagination->get_current_archive_page_number(); |
| 26 |
if ( $current_page > 1 ) { |
| 27 |
return $this->pagination->get_paginated_url( $permalink, $current_page ); |
| 28 |
} |
| 29 |
|
| 30 |
return $permalink; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Generates the robots value. |
| 35 |
* |
| 36 |
* @return array The robots value. |
| 37 |
*/ |
| 38 |
public function generate_robots() { |
| 39 |
$robots = $this->get_base_robots(); |
| 40 |
|
| 41 |
if ( $this->options->get( 'noindex-ptarchive-' . $this->model->object_sub_type, false ) ) { |
| 42 |
$robots['index'] = 'noindex'; |
| 43 |
} |
| 44 |
|
| 45 |
return $this->filter_robots( $robots ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Generates the title. |
| 50 |
* |
| 51 |
* @return string The title. |
| 52 |
*/ |
| 53 |
public function generate_title() { |
| 54 |
if ( $this->model->title ) { |
| 55 |
return $this->model->title; |
| 56 |
} |
| 57 |
|
| 58 |
$post_type = $this->model->object_sub_type; |
| 59 |
$title = $this->options->get_title_default( 'title-ptarchive-' . $post_type ); |
| 60 |
|
| 61 |
return $title; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Generates the source. |
| 66 |
* |
| 67 |
* @return array The source. |
| 68 |
*/ |
| 69 |
public function generate_source() { |
| 70 |
return [ 'post_type' => $this->model->object_sub_type ]; |
| 71 |
} |
| 72 |
} |
| 73 |
|