mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
REST API: Core typically sends nocache headers on all auth'ed responses, as in wp, admin-ajax, etc. Because the REST API infrastructure is hooked in pre-wp, we should be setting this ourselves.
Adds unit tests. Props joehoyle. Fixes #34832. git-svn-id: https://develop.svn.wordpress.org/trunk@35773 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -236,6 +236,20 @@ class WP_REST_Server {
|
||||
$this->send_header( 'Access-Control-Expose-Headers', 'X-WP-Total, X-WP-TotalPages' );
|
||||
$this->send_header( 'Access-Control-Allow-Headers', 'Authorization' );
|
||||
|
||||
/**
|
||||
* Send nocache headers on authenticated requests.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param bool $rest_send_nocache_headers Whether to send no-cache headers.
|
||||
*/
|
||||
$send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
|
||||
if ( $send_no_cache_headers ) {
|
||||
foreach ( wp_get_nocache_headers() as $header => $header_value ) {
|
||||
$this->send_header( $header, $header_value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter whether the REST API is enabled.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user