Bootstrap/Load: Correct sending the X-Pingback header in WP::send_headers().

The logic for sending the `X-Pingback` header for single posts that allow pings was recently moved from `WP::handle_404()`​ to a more appropriate place in `WP::send_headers()`.

To check whether pings are open for a particular post, that logic relies on the `$wp_query` global, which is declared in `WP::handle_404()`, but not in `WP::send_headers()`

This commit ensures that `$wp_query` is globalized in `WP::send_headers()` too, so that the check works as expected.

Follow-up to [54250].

Props strategio, sabernhardt, dlh, davidbaumwald, SergeyBiryukov.
Fixes #56840.

git-svn-id: https://develop.svn.wordpress.org/trunk@54636 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-10-18 16:09:50 +00:00
parent 4bff0ccfe5
commit 3977b6b06d
2 changed files with 19 additions and 0 deletions
+15
View File
@@ -19,4 +19,19 @@ class Tests_WP_SendHeaders extends WP_UnitTestCase {
$this->go_to( home_url() );
}
/**
* @ticket 56840
*/
public function test_send_headers_sets_x_pingback_for_single_posts_that_allow_pings() {
add_action(
'wp_headers',
function ( $headers ) {
$this->assertArrayHasKey( 'X-Pingback', $headers );
}
);
$post_id = self::factory()->post->create();
$this->go_to( get_permalink( $post_id ) );
}
}