Skip to content

Commit 34da52d

Browse files
stodorovickraftbj
authored andcommitted
Merge branch 'cherry-pick/436-hide-debug-rest-ajax' of github.com:Automattic/wp-super-cache into cherry-pick/613-home-url-supercache-dir
2 parents 46a9a46 + 4d15180 commit 34da52d

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

wp-cache-phase2.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,14 @@ function wp_cache_append_tag( &$buffer ) {
22092209
$msg = "Live page served on $timestamp";
22102210
}
22112211

2212-
if ( strpos( $buffer, '<html' ) === false ) {
2212+
// Don't output debug message if we aren't handling a normal HTML response.
2213+
if (
2214+
strpos( $buffer, '<html' ) === false ||
2215+
( defined( 'REST_REQUEST' ) && REST_REQUEST ) ||
2216+
( defined( 'JSON_REQUEST' ) && JSON_REQUEST ) ||
2217+
( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST ) ||
2218+
( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() )
2219+
) {
22132220
wp_cache_debug( site_url( $_SERVER['REQUEST_URI'] ) . ' - ' . $msg );
22142221
return false;
22152222
}
@@ -2228,7 +2235,14 @@ function wp_cache_add_to_buffer( &$buffer, $text ) {
22282235
return false;
22292236
}
22302237

2231-
if ( strpos( $buffer, '<html' ) === false ) {
2238+
// Don't output debug message if we aren't handling a normal HTML response.
2239+
if (
2240+
strpos( $buffer, '<html' ) === false ||
2241+
( defined( 'REST_REQUEST' ) && REST_REQUEST ) ||
2242+
( defined( 'JSON_REQUEST' ) && JSON_REQUEST ) ||
2243+
( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST ) ||
2244+
( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() )
2245+
) {
22322246
wp_cache_debug( site_url( $_SERVER['REQUEST_URI'] ) . ' - ' . $text );
22332247
return false;
22342248
}

0 commit comments

Comments
 (0)