PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
wordpress-seo / src / presentations / indexable-search-result-page-presentation.php

indexable-search-result-page-presentation.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/presentations/indexable-search-result-page-presentation.php

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