Make WordPress Core


Ignore:
Timestamp:
10/18/2022 04:09:50 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/wp/sendHeaders.php

    r54250 r54636  
    2020        $this->go_to( home_url() );
    2121    }
     22
     23    /**
     24     * @ticket 56840
     25     */
     26    public function test_send_headers_sets_x_pingback_for_single_posts_that_allow_pings() {
     27        add_action(
     28            'wp_headers',
     29            function ( $headers ) {
     30                $this->assertArrayHasKey( 'X-Pingback', $headers );
     31            }
     32        );
     33
     34        $post_id = self::factory()->post->create();
     35        $this->go_to( get_permalink( $post_id ) );
     36    }
    2237}
Note: See TracChangeset for help on using the changeset viewer.