- Timestamp:
- 10/12/2023 03:15:04 PM (16 months ago)
- Location:
- branches/5.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.7
- Property svn:mergeinfo changed
/trunk merged: 56833-56838
- Property svn:mergeinfo changed
-
branches/5.7/src/wp-includes/rest-api/class-wp-rest-server.php
r50150 r56886 318 318 319 319 /** 320 * Filters whether to send nocache headers on a REST API request.321 *322 * @since 4.4.0323 *324 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.325 */326 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );327 if ( $send_no_cache_headers ) {328 foreach ( wp_get_nocache_headers() as $header => $header_value ) {329 if ( empty( $header_value ) ) {330 $this->remove_header( $header );331 } else {332 $this->send_header( $header, $header_value );333 }334 }335 }336 337 /**338 320 * Filters whether the REST API is enabled. 339 321 * … … 401 383 * header. 402 384 */ 385 $method_overridden = false; 403 386 if ( isset( $_GET['_method'] ) ) { 404 387 $request->set_method( $_GET['_method'] ); 405 388 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 406 389 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 390 $method_overridden = true; 407 391 } 408 392 … … 462 446 */ 463 447 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 448 449 /** 450 * Filters whether to send nocache headers on a REST API request. 451 * 452 * @since 4.4.0 453 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 454 * 455 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 456 */ 457 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 458 459 // send no cache headers if the $send_no_cache_headers is true 460 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 461 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 462 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 463 if ( empty( $header_value ) ) { 464 $this->remove_header( $header ); 465 } else { 466 $this->send_header( $header, $header_value ); 467 } 468 } 469 } 464 470 465 471 if ( ! $served ) {
Note: See TracChangeset
for help on using the changeset viewer.