• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/generators/schema/website.php
1
<?php
2

3
namespace Yoast\WP\SEO\Generators\Schema;
4

5
use Yoast\WP\SEO\Config\Schema_IDs;
6

7
/**
8
 * Returns schema Website data.
9
 */
10
class Website extends Abstract_Schema_Piece {
11

12
        /**
13
         * Determines whether or not a piece should be added to the graph.
14
         *
15
         * @return bool
16
         */
17
        public function is_needed() {
18
                return true;
×
19
        }
20

21
        /**
22
         * Outputs code to allow recognition of the internal search engine.
23
         *
24
         * @return array Website data blob.
25
         */
26
        public function generate() {
27
                $data = [
×
28
                        '@type'       => 'WebSite',
×
29
                        '@id'         => $this->context->site_url . Schema_IDs::WEBSITE_HASH,
×
30
                        'url'         => $this->context->site_url,
×
31
                        'name'        => $this->helpers->schema->html->smart_strip_tags( $this->context->site_name ),
×
32
                        'description' => \get_bloginfo( 'description' ),
×
33
                ];
×
34

35
                if ( $this->context->site_represents_reference ) {
×
36
                        $data['publisher'] = $this->context->site_represents_reference;
×
37
                }
38

39
                $data = $this->add_alternate_name( $data );
×
40
                $data = $this->internal_search_section( $data );
×
41
                $data = $this->helpers->schema->language->add_piece_language( $data );
×
42

43
                return $data;
×
44
        }
45

46
        /**
47
         * Returns an alternate name if one was specified in the Yoast SEO settings.
48
         *
49
         * @param array $data The website data array.
50
         *
51
         * @return array
52
         */
53
        private function add_alternate_name( $data ) {
54
                if ( $this->context->alternate_site_name !== '' ) {
×
55
                        $data['alternateName'] = $this->helpers->schema->html->smart_strip_tags( $this->context->alternate_site_name );
×
56
                }
57

58
                return $data;
×
59
        }
60

61
        /**
62
         * Adds the internal search JSON LD code to the homepage if it's not disabled.
63
         *
64
         * @link https://developers.google.com/search/docs/data-types/sitelinks-searchbox
65
         *
66
         * @param array $data The website data array.
67
         *
68
         * @return array
69
         */
70
        private function internal_search_section( $data ) {
71
                /**
72
                 * Filter: 'disable_wpseo_json_ld_search' - Allow disabling of the json+ld output.
73
                 *
74
                 * @api bool $display_search Whether or not to display json+ld search on the frontend.
75
                 */
76
                if ( \apply_filters( 'disable_wpseo_json_ld_search', false ) ) {
×
77
                        return $data;
×
78
                }
79

80
                /**
81
                 * Filter: 'wpseo_json_ld_search_url' - Allows filtering of the search URL for Yoast SEO.
82
                 *
83
                 * @api string $search_url The search URL for this site with a `{search_term_string}` variable.
84
                 */
85
                $search_url = \apply_filters( 'wpseo_json_ld_search_url', $this->context->site_url . '?s={search_term_string}' );
×
86

87
                $data['potentialAction'][] = [
×
88
                        '@type'       => 'SearchAction',
×
89
                        'target'      => [
×
90
                                '@type'       => 'EntryPoint',
×
91
                                'urlTemplate' => $search_url,
×
92
                        ],
×
93
                        'query-input' => 'required name=search_term_string',
×
94
                ];
×
95

96
                return $data;
×
97
        }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc