Skip to content

Commit

Permalink
Add condition to skip caching if wp_404_caching is disabled
Browse files Browse the repository at this point in the history
A condition was inserted at the beginning of the action__template_redirect function in class-full-page-cache-404.php. This checks if wp_404_caching is disabled by a filter; if it's disabled, the function returns without caching.
  • Loading branch information
attackant committed Mar 15, 2024
1 parent cd7dbcf commit d555cf8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/features/class-full-page-cache-404.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public function boot(): void {
*/
public static function action__template_redirect(): void {

if ( ! apply_filters( 'wp_404_caching_enabled', true ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return;
}

// Don't cache if not a 404.
if ( ! is_404() ) {
return;
Expand Down

0 comments on commit d555cf8

Please sign in to comment.