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

Yoast / wordpress-seo / b51d845f89fe206089fb5db4f0ce36d8be6498bf

17 Feb 2026 11:03AM UTC coverage: 53.676%. First build
b51d845f89fe206089fb5db4f0ce36d8be6498bf

push

github

web-flow
Merge pull request #22973 from Yoast/feature/schema_aggregator

Merges `feature/schema-aggregation` to `trunk`

8863 of 16393 branches covered (54.07%)

Branch coverage included in aggregate %.

763 of 1164 new or added lines in 65 files covered. (65.55%)

33819 of 63125 relevant lines covered (53.57%)

47395.23 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
         */
NEW
19
        public function set_header_for_request( WP_REST_Response $response ) {
×
NEW
20
                $data = $response->get_data();
×
21

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

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

NEW
29
                if ( \strpos( $content_type, 'application/xml' ) !== false ) {
×
NEW
30
                        \header( 'Content-Type: application/xml; charset=UTF-8' );
×
NEW
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 {
NEW
34
                        \header( 'X-Accel-Buffering: no' );
×
NEW
35
                        \header( 'Content-Type: application/json; charset=UTF-8' );
×
NEW
36
                        foreach ( $data as $schema_piece ) {
×
37
                                // @phpcs:disable Yoast.Yoast.JsonEncodeAlternative.FoundWithAdditionalParams -- The pretty print option breaks the JSONL format.
NEW
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
                                \ob_flush();
×
NEW
40
                                \flush();
×
41
                                // @phpcs:enable
42
                        }
43
                }
44
        }
45
}
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