wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php	Fri Sep 05 18:52:52 2025 +0200
@@ -119,6 +119,11 @@
 	 * @return WP_REST_Response Response object on success.
 	 */
 	public function get_items( $request ) {
+		if ( $request->is_method( 'HEAD' ) ) {
+			// Return early as this handler doesn't add any response headers.
+			return new WP_REST_Response( array() );
+		}
+
 		$this->retrieve_widgets();
 
 		$data              = array();
@@ -321,6 +326,12 @@
 		// Restores the more descriptive, specific name for use within this method.
 		$raw_sidebar = $item;
 
+		// Don't prepare the response body for HEAD requests.
+		if ( $request->is_method( 'HEAD' ) ) {
+			/** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php */
+			return apply_filters( 'rest_prepare_sidebar', new WP_REST_Response( array() ), $raw_sidebar, $request );
+		}
+
 		$id      = $raw_sidebar['id'];
 		$sidebar = array( 'id' => $id );