mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap/Load: Send HTTP headers after querying posts in
WP::main()
.
By running `WP::send_headers()` after posts have been queried, we can ensure that conditional tags like `is_front_page()`, `is_home()`, etc. work as expected. This provides better context and more flexibility when adjusting HTTP headers via the `wp_headers` filter or `send_headers` action. Previously, the earliest action where conditional tags worked correctly was `wp`. Includes moving the `X-Pingback` header, previously sent in `WP::handle_404()` after posts have been queried, to a more appropriate place in `WP::send_headers()`. Follow-up to [2627], [34442]. Props jonoaldersonwp, joostdevalk, peterwilsoncc, adamsilverstein, SergeyBiryukov. Fixes #56068. git-svn-id: https://develop.svn.wordpress.org/trunk@54250 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
1 parent
61f7e75
commit ca0979b
Showing
2 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @group wp | ||
* @covers WP::send_headers | ||
*/ | ||
class Tests_WP_SendHeaders extends WP_UnitTestCase { | ||
|
||
/** | ||
* @ticket 56068 | ||
*/ | ||
public function test_send_headers_runs_after_posts_have_been_queried() { | ||
add_action( | ||
'send_headers', | ||
function ( $wp ) { | ||
$this->assertQueryTrue( 'is_front_page', 'is_home' ); | ||
} | ||
); | ||
|
||
$this->go_to( home_url() ); | ||
} | ||
} |