From 39c326fb027513f643d4b2045e590ed2ceeadb62 Mon Sep 17 00:00:00 2001 From: Anton Vlasenko Date: Thu, 2 Jan 2025 21:02:20 +0100 Subject: [PATCH] Short circuit the WP_REST_Pattern_Directory_Controller controller. --- .../endpoints/class-wp-rest-pattern-directory-controller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php index e31c47ee61a4b..4dda8b345569e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php @@ -161,6 +161,11 @@ public function get_items( $request ) { return $raw_patterns; } + if ( $request->is_method( 'HEAD' ) ) { + // Return early as this handler doesn't add any response headers. + return new WP_REST_Response(); + } + $response = array(); if ( $raw_patterns ) {