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

Yoast / wordpress-seo / bdb19fe0dd51178685796832637565c97b9e6647

24 Feb 2026 05:59PM UTC coverage: 53.703% (+3.0%) from 50.685%
bdb19fe0dd51178685796832637565c97b9e6647

push

github

thijsoo
Merge branch 'release/27.1' of github.com:Yoast/wordpress-seo into trunk

8877 of 16412 branches covered (54.09%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

33839 of 63129 relevant lines covered (53.6%)

47392.24 hits per line

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

0.0
/src/schema-aggregator/infrastructure/schema_map/schema-map-header-adapter.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Schema_Map;
4

5
use WP_REST_Response;
6

7
/**
8
 * Adapter to set proper response headers for Schema Map responses.
9
 */
10
class Schema_Map_Header_Adapter {
11

12
        /**
13
         * Set proper headers for Schema Map responses.
14
         *
15
         * @param WP_REST_Response $response The REST response object.
16
         *
17
         * @return void
18
         */
19
        public function set_header_for_request( WP_REST_Response $response ) {
×
20
                $data = $response->get_data();
×
21

22
                foreach ( $response->get_headers() as $key => $value ) {
×
23
                        \header( \sprintf( '%s: %s', $key, $value ) );
×
24
                }
25

26
                $headers      = $response->get_headers();
×
27
                $content_type = ( $headers['Content-Type'] ?? 'application/json; charset=UTF-8' );
×
28

29
                if ( \strpos( $content_type, 'application/xml' ) !== false ) {
×
30
                        \header( 'Content-Type: application/xml; charset=UTF-8' );
×
31
                        echo $data; //@phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $data should already be escaped here since this just adds headers to the request.
×
32
                }
33
                else {
34
                        \header( 'X-Accel-Buffering: no' );
×
35
                        \header( 'Content-Type: application/json; charset=UTF-8' );
×
36
                        foreach ( $data as $schema_piece ) {
×
37
                                // @phpcs:disable Yoast.Yoast.JsonEncodeAlternative.FoundWithAdditionalParams -- The pretty print option breaks the JSONL format.
38
                                echo \wp_json_encode( $schema_piece, ( \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE ) ) . \PHP_EOL; // @phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $data should already be escaped here since this just adds headers to the request.
×
NEW
39
                                if ( \ob_get_level() > 0 ) {
×
NEW
40
                                        \ob_flush();
×
41
                                }
UNCOV
42
                                \flush();
×
43
                                // @phpcs:enable
44
                        }
45
                }
46
        }
47
}
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