WebSite.php
1.45 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
<?php
namespace AIOSEO\Plugin\Common\Schema\Graphs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WebSite graph class.
*
* @since 4.0.0
*/
class WebSite extends Graph {
/**
* Returns the graph data.
*
* @since 4.0.0
*
* @return array $data The graph data.
*/
public function get() {
$homeUrl = trailingslashit( home_url() );
$data = [
'@type' => 'WebSite',
'@id' => $homeUrl . '#website',
'url' => $homeUrl,
'name' => aioseo()->options->searchAppearance->global->schema->websiteName
? aioseo()->options->searchAppearance->global->schema->websiteName
: aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'name' ) ),
'alternateName' => aioseo()->options->searchAppearance->global->schema->websiteAlternateName,
'description' => aioseo()->helpers->decodeHtmlEntities( get_bloginfo( 'description' ) ),
'inLanguage' => aioseo()->helpers->currentLanguageCodeBCP47(),
'publisher' => [ '@id' => $homeUrl . '#' . aioseo()->options->searchAppearance->global->schema->siteRepresents ]
];
if ( is_front_page() && aioseo()->options->searchAppearance->advanced->sitelinks ) {
$data['potentialAction'] = [
'@type' => 'SearchAction',
'target' => [
'@type' => 'EntryPoint',
'urlTemplate' => $homeUrl . '?s={search_term_string}'
],
'query-input' => 'required name=search_term_string',
];
}
return $data;
}
}