PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-seo/src/class-website-schema-node.php +69 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,69 @@
1 +<?php
2 +/**
3 + * Site-level WebSite Schema.org node builder.
4 + *
5 + * Builds the WebSite JSON-LD node from existing site identity: Site Title,
6 + * site URL, Tagline, site language, and core WordPress search.
7 + *
8 + * @package automattic/jetpack-seo-package
9 + */
10 +
11 +namespace Automattic\Jetpack\SEO;
12 +
13 +/**
14 + * Builds the site-level WebSite node.
15 + */
16 +class Website_Schema_Node {
17 +
18 + /**
19 + * Build the WebSite node, or null when the site has no name to identify it.
20 + *
21 + * @return array|null
22 + */
23 + public static function build() {
24 + $name = self::text( get_bloginfo( 'name' ) );
25 + if ( '' === $name ) {
26 + return null;
27 + }
28 +
29 + $node = array(
30 + '@type' => 'WebSite',
31 + '@id' => Schema_Node_Ids::website(),
32 + 'name' => $name,
33 + 'url' => home_url( '/' ),
34 + 'potentialAction' => array(
35 + '@type' => 'SearchAction',
36 + 'target' => array(
37 + '@type' => 'EntryPoint',
38 + 'urlTemplate' => home_url( '/?s={search_term_string}' ),
39 + ),
40 + 'query-input' => 'required name=search_term_string',
41 + ),
42 + );
43 +
44 + $description = self::text( get_bloginfo( 'description' ) );
45 + if ( '' !== $description ) {
46 + $node['description'] = $description;
47 + }
48 +
49 + $language = self::text( get_bloginfo( 'language' ) );
50 + if ( '' !== $language ) {
51 + $node['inLanguage'] = $language;
52 + }
53 +
54 + return $node;
55 + }
56 +
57 + /**
58 + * Normalize a scalar site value to trimmed plain text.
59 + *
60 + * @param mixed $value Raw value.
61 + * @return string
62 + */
63 + private static function text( $value ) {
64 + if ( ! is_string( $value ) ) {
65 + return '';
66 + }
67 + return trim( wp_strip_all_tags( $value ) );
68 + }
69 +}