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

Yoast / wordpress-seo / 6cad32f98a761e1adcee035e55e0885f3ffc810e

03 Mar 2026 02:05PM UTC coverage: 53.915% (-2.6%) from 56.496%
6cad32f98a761e1adcee035e55e0885f3ffc810e

push

github

vraja-pro
Merge remote-tracking branch 'origin/trunk' into feature/task-list-phase-3

9014 of 16577 branches covered (54.38%)

Branch coverage included in aggregate %.

47 of 76 new or added lines in 19 files covered. (61.84%)

2 existing lines in 1 file now uncovered.

34238 of 63645 relevant lines covered (53.8%)

47008.35 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
                                }
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