Changeset 59899 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php
- Timestamp:
- 03/02/2025 10:05:08 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php
r57686 r59899 90 90 $collections_page = array_slice( $collections_all, ( $page - 1 ) * $per_page, $per_page ); 91 91 92 $is_head_request = $request->is_method( 'HEAD' ); 93 92 94 $items = array(); 93 95 foreach ( $collections_page as $collection ) { … … 98 100 continue; 99 101 } 102 103 /* 104 * Skip preparing the response body for HEAD requests. 105 * Cannot exit earlier due to backward compatibility reasons, 106 * as validation occurs in the prepare_item_for_response method. 107 */ 108 if ( $is_head_request ) { 109 continue; 110 } 111 100 112 $item = $this->prepare_response_for_collection( $item ); 101 113 $items[] = $item; 102 114 } 103 115 104 $response = rest_ensure_response( $items );116 $response = $is_head_request ? new WP_REST_Response() : rest_ensure_response( $items ); 105 117 106 118 $response->header( 'X-WP-Total', (int) $total_items ); … … 176 188 } 177 189 190 /** 191 * Don't prepare the response body for HEAD requests. 192 * Can't exit at the beginning of the method due to the potential need to return a WP_Error object. 193 */ 194 if ( $request->is_method( 'HEAD' ) ) { 195 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php */ 196 return apply_filters( 'rest_prepare_font_collection', new WP_REST_Response(), $item, $request ); 197 } 198 178 199 foreach ( $data_fields as $field ) { 179 200 if ( rest_is_field_included( $field, $fields ) ) { … … 181 202 } 182 203 } 204 } 205 206 /** 207 * Don't prepare the response body for HEAD requests. 208 * Can't exit at the beginning of the method due to the potential need to return a WP_Error object. 209 */ 210 if ( $request->is_method( 'HEAD' ) ) { 211 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php */ 212 return apply_filters( 'rest_prepare_font_collection', new WP_REST_Response(), $item, $request ); 183 213 } 184 214
Note: See TracChangeset
for help on using the changeset viewer.