indexable-search-result-page-presentation.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Yoast\WP\SEO\Presentations;
/**
* Class Indexable_Search_Result_Page_Presentation.
*
* Presentation object for indexables.
*/
class Indexable_Search_Result_Page_Presentation extends Indexable_Presentation {
/**
* Generates the robots value.
*
* @return array The robots value.
*/
public function generate_robots() {
$robots = $this->get_base_robots();
$robots['index'] = 'noindex';
return $this->filter_robots( $robots );
}
/**
* Generates the title.
*
* @return string The title.
*/
public function generate_title() {
if ( $this->model->title ) {
return $this->model->title;
}
return $this->options->get_title_default( 'title-search-wpseo' );
}
/**
* Generates the Twitter title.
*
* @return string The Twitter title.
*/
public function generate_twitter_title() {
return $this->title;
}
/**
* Generates the Open Graph URL.
*
* @return string The Open Graph URL.
*/
public function generate_open_graph_url() {
$search_query = \get_search_query();
// Regex catches case when /search/page/N without search term is itself mistaken for search term.
if ( ! empty( $search_query ) && ! \preg_match( '|^page/\d+$|', $search_query ) ) {
return \get_search_link();
}
return '';
}
/**
* Generates the Open Graph type.
*
* @return string The Open Graph type.
*/
public function generate_open_graph_type() {
return 'article';
}
}